contrib/OWB: add correct SDL dependency, fix compilers used
[AROS-Contrib.git] / freetype1 / contrib / ftos2 / ifi / test.c
blobb7930127225f5a8fe1b10c996d190e35f6b76c27
2 #include <os2.h>
4 #include <stdio.h>
5 #include <stdlib.h>
6 #include <string.h>
7 #include "32pmifi.h"
9 //#define USE_ORIG
10 #ifdef USE_ORIG
11 #pragma import (fdhdr, "FONT_DRIVER_DISPATCH_TABLE", "TRUETYPE", 0)
12 #else
13 #if defined USE_ATM
14 #pragma import (fdhdr, "FONT_DRIVER_DISPATCH_TABLE", "PMATM", 0)
15 #else
16 #pragma import (fdhdr, "FONT_DRIVER_DISPATCH_TABLE", "FREETYPE", 0)
17 #endif
18 #endif
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"
44 #ifdef USE_ATM
45 #define FNTNAME2 "\\PSFONTS\\helv.ofm"
46 #else
47 #define FNTNAME2 "\\PSFONTS\\symbol.tTf"
48 #endif
50 #define BUFSIZE 32768
52 void ShowChar(PCHARATTR pca, PBITMAPMETRICS pbmm) {
53 int i, j;
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))))
59 printf("*");
60 else
61 printf(" ");
62 printf("\n");
66 void main(int argc, char **argv)
68 char fname[260];
69 PFDDISPATCH pfdisp;
70 LONG rc;
71 HFF hff, hff2; /* font file */
72 HFC hfc, hfc2; /* font context */
73 static IFIMETRICS ifimet[12]; /* IFI metrics */
74 CONTEXTINFO ci;
75 CHARATTR charattr; /* character attributes */
76 BITMAPMETRICS bmm; /* bit-map metrics */
77 PBYTE buf;
78 int glyph = 0, i, j;
79 int numFaces;
80 int faceIndex = 0;
82 switch (argc) {
83 case 4:
84 strcpy(fname, argv[1]);
85 glyph = atoi(argv[2]);
86 faceIndex = atoi(argv[3]);
87 break;
89 case 2:
90 glyph = atoi(argv[1]);
91 case 1:
92 strcpy(fname, FNTNAME1);
93 break;
95 default:
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");
103 return;
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)
112 return;
114 /* rc = fdhdr.pfddisp->FdConvertFontFile("G:\\PSFONTS\\TIMES.TTF",
115 "G:\\PSFONTS", buf); */
117 #if 0
118 for (i = 0; i < 18; i++) {
119 hff = fdhdr.pfddisp->FdLoadFontFile(fontnames[i]);
120 if (hff == (HFF)-1) {
121 printf("x");
122 continue;
124 numFaces = fdhdr.pfddisp->FdQueryFaces(hff, NULL, 0, -1, 0);
125 if (numFaces < 0) {
126 printf("x");
127 continue;
129 for (j = 0; j < numFaces; j++) {
130 rc = fdhdr.pfddisp->FdQueryFaces(hff, &ifimet[0], 238, 1, j);
131 if (rc < 0) {
132 printf("x");
133 continue;
137 rc = fdhdr.pfddisp->FdUnloadFontFile(hff);
138 if (rc)
139 printf("x");
140 else
141 printf(".");
143 printf("\n");
144 #endif
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)
153 return;
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);
164 ci.cb = sizeof(ci);
165 ci.fl = 0;
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),
188 NULL, 0);
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;
197 charattr.gi = glyph;
198 charattr.pBuffer = buf;
199 charattr.cbLen = BUFSIZE;
200 if (rc == -1)
201 return;
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)
212 return;
214 charattr.cbLen = 0;
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);