summaryrefslogtreecommitdiff
path: root/Build/source/texk/web2c/omegafonts/param_routines.c
blob: bdf243e659d6289e77838bee593535ce4e1608f3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
/* param_routines.c: Data structures for parameter lists.

This file is part of Omega,
which is based on the web2c distribution of TeX,

Copyright (c) 1994--2001 John Plaice and Yannis Haralambous

Omega is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

Omega is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with Omega; if not, write to the Free Software Foundation, Inc.,
59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.

*/

#include "cpascal.h"
#include "list_routines.h"
#include "manifests.h"
#include "header_routines.h"
#include "param_routines.h"
#include "print_routines.h"
#include "out_routines.h"
#include "error_routines.h"
#include "out_ofm.h"

#define PARAM_MIN 1

av_list param_list = NULL;
int param_max = PARAM_MIN-1;
int param_started = FALSE;

unsigned np=0;

void
init_parameters(void)
{
    if (param_started==TRUE)
    warning_0("FONTDIMEN previously defined;  all old parameters ignored");
    if (param_list!=NULL) {
        av_list L1 = param_list, L2;
        while (L1 != NULL) {
	    L2 = L1->ptr;
	    free(L1);
	    L1 = L2;
        }
    }
    param_list = NULL;
    param_max = PARAM_MIN-1;
    np=param_max;
    param_started = TRUE;
}

void
set_param_word(int index, int val)
{
    av_list L1, L2;

    if (index < PARAM_MIN) {
        warning_0("PARAMETER index must be at least 1; ignored");
        return;
    }
    L1 = param_list;
    if (L1 == NULL) {
        param_list = av_list1(index, val);
        param_max = index;
        np=param_max;
    } else {
        L2 = L1->ptr;
        while ((L2 != NULL) && (lattr(L2) <= index)) {
            L1 = L2;
            L2 = L2->ptr;
        }
        if (index < lattr(L1)) {
            param_list = av_list1(index, val);
            param_list->ptr = L1;
	} else if (index == lattr(L1)) {
        warning_1("PARAMETER index (%d) previously defined; "
                  "old value ignored", index);
            lval(L1)  = val;
        } else {
            if (L2==NULL) {param_max=index; np=param_max;}
            L2 = av_list1(index, val);
            L2->ptr = L1->ptr;
            L1->ptr = L2;
        }
    }
}

void
retrieve_parameters(unsigned char *table)
{
    int value;
    unsigned i;
    unsigned np_prime = np;

    param_list = NULL;
    for (i=1; i<=np_prime; i++) {
        value = ((table[4*i] & 0xff) << 24) |
                ((table[4*i+1] & 0xff) << 16) |
                ((table[4*i+2] & 0xff) << 8) |
                (table[4*i+3] & 0xff);
        if ((i<=7) | (value != 0)) {
           set_param_word(i, value);
        }
    }
    np = np_prime;
}

void
print_parameters(void)
{
    av_list L = param_list;

    if (L == NULL)
        return;

    print_font_dimension();
    while (L != NULL) {
	print_parameter(lattr(L), lval(L));
	L = L->ptr;
    }
    right();
}

static void
output_ofm_one_parameter(unsigned i, fix param)
{
    if (i==P_SLANT) out_ofm_4(param);
    else out_ofm_scaled(param);
}

void
output_ofm_parameter(void)
{
    unsigned i=1, j;

    av_list L = param_list;

    while(L != NULL) {
       j=lattr(L);
       while (i<j) {
           output_ofm_one_parameter(i, 0);
           i++;
       }
       output_ofm_one_parameter(i, lval(L));
       L = L->ptr; i++;
    }
}