11 #pragma import (fdhdr, "FONT_DRIVER_DISPATCH_TABLE", "TRUETYPE", 0)
14 #pragma import (fdhdr, "FONT_DRIVER_DISPATCH_TABLE", "PMATM", 0)
16 #pragma import (fdhdr, "FONT_DRIVER_DISPATCH_TABLE", "FREETYPE", 0)
20 extern FDHEADER fdhdr
;
22 char *fontnames
[20] = {
23 "G:\\OS2\\MDOS\\WINOS2\\SYSTEM\\SYMBOL.TTF",
24 "G:\\OS2\\MDOS\\WINOS2\\SYSTEM\\WINGDING.TTF",
25 "G:\\PSFONTS\\ARIALB.ttf",
26 "G:\\PSFONTS\\ARIALI.ttf",
27 "G:\\PSFONTS\\ARIALZ.ttf",
28 "G:\\PSFONTS\\COUR.TTF",
29 "G:\\PSFONTS\\COURB.TTF",
30 "G:\\PSFONTS\\COURI.TTF",
31 "G:\\PSFONTS\\COURZ.TTF",
32 "G:\\PSFONTS\\ARIAL.ttf",
33 "G:\\PSFONTS\\TIMESB.TTF",
34 "G:\\PSFONTS\\TIMESI.ttf",
35 "G:\\PSFONTS\\TIMESZ.ttf",
36 "G:\\PSFONTS\\TIMES.TTF",
37 "G:\\PSFONTS\\ARIBLK.ttf",
38 "G:\\CHINESE\\AVSV.TTF",
39 "G:\\CHINESE\\MINGLI.TTC",
40 "D:\\PSFONTS\\TNRMT30.TTF"
43 #define FNTNAME1 "\\PSFONTS\\TIMES.TTF"
45 #define FNTNAME2 "\\PSFONTS\\helv.ofm"
47 #define FNTNAME2 "\\PSFONTS\\symbol.tTf"
52 void ShowChar(PCHARATTR pca
, PBITMAPMETRICS pbmm
) {
54 int bufwidth
= ((pbmm
->sizlExtent
.cx
+ 31) & -32) / 8;
56 for (i
=0; i
< pbmm
->sizlExtent
.cy
; i
++) {
57 for (j
= 0; j
< bufwidth
* 8; j
++)
58 if (pca
->pBuffer
[i
* bufwidth
+ j
/ 8] & (1 << (7-(j
% 8))))
66 void main(int argc
, char **argv
)
71 HFF hff
, hff2
; /* font file */
72 HFC hfc
, hfc2
; /* font context */
73 static IFIMETRICS ifimet
[12]; /* IFI metrics */
75 CHARATTR charattr
; /* character attributes */
76 BITMAPMETRICS bmm
; /* bit-map metrics */
84 strcpy(fname
, argv
[1]);
85 glyph
= atoi(argv
[2]);
86 faceIndex
= atoi(argv
[3]);
90 glyph
= atoi(argv
[1]);
92 strcpy(fname
, FNTNAME1
);
96 strcpy(fname
, argv
[1]);
97 glyph
= atoi(argv
[2]);
100 buf
= (PBYTE
)malloc(BUFSIZE
);
101 if (strncmp("OS/2 FONT DRIVER", fdhdr
.strId
, 16)) {
102 printf("Invalid Font Driver\n");
105 printf("Font Driver OK, ");
106 printf("Version %d\n", fdhdr
.ulVersion
);
107 printf("Technology: %s\n", fdhdr
.szTechnology
);
109 hff
= fdhdr
.pfddisp
->FdLoadFontFile(fname
);
110 printf("Loading font... HFF = %X\n", hff
);
111 if (hff
== (HFF
)0xFFFFFFFF)
114 /* rc = fdhdr.pfddisp->FdConvertFontFile("G:\\PSFONTS\\TIMES.TTF",
115 "G:\\PSFONTS", buf); */
118 for (i
= 0; i
< 18; i
++) {
119 hff
= fdhdr
.pfddisp
->FdLoadFontFile(fontnames
[i
]);
120 if (hff
== (HFF
)-1) {
124 numFaces
= fdhdr
.pfddisp
->FdQueryFaces(hff
, NULL
, 0, -1, 0);
129 for (j
= 0; j
< numFaces
; j
++) {
130 rc
= fdhdr
.pfddisp
->FdQueryFaces(hff
, &ifimet
[0], 238, 1, j
);
137 rc
= fdhdr
.pfddisp
->FdUnloadFontFile(hff
);
146 hff
= fdhdr
.pfddisp
->FdLoadFontFile(FNTNAME2
);
147 hff
= fdhdr
.pfddisp
->FdLoadFontFile(fname
);
148 rc
= fdhdr
.pfddisp
->FdUnloadFontFile(hff
);
150 hff
= fdhdr
.pfddisp
->FdLoadFontFile(fname
);
151 printf("Loading font... HFF = %X\n", hff
);
152 if (hff
== (HFF
)0xFFFFFFFF)
154 numFaces
= fdhdr
.pfddisp
->FdQueryFaces(hff
, NULL
, 0, -1, 0);
155 printf("Number of faces = %d\n", numFaces
);
156 rc
= fdhdr
.pfddisp
->FdQueryFaces(hff
, &ifimet
[0], sizeof(IFIMETRICS
), numFaces
, 0);
157 printf("Querying faces... RC = %X\n", rc
);
158 hfc
= fdhdr
.pfddisp
->FdOpenFontContext(hff
, faceIndex
);
159 printf("Opening context... HFC = %X\n", hfc
);
160 if (hfc
== (HFC
)0xFFFFFFFF) {
161 rc
= fdhdr
.pfddisp
->FdUnloadFontFile(hff
);
162 printf("Unloading font... RC = %X\n", rc
);
166 /* ci.sizlPPM.cx = 3618;
167 ci.sizlPPM.cy = 3622;
168 ci.pfxSpot.x = 46340;
169 ci.pfxSpot.y = 46340;
170 ci.matXform.eM11 = 511;
171 ci.matXform.eM12 = 0;
172 ci.matXform.eM21 = 0;
173 ci.matXform.eM22 = 511; */
174 ci
.sizlPPM
.cx
= 3622;
175 ci
.sizlPPM
.cy
= 3622;
176 ci
.pfxSpot
.x
= 46340;
177 ci
.pfxSpot
.y
= 46340;
178 ci
.matXform
.eM11
= 768;
179 ci
.matXform
.eM12
= 0;
180 ci
.matXform
.eM21
= 0;
181 ci
.matXform
.eM22
= 768;
183 rc
= fdhdr
.pfddisp
->FdQueryFaceAttr(hfc
, FD_QUERY_ABC_WIDTHS
, buf
,
184 sizeof(ABC_TRIPLETS
), NULL
, glyph
);
185 printf("Querying face attrs... RC = %d\n", rc
);
186 rc
= fdhdr
.pfddisp
->FdQueryFaceAttr(hfc
, FD_QUERY_KERNINGPAIRS
, buf
,
187 ifimet
[0].cKerningPairs
* sizeof(FD_KERNINGPAIRS
),
191 rc
= fdhdr
.pfddisp
->FdSetFontContext(hfc
, &ci
);
192 printf("Setting context... rc = %X\n", rc
);
194 charattr
.cb
= sizeof(charattr
);
195 charattr
.iQuery
= FD_QUERY_BITMAPMETRICS
| FD_QUERY_CHARIMAGE
;
196 // charattr.iQuery = FD_QUERY_OUTLINE;
198 charattr
.pBuffer
= buf
;
199 charattr
.cbLen
= BUFSIZE
;
202 rc
= fdhdr
.pfddisp
->FdQueryCharAttr(hfc
, &charattr
, &bmm
);
203 printf("Querying char attrs... bytes = %d\n", rc
);
204 ShowChar(&charattr
, &bmm
);
206 // rc = fdhdr.pfddisp->FdQueryCharAttr(hfc, &charattr, &bmm, NULL);
207 // printf("Querying char attrs... bytes = %d\n", rc);
209 hff2
= fdhdr
.pfddisp
->FdLoadFontFile(FNTNAME2
);
210 printf("Loading font... HFF = %X\n", hff2
);
211 if (hff2
== (HFF
)0xFFFFFFFF)
215 rc
= fdhdr
.pfddisp
->FdQueryCharAttr(hfc
, &charattr
, &bmm
);
216 printf("Querying char attrs... bytes = %d\n", rc
);
217 rc
= fdhdr
.pfddisp
->FdQueryFaces(hff2
, &ifimet
[0], sizeof(ifimet
), 1, 0);
218 printf("Querying faces... RC = %X\n", rc
);
219 hfc2
= fdhdr
.pfddisp
->FdOpenFontContext(hff2
, 0);
220 printf("Opening context... HFC = %X\n", hfc2
);
221 if (hfc2
== (HFC
)0xFFFFFFFF) {
222 rc
= fdhdr
.pfddisp
->FdUnloadFontFile(hff2
);
223 printf("Unloading font... RC = %X\n", rc
);
225 rc
= fdhdr
.pfddisp
->FdCloseFontContext(hfc
);
226 printf("Closing context... RC = %X\n", rc
);
227 rc
= fdhdr
.pfddisp
->FdUnloadFontFile(hff
);
228 printf("Unloading font... RC = %X\n", rc
);
229 rc
= fdhdr
.pfddisp
->FdUnloadFontFile(hff
);
230 printf("Unloading font... RC = %X\n", rc
);
232 rc
= fdhdr
.pfddisp
->FdCloseFontContext(hfc2
);
233 printf("Closing context... RC = %X\n", rc
);
234 rc
= fdhdr
.pfddisp
->FdUnloadFontFile(hff2
);
235 printf("Unloading font... RC = %X\n", rc
);
236 rc
= fdhdr
.pfddisp
->FdUnloadFontFile(hff2
);
237 printf("Unloading font... RC = %X\n", rc
);