summaryrefslogtreecommitdiff
path: root/systems/os2/dviware/hp-deskjet/fontfile.h
blob: f86a2219c516f796440170c3dcf9fde4c75a0048 (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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
                                                              /* -*-C-*- fontfile.h */
/*-->fontfile*/
/**********************************************************************/
/****************************** fontfile ******************************/
/**********************************************************************/

void
fontfile(filelist,font_path,font_name,magnification)
char *filelist[MAXFORMATS];     /* output filename list */
char *font_path;                /* host font file pathname */
char *font_name;                /* TeX font_name */
int magnification;              /* magnification value */
{

    /*
    Given a TeX font_name and a magnification value, construct a list of
    system-dependent  host  filenames,  returning  them  in  the   first
    argument.  The files are not guaranteed to exist.  The font names by
    default contains names for the PK,  GF, and PXL font files, but  the
    selection, and search order, may be changed at run time by  defining
    a value for the environment  variable FONTLIST.  See initglob()  for
    details.
    */

    register int m;                     /* index into filelist[] */
    register INT16 k;                   /* loop index */
    float fltdpi;                       /* dots/inch */
    int dpi;                            /* dots/inch for filename */

#if    OS_VAXVMS
    char *tcp;                  /* temporary character pointer */
    char *tcp2;                 /* temporary character pointer */
    char temp_name[MAXFNAME];   /* temporary filename */
#endif

    /*
    We need to convert an old-style ROUNDED integer magnification based
    on 1000 units = 200 dpi to an actual rounded dpi value.

    We have
        magnification = round(real_mag) = trunc(real_mag + 0.5)
    which implies
        float(magnification) - 0.5 <= real_mag < float(magnification) + 0.5

    We want
        dpi = round(real_mag/5.0)
    which implies
        float(dpi) - 0.5 <= real_mag/5.0 < float(dpi) + 0.5
    or
        5.0*float(dpi) - 2.5 <= real_mag < 5.0*float(dpi) + 2.5

    We can combine the two to conclude that
        5.0*float(dpi) - 2.5 < float(magnification) + 0.5
    or
        5.0*float(dpi) - 3 < float(magnification)
    which gives the STRICT inequality
        float(dpi) < (float(magnification) + 3.0)/5.0
    */

    fltdpi = (((float)magnification) + 3.0)/5.0;
    dpi = (int)fltdpi;
    if (fltdpi == (float)dpi)
        dpi--;                          /* enforce inequality */

    for (k = 0; k < MAXFORMATS; ++k) /* loop over possible file types */
      *filelist[k] = '\0';      /* Initially, all filenames are empty */

    m = 0;                              /* index in filelist[] */
    for (k = 0; k < MAXFORMATS; ++k) /* loop over possible file types */
    {

#if    OS_TOPS20

        /* Typical results:
            texfonts:amr10.300gf
            texfonts:amr10.300pk
            texfonts:amr10.1500pxl
        */

        if (k == gf_index)
            (void)sprintf(filelist[m++], "%s%s.%dgf",
                font_path, font_name, dpi);
        else if (k == pk_index)
            (void)sprintf(filelist[m++], "%s%s.%dpk",
                font_path, font_name, dpi);
        else if (k == pxl_index)
            (void)sprintf(filelist[m++], "%s%s.%dpxl",
                font_path, font_name, magnification);

#endif /* OS_TOPS20 */

#if    (OS_ATARI | OS_PCDOS | OS_IBMOS2)

        /* Typical results:
            d:\tex\fonts\300\amr10.gf
            d:\tex\fonts\300\amr10.pk
            d:\tex\fonts\1500\amr10.pxl
        */

        if (k == gf_index)
            (void)sprintf(filelist[m++], "%s%d\\%s.gf",
                font_path, dpi, font_name);
        else if (k == pk_index)
            (void)sprintf(filelist[m++], "%s%d\\%s.pk",
                font_path, dpi, font_name);
        else if (k == pxl_index)
            (void)sprintf(filelist[m++], "%s%d\\%s.pxl",
                font_path, magnification, font_name);

#endif /* OS_PCDOS */

#if    OS_UNIX

        /* Typical results (both naming styles are tried):
            /usr/lib/tex/fonts/300/amr10.gf
            /usr/lib/tex/fonts/amr10.300gf
            /usr/lib/tex/fonts/300/amr10.pk
            /usr/lib/tex/fonts/1500/amr10.pxl
            /usr/lib/tex/fonts/amr10.1500pxl
            /usr/lib/tex/fonts/amr10.300pk
        */

        if (k == gf_index)
        {
            (void)sprintf(filelist[m++], "%s%d/%s.gf",
                font_path, dpi, font_name);
            (void)sprintf(filelist[m++], "%s%s.%dgf",
                font_path, font_name, dpi);
        }
        else if (k == pk_index)
        {
            (void)sprintf(filelist[m++], "%s%d/%s.pk",
                font_path, dpi, font_name);
            (void)sprintf(filelist[m++], "%s%s.%dpk",
                font_path, font_name, dpi);
        }
        else if (k == pxl_index)
        {
            (void)sprintf(filelist[m++], "%s%d/%s.pxl",
                font_path, magnification, font_name);
            (void)sprintf(filelist[m++], "%s%s.%dpxl",
                font_path, font_name, magnification);
        }
        /*(void)fprintf(stderr,"In fontfile: Path = %s\n",filelist[m - 1]);*/

#endif /* OS_UNIX */


#if    OS_VAXVMS

        /* Typical results (both naming styles are tried):
            [tex.fonts.300]amr10.gf
            [tex.fonts]amr10.300gf
            [tex.fonts.300]amr10.pk
            [tex.fonts]amr10.300pk
            [tex.fonts.1500]amr10.pxl
            [tex.fonts]amr10.1500pxl


        We try a translation of  a logical name here if  what we have in
        fontpath[]    is   not     a   directory  specification     like
        "device:[tex.fonts]" or a rooted logical  name like "tex_fonts:"
        translating to something like "device:[tex.fonts.]"
        */


        /* Use a straightforward expansion first, in case fontpath is
           a search list. */
        if (k == gf_index)
        {
            (void)sprintf(filelist[m++], "%s[%d]%s.gf", fontpath,
                dpi, font_name);
            (void)sprintf(filelist[m++], "%s%s.%dgf", fontpath,
                font_name, dpi);
        }
        else if (k == pk_index)
        {
            (void)sprintf(filelist[m++], "%s[%d]%s.pk", fontpath,
                dpi, font_name);
            (void)sprintf(filelist[m++], "%s%s.%dpk", fontpath,
                font_name, dpi);
        }
        else if (k == pxl_index)
        {
            (void)sprintf(filelist[m++], "%s[%d]%s.pxl", fontpath,
                magnification, font_name);
            (void)sprintf(filelist[m++], "%s%s.%dpxl", fontpath,
                font_name, magnification);
        }

        (void)strcpy(temp_name,fontpath);
        tcp = strrchr(temp_name,']'); /* search for last right bracket */
        if (tcp == (char *)NULL) /* then try logical name translation */
        {
            tcp = GETENV(fontpath);
            if (tcp != (char *)NULL)
            {
                tcp2 = strrchr(tcp,']');
                if (tcp2 == (char *)NULL)
                  tcp = (char *)NULL; /* translates to another logical name */
                else
                {
                    if (*(tcp2-1) == '.')
                        tcp = (char *)NULL; /* looks like rooted logical name */
                    else        /* looks like directory name */
                    {
                        (void)strcpy(temp_name,tcp);
                        tcp = strrchr(temp_name,']');
                    }
                }
            }
        }
        if (tcp != (char *)NULL)
        {    /* fontpath is something like [tex.fonts] */
            *tcp = '\0';            /* clobber right bracket */
            if (k == gf_index)
            {
                (void)sprintf(filelist[m++], "%s.%d]%s.gf", temp_name,
                    dpi, font_name);
                (void)sprintf(filelist[m++], "%s]%s.%dgf", temp_name,
                    font_name, dpi);
            }
            else if (k == pk_index)
            {
                (void)sprintf(filelist[m++], "%s.%d]%s.pk", temp_name,
                    dpi, font_name);
                (void)sprintf(filelist[m++], "%s]%s.%dpk", temp_name,
                    font_name, dpi);
            }
            else if (k == pxl_index)
            {
                (void)sprintf(filelist[m++], "%s.%d]%s.pxl", temp_name,
                    magnification, font_name);
                (void)sprintf(filelist[m++], "%s]%s.%dpxl", temp_name,
                    font_name, magnification);
            }
        }
#endif /* OS_VAXVMS */
    }

}