Moved undocshell.h to dlls/shell32. Removed shell16.h.
[wine/multimedia.git] / objects / font.c
blob8706b9668ec519859fb45e3c0ffa776caa7dfcce
1 /*
2 * GDI font objects
4 * Copyright 1993 Alexandre Julliard
5 * 1997 Alex Korobka
6 */
8 #include <stdlib.h>
9 #include <string.h>
10 #include "winerror.h"
11 #include "winnls.h"
12 #include "font.h"
13 #include "heap.h"
14 #include "options.h"
15 #include "debugtools.h"
16 #include "gdi.h"
18 DEFAULT_DEBUG_CHANNEL(font);
19 DECLARE_DEBUG_CHANNEL(gdi);
21 #define ENUM_UNICODE 0x00000001
23 typedef struct
25 LPLOGFONT16 lpLogFontParam;
26 FONTENUMPROCEX16 lpEnumFunc;
27 LPARAM lpData;
29 LPNEWTEXTMETRICEX16 lpTextMetric;
30 LPENUMLOGFONTEX16 lpLogFont;
31 SEGPTR segTextMetric;
32 SEGPTR segLogFont;
33 } fontEnum16;
35 typedef struct
37 LPLOGFONTW lpLogFontParam;
38 FONTENUMPROCEXW lpEnumFunc;
39 LPARAM lpData;
41 DWORD dwFlags;
42 } fontEnum32;
45 * For TranslateCharsetInfo
47 #define FS(x) {{0,0,0,0},{0x1<<(x),0}}
48 #define MAXTCIINDEX 32
49 static CHARSETINFO FONT_tci[MAXTCIINDEX] = {
50 /* ANSI */
51 { ANSI_CHARSET, 1252, FS(0)},
52 { EASTEUROPE_CHARSET, 1250, FS(1)},
53 { RUSSIAN_CHARSET, 1251, FS(2)},
54 { GREEK_CHARSET, 1253, FS(3)},
55 { TURKISH_CHARSET, 1254, FS(4)},
56 { HEBREW_CHARSET, 1255, FS(5)},
57 { ARABIC_CHARSET, 1256, FS(6)},
58 { BALTIC_CHARSET, 1257, FS(7)},
59 /* reserved by ANSI */
60 { DEFAULT_CHARSET, 0, FS(0)},
61 { DEFAULT_CHARSET, 0, FS(0)},
62 { DEFAULT_CHARSET, 0, FS(0)},
63 { DEFAULT_CHARSET, 0, FS(0)},
64 { DEFAULT_CHARSET, 0, FS(0)},
65 { DEFAULT_CHARSET, 0, FS(0)},
66 { DEFAULT_CHARSET, 0, FS(0)},
67 { DEFAULT_CHARSET, 0, FS(0)},
68 /* ANSI and OEM */
69 { THAI_CHARSET, 874, FS(16)},
70 { SHIFTJIS_CHARSET, 932, FS(17)},
71 { GB2312_CHARSET, 936, FS(18)},
72 { HANGEUL_CHARSET, 949, FS(19)},
73 { CHINESEBIG5_CHARSET, 950, FS(20)},
74 { JOHAB_CHARSET, 1361, FS(21)},
75 /* reserved for alternate ANSI and OEM */
76 { DEFAULT_CHARSET, 0, FS(0)},
77 { DEFAULT_CHARSET, 0, FS(0)},
78 { DEFAULT_CHARSET, 0, FS(0)},
79 { DEFAULT_CHARSET, 0, FS(0)},
80 { DEFAULT_CHARSET, 0, FS(0)},
81 { DEFAULT_CHARSET, 0, FS(0)},
82 { DEFAULT_CHARSET, 0, FS(0)},
83 { DEFAULT_CHARSET, 0, FS(0)},
84 /* reserved for system */
85 { DEFAULT_CHARSET, 0, FS(0)},
86 { DEFAULT_CHARSET, 0, FS(0)},
89 /***********************************************************************
90 * LOGFONT conversion functions.
92 void FONT_LogFontATo16( const LOGFONTA* font32, LPLOGFONT16 font16 )
94 font16->lfHeight = font32->lfHeight;
95 font16->lfWidth = font32->lfWidth;
96 font16->lfEscapement = font32->lfEscapement;
97 font16->lfOrientation = font32->lfOrientation;
98 font16->lfWeight = font32->lfWeight;
99 font16->lfItalic = font32->lfItalic;
100 font16->lfUnderline = font32->lfUnderline;
101 font16->lfStrikeOut = font32->lfStrikeOut;
102 font16->lfCharSet = font32->lfCharSet;
103 font16->lfOutPrecision = font32->lfOutPrecision;
104 font16->lfClipPrecision = font32->lfClipPrecision;
105 font16->lfQuality = font32->lfQuality;
106 font16->lfPitchAndFamily = font32->lfPitchAndFamily;
107 lstrcpynA( font16->lfFaceName, font32->lfFaceName, LF_FACESIZE );
110 void FONT_LogFontWTo16( const LOGFONTW* font32, LPLOGFONT16 font16 )
112 font16->lfHeight = font32->lfHeight;
113 font16->lfWidth = font32->lfWidth;
114 font16->lfEscapement = font32->lfEscapement;
115 font16->lfOrientation = font32->lfOrientation;
116 font16->lfWeight = font32->lfWeight;
117 font16->lfItalic = font32->lfItalic;
118 font16->lfUnderline = font32->lfUnderline;
119 font16->lfStrikeOut = font32->lfStrikeOut;
120 font16->lfCharSet = font32->lfCharSet;
121 font16->lfOutPrecision = font32->lfOutPrecision;
122 font16->lfClipPrecision = font32->lfClipPrecision;
123 font16->lfQuality = font32->lfQuality;
124 font16->lfPitchAndFamily = font32->lfPitchAndFamily;
125 WideCharToMultiByte( CP_ACP, 0, font32->lfFaceName, -1,
126 font16->lfFaceName, LF_FACESIZE, NULL, NULL );
127 font16->lfFaceName[LF_FACESIZE-1] = 0;
130 void FONT_LogFont16ToA( const LOGFONT16 *font16, LPLOGFONTA font32 )
132 font32->lfHeight = font16->lfHeight;
133 font32->lfWidth = font16->lfWidth;
134 font32->lfEscapement = font16->lfEscapement;
135 font32->lfOrientation = font16->lfOrientation;
136 font32->lfWeight = font16->lfWeight;
137 font32->lfItalic = font16->lfItalic;
138 font32->lfUnderline = font16->lfUnderline;
139 font32->lfStrikeOut = font16->lfStrikeOut;
140 font32->lfCharSet = font16->lfCharSet;
141 font32->lfOutPrecision = font16->lfOutPrecision;
142 font32->lfClipPrecision = font16->lfClipPrecision;
143 font32->lfQuality = font16->lfQuality;
144 font32->lfPitchAndFamily = font16->lfPitchAndFamily;
145 lstrcpynA( font32->lfFaceName, font16->lfFaceName, LF_FACESIZE );
148 void FONT_LogFont16ToW( const LOGFONT16 *font16, LPLOGFONTW font32 )
150 font32->lfHeight = font16->lfHeight;
151 font32->lfWidth = font16->lfWidth;
152 font32->lfEscapement = font16->lfEscapement;
153 font32->lfOrientation = font16->lfOrientation;
154 font32->lfWeight = font16->lfWeight;
155 font32->lfItalic = font16->lfItalic;
156 font32->lfUnderline = font16->lfUnderline;
157 font32->lfStrikeOut = font16->lfStrikeOut;
158 font32->lfCharSet = font16->lfCharSet;
159 font32->lfOutPrecision = font16->lfOutPrecision;
160 font32->lfClipPrecision = font16->lfClipPrecision;
161 font32->lfQuality = font16->lfQuality;
162 font32->lfPitchAndFamily = font16->lfPitchAndFamily;
163 MultiByteToWideChar( CP_ACP, 0, font16->lfFaceName, -1, font32->lfFaceName, LF_FACESIZE );
164 font32->lfFaceName[LF_FACESIZE-1] = 0;
167 void FONT_LogFontAToW( const LOGFONTA *fontA, LPLOGFONTW fontW )
169 memcpy(fontW, fontA, sizeof(LOGFONTA) - LF_FACESIZE);
170 MultiByteToWideChar(CP_ACP, 0, fontA->lfFaceName, -1, fontW->lfFaceName,
171 LF_FACESIZE);
174 void FONT_LogFontWToA( const LOGFONTW *fontW, LPLOGFONTA fontA )
176 memcpy(fontA, fontW, sizeof(LOGFONTA) - LF_FACESIZE);
177 WideCharToMultiByte(CP_ACP, 0, fontW->lfFaceName, -1, fontA->lfFaceName,
178 LF_FACESIZE, NULL, NULL);
181 void FONT_EnumLogFontEx16ToA( const ENUMLOGFONTEX16 *font16, LPENUMLOGFONTEXA font32 )
183 FONT_LogFont16ToA( (LPLOGFONT16)font16, (LPLOGFONTA)font32);
184 lstrcpynA( font32->elfFullName, font16->elfFullName, LF_FULLFACESIZE );
185 lstrcpynA( font32->elfStyle, font16->elfStyle, LF_FACESIZE );
186 lstrcpynA( font32->elfScript, font16->elfScript, LF_FACESIZE );
189 void FONT_EnumLogFontEx16ToW( const ENUMLOGFONTEX16 *font16, LPENUMLOGFONTEXW font32 )
191 FONT_LogFont16ToW( (LPLOGFONT16)font16, (LPLOGFONTW)font32);
193 MultiByteToWideChar( CP_ACP, 0, font16->elfFullName, -1, font32->elfFullName, LF_FULLFACESIZE );
194 font32->elfFullName[LF_FULLFACESIZE-1] = 0;
195 MultiByteToWideChar( CP_ACP, 0, font16->elfStyle, -1, font32->elfStyle, LF_FACESIZE );
196 font32->elfStyle[LF_FACESIZE-1] = 0;
197 MultiByteToWideChar( CP_ACP, 0, font16->elfScript, -1, font32->elfScript, LF_FACESIZE );
198 font32->elfScript[LF_FACESIZE-1] = 0;
201 void FONT_EnumLogFontExWTo16( const ENUMLOGFONTEXW *fontW, LPENUMLOGFONTEX16 font16 )
203 FONT_LogFontWTo16( (LPLOGFONTW)fontW, (LPLOGFONT16)font16);
205 WideCharToMultiByte( CP_ACP, 0, fontW->elfFullName, -1,
206 font16->elfFullName, LF_FULLFACESIZE, NULL, NULL );
207 font16->elfFullName[LF_FULLFACESIZE-1] = '\0';
208 WideCharToMultiByte( CP_ACP, 0, fontW->elfStyle, -1,
209 font16->elfStyle, LF_FACESIZE, NULL, NULL );
210 font16->elfStyle[LF_FACESIZE-1] = '\0';
211 WideCharToMultiByte( CP_ACP, 0, fontW->elfScript, -1,
212 font16->elfScript, LF_FACESIZE, NULL, NULL );
213 font16->elfScript[LF_FACESIZE-1] = '\0';
216 void FONT_EnumLogFontExWToA( const ENUMLOGFONTEXW *fontW, LPENUMLOGFONTEXA fontA )
218 FONT_LogFontWToA( (LPLOGFONTW)fontW, (LPLOGFONTA)fontA);
220 WideCharToMultiByte( CP_ACP, 0, fontW->elfFullName, -1,
221 fontA->elfFullName, LF_FULLFACESIZE, NULL, NULL );
222 fontA->elfFullName[LF_FULLFACESIZE-1] = '\0';
223 WideCharToMultiByte( CP_ACP, 0, fontW->elfStyle, -1,
224 fontA->elfStyle, LF_FACESIZE, NULL, NULL );
225 fontA->elfStyle[LF_FACESIZE-1] = '\0';
226 WideCharToMultiByte( CP_ACP, 0, fontW->elfScript, -1,
227 fontA->elfScript, LF_FACESIZE, NULL, NULL );
228 fontA->elfScript[LF_FACESIZE-1] = '\0';
231 /***********************************************************************
232 * TEXTMETRIC conversion functions.
234 void FONT_TextMetricATo16(const TEXTMETRICA *ptm32, LPTEXTMETRIC16 ptm16 )
236 ptm16->tmHeight = ptm32->tmHeight;
237 ptm16->tmAscent = ptm32->tmAscent;
238 ptm16->tmDescent = ptm32->tmDescent;
239 ptm16->tmInternalLeading = ptm32->tmInternalLeading;
240 ptm16->tmExternalLeading = ptm32->tmExternalLeading;
241 ptm16->tmAveCharWidth = ptm32->tmAveCharWidth;
242 ptm16->tmMaxCharWidth = ptm32->tmMaxCharWidth;
243 ptm16->tmWeight = ptm32->tmWeight;
244 ptm16->tmOverhang = ptm32->tmOverhang;
245 ptm16->tmDigitizedAspectX = ptm32->tmDigitizedAspectX;
246 ptm16->tmDigitizedAspectY = ptm32->tmDigitizedAspectY;
247 ptm16->tmFirstChar = ptm32->tmFirstChar;
248 ptm16->tmLastChar = ptm32->tmLastChar;
249 ptm16->tmDefaultChar = ptm32->tmDefaultChar;
250 ptm16->tmBreakChar = ptm32->tmBreakChar;
251 ptm16->tmItalic = ptm32->tmItalic;
252 ptm16->tmUnderlined = ptm32->tmUnderlined;
253 ptm16->tmStruckOut = ptm32->tmStruckOut;
254 ptm16->tmPitchAndFamily = ptm32->tmPitchAndFamily;
255 ptm16->tmCharSet = ptm32->tmCharSet;
258 void FONT_TextMetricWTo16(const TEXTMETRICW *ptm32, LPTEXTMETRIC16 ptm16 )
260 ptm16->tmHeight = ptm32->tmHeight;
261 ptm16->tmAscent = ptm32->tmAscent;
262 ptm16->tmDescent = ptm32->tmDescent;
263 ptm16->tmInternalLeading = ptm32->tmInternalLeading;
264 ptm16->tmExternalLeading = ptm32->tmExternalLeading;
265 ptm16->tmAveCharWidth = ptm32->tmAveCharWidth;
266 ptm16->tmMaxCharWidth = ptm32->tmMaxCharWidth;
267 ptm16->tmWeight = ptm32->tmWeight;
268 ptm16->tmOverhang = ptm32->tmOverhang;
269 ptm16->tmDigitizedAspectX = ptm32->tmDigitizedAspectX;
270 ptm16->tmDigitizedAspectY = ptm32->tmDigitizedAspectY;
271 ptm16->tmFirstChar = ptm32->tmFirstChar;
272 ptm16->tmLastChar = ptm32->tmLastChar;
273 ptm16->tmDefaultChar = ptm32->tmDefaultChar;
274 ptm16->tmBreakChar = ptm32->tmBreakChar;
275 ptm16->tmItalic = ptm32->tmItalic;
276 ptm16->tmUnderlined = ptm32->tmUnderlined;
277 ptm16->tmStruckOut = ptm32->tmStruckOut;
278 ptm16->tmPitchAndFamily = ptm32->tmPitchAndFamily;
279 ptm16->tmCharSet = ptm32->tmCharSet;
282 void FONT_TextMetric16ToA(const TEXTMETRIC16 *ptm16, LPTEXTMETRICA ptm32 )
284 ptm32->tmHeight = ptm16->tmHeight;
285 ptm32->tmAscent = ptm16->tmAscent;
286 ptm32->tmDescent = ptm16->tmDescent;
287 ptm32->tmInternalLeading = ptm16->tmInternalLeading;
288 ptm32->tmExternalLeading = ptm16->tmExternalLeading;
289 ptm32->tmAveCharWidth = ptm16->tmAveCharWidth;
290 ptm32->tmMaxCharWidth = ptm16->tmMaxCharWidth;
291 ptm32->tmWeight = ptm16->tmWeight;
292 ptm32->tmOverhang = ptm16->tmOverhang;
293 ptm32->tmDigitizedAspectX = ptm16->tmDigitizedAspectX;
294 ptm32->tmDigitizedAspectY = ptm16->tmDigitizedAspectY;
295 ptm32->tmFirstChar = ptm16->tmFirstChar;
296 ptm32->tmLastChar = ptm16->tmLastChar;
297 ptm32->tmDefaultChar = ptm16->tmDefaultChar;
298 ptm32->tmBreakChar = ptm16->tmBreakChar;
299 ptm32->tmItalic = ptm16->tmItalic;
300 ptm32->tmUnderlined = ptm16->tmUnderlined;
301 ptm32->tmStruckOut = ptm16->tmStruckOut;
302 ptm32->tmPitchAndFamily = ptm16->tmPitchAndFamily;
303 ptm32->tmCharSet = ptm16->tmCharSet;
306 void FONT_TextMetric16ToW(const TEXTMETRIC16 *ptm16, LPTEXTMETRICW ptm32 )
308 ptm32->tmHeight = ptm16->tmHeight;
309 ptm32->tmAscent = ptm16->tmAscent;
310 ptm32->tmDescent = ptm16->tmDescent;
311 ptm32->tmInternalLeading = ptm16->tmInternalLeading;
312 ptm32->tmExternalLeading = ptm16->tmExternalLeading;
313 ptm32->tmAveCharWidth = ptm16->tmAveCharWidth;
314 ptm32->tmMaxCharWidth = ptm16->tmMaxCharWidth;
315 ptm32->tmWeight = ptm16->tmWeight;
316 ptm32->tmOverhang = ptm16->tmOverhang;
317 ptm32->tmDigitizedAspectX = ptm16->tmDigitizedAspectX;
318 ptm32->tmDigitizedAspectY = ptm16->tmDigitizedAspectY;
319 ptm32->tmFirstChar = ptm16->tmFirstChar;
320 ptm32->tmLastChar = ptm16->tmLastChar;
321 ptm32->tmDefaultChar = ptm16->tmDefaultChar;
322 ptm32->tmBreakChar = ptm16->tmBreakChar;
323 ptm32->tmItalic = ptm16->tmItalic;
324 ptm32->tmUnderlined = ptm16->tmUnderlined;
325 ptm32->tmStruckOut = ptm16->tmStruckOut;
326 ptm32->tmPitchAndFamily = ptm16->tmPitchAndFamily;
327 ptm32->tmCharSet = ptm16->tmCharSet;
330 void FONT_TextMetricAToW(const TEXTMETRICA *ptm32A, LPTEXTMETRICW ptm32W )
332 ptm32W->tmHeight = ptm32A->tmHeight;
333 ptm32W->tmAscent = ptm32A->tmAscent;
334 ptm32W->tmDescent = ptm32A->tmDescent;
335 ptm32W->tmInternalLeading = ptm32A->tmInternalLeading;
336 ptm32W->tmExternalLeading = ptm32A->tmExternalLeading;
337 ptm32W->tmAveCharWidth = ptm32A->tmAveCharWidth;
338 ptm32W->tmMaxCharWidth = ptm32A->tmMaxCharWidth;
339 ptm32W->tmWeight = ptm32A->tmWeight;
340 ptm32W->tmOverhang = ptm32A->tmOverhang;
341 ptm32W->tmDigitizedAspectX = ptm32A->tmDigitizedAspectX;
342 ptm32W->tmDigitizedAspectY = ptm32A->tmDigitizedAspectY;
343 ptm32W->tmFirstChar = ptm32A->tmFirstChar;
344 ptm32W->tmLastChar = ptm32A->tmLastChar;
345 ptm32W->tmDefaultChar = ptm32A->tmDefaultChar;
346 ptm32W->tmBreakChar = ptm32A->tmBreakChar;
347 ptm32W->tmItalic = ptm32A->tmItalic;
348 ptm32W->tmUnderlined = ptm32A->tmUnderlined;
349 ptm32W->tmStruckOut = ptm32A->tmStruckOut;
350 ptm32W->tmPitchAndFamily = ptm32A->tmPitchAndFamily;
351 ptm32W->tmCharSet = ptm32A->tmCharSet;
354 void FONT_TextMetricWToA(const TEXTMETRICW *ptmW, LPTEXTMETRICA ptmA )
356 ptmA->tmHeight = ptmW->tmHeight;
357 ptmA->tmAscent = ptmW->tmAscent;
358 ptmA->tmDescent = ptmW->tmDescent;
359 ptmA->tmInternalLeading = ptmW->tmInternalLeading;
360 ptmA->tmExternalLeading = ptmW->tmExternalLeading;
361 ptmA->tmAveCharWidth = ptmW->tmAveCharWidth;
362 ptmA->tmMaxCharWidth = ptmW->tmMaxCharWidth;
363 ptmA->tmWeight = ptmW->tmWeight;
364 ptmA->tmOverhang = ptmW->tmOverhang;
365 ptmA->tmDigitizedAspectX = ptmW->tmDigitizedAspectX;
366 ptmA->tmDigitizedAspectY = ptmW->tmDigitizedAspectY;
367 ptmA->tmFirstChar = ptmW->tmFirstChar;
368 ptmA->tmLastChar = ptmW->tmLastChar;
369 ptmA->tmDefaultChar = ptmW->tmDefaultChar;
370 ptmA->tmBreakChar = ptmW->tmBreakChar;
371 ptmA->tmItalic = ptmW->tmItalic;
372 ptmA->tmUnderlined = ptmW->tmUnderlined;
373 ptmA->tmStruckOut = ptmW->tmStruckOut;
374 ptmA->tmPitchAndFamily = ptmW->tmPitchAndFamily;
375 ptmA->tmCharSet = ptmW->tmCharSet;
379 void FONT_NewTextMetricExWTo16(const NEWTEXTMETRICEXW *ptmW, LPNEWTEXTMETRICEX16 ptm16 )
381 FONT_TextMetricWTo16((LPTEXTMETRICW)ptmW, (LPTEXTMETRIC16)ptm16);
382 ptm16->ntmTm.ntmFlags = ptmW->ntmTm.ntmFlags;
383 ptm16->ntmTm.ntmSizeEM = ptmW->ntmTm.ntmSizeEM;
384 ptm16->ntmTm.ntmCellHeight = ptmW->ntmTm.ntmCellHeight;
385 ptm16->ntmTm.ntmAvgWidth = ptmW->ntmTm.ntmAvgWidth;
386 memcpy(&ptm16->ntmFontSig, &ptmW->ntmFontSig, sizeof(FONTSIGNATURE));
389 void FONT_NewTextMetricExWToA(const NEWTEXTMETRICEXW *ptmW, LPNEWTEXTMETRICEXA ptmA )
391 FONT_TextMetricWToA((LPTEXTMETRICW)ptmW, (LPTEXTMETRICA)ptmA);
392 ptmA->ntmTm.ntmFlags = ptmW->ntmTm.ntmFlags;
393 ptmA->ntmTm.ntmSizeEM = ptmW->ntmTm.ntmSizeEM;
394 ptmA->ntmTm.ntmCellHeight = ptmW->ntmTm.ntmCellHeight;
395 ptmA->ntmTm.ntmAvgWidth = ptmW->ntmTm.ntmAvgWidth;
396 memcpy(&ptmA->ntmFontSig, &ptmW->ntmFontSig, sizeof(FONTSIGNATURE));
399 void FONT_NewTextMetricEx16ToW(const NEWTEXTMETRICEX16 *ptm16, LPNEWTEXTMETRICEXW ptmW )
401 FONT_TextMetric16ToW((LPTEXTMETRIC16)ptm16, (LPTEXTMETRICW)ptmW);
402 ptmW->ntmTm.ntmFlags = ptm16->ntmTm.ntmFlags;
403 ptmW->ntmTm.ntmSizeEM = ptm16->ntmTm.ntmSizeEM;
404 ptmW->ntmTm.ntmCellHeight = ptm16->ntmTm.ntmCellHeight;
405 ptmW->ntmTm.ntmAvgWidth = ptm16->ntmTm.ntmAvgWidth;
406 memcpy(&ptmW->ntmFontSig, &ptm16->ntmFontSig, sizeof(FONTSIGNATURE));
410 /***********************************************************************
411 * CreateFontIndirect (GDI.57)
413 HFONT16 WINAPI CreateFontIndirect16( const LOGFONT16 *plf16 )
415 LOGFONTW lfW;
417 if(plf16) {
418 FONT_LogFont16ToW( plf16, &lfW );
419 return CreateFontIndirectW( &lfW );
420 } else {
421 return CreateFontIndirectW( NULL );
426 /***********************************************************************
427 * CreateFontIndirectA (GDI32.@)
429 HFONT WINAPI CreateFontIndirectA( const LOGFONTA *plfA )
431 LOGFONTW lfW;
433 if (plfA) {
434 FONT_LogFontAToW( plfA, &lfW );
435 return CreateFontIndirectW( &lfW );
436 } else
437 return CreateFontIndirectW( NULL );
441 /***********************************************************************
442 * CreateFontIndirectW (GDI32.@)
444 HFONT WINAPI CreateFontIndirectW( const LOGFONTW *plf )
446 HFONT hFont = 0;
448 if (plf)
450 FONTOBJ* fontPtr;
451 if ((fontPtr = GDI_AllocObject( sizeof(FONTOBJ), FONT_MAGIC, &hFont )))
453 memcpy( &fontPtr->logfont, plf, sizeof(LOGFONTW) );
455 TRACE("(%ld %ld %ld %ld) %s %s %s => %04x\n",
456 plf->lfHeight, plf->lfWidth,
457 plf->lfEscapement, plf->lfOrientation,
458 debugstr_w(plf->lfFaceName),
459 plf->lfWeight > 400 ? "Bold" : "",
460 plf->lfItalic ? "Italic" : "", hFont);
462 if (plf->lfEscapement != plf->lfOrientation) {
463 /* this should really depend on whether GM_ADVANCED is set */
464 fontPtr->logfont.lfOrientation = fontPtr->logfont.lfEscapement;
465 WARN("orientation angle %f set to "
466 "escapement angle %f for new font %04x\n",
467 plf->lfOrientation/10., plf->lfEscapement/10., hFont);
469 GDI_ReleaseObj( hFont );
472 else WARN("(NULL) => NULL\n");
474 return hFont;
477 /***********************************************************************
478 * CreateFont (GDI.56)
480 HFONT16 WINAPI CreateFont16(INT16 height, INT16 width, INT16 esc, INT16 orient,
481 INT16 weight, BYTE italic, BYTE underline,
482 BYTE strikeout, BYTE charset, BYTE outpres,
483 BYTE clippres, BYTE quality, BYTE pitch,
484 LPCSTR name )
486 LOGFONT16 logfont;
488 logfont.lfHeight = height;
489 logfont.lfWidth = width;
490 logfont.lfEscapement = esc;
491 logfont.lfOrientation = orient;
492 logfont.lfWeight = weight;
493 logfont.lfItalic = italic;
494 logfont.lfUnderline = underline;
495 logfont.lfStrikeOut = strikeout;
496 logfont.lfCharSet = charset;
497 logfont.lfOutPrecision = outpres;
498 logfont.lfClipPrecision = clippres;
499 logfont.lfQuality = quality;
500 logfont.lfPitchAndFamily = pitch;
502 if (name)
503 lstrcpynA(logfont.lfFaceName,name,sizeof(logfont.lfFaceName));
504 else
505 logfont.lfFaceName[0] = '\0';
507 return CreateFontIndirect16( &logfont );
510 /*************************************************************************
511 * CreateFontA (GDI32.@)
513 HFONT WINAPI CreateFontA( INT height, INT width, INT esc,
514 INT orient, INT weight, DWORD italic,
515 DWORD underline, DWORD strikeout, DWORD charset,
516 DWORD outpres, DWORD clippres, DWORD quality,
517 DWORD pitch, LPCSTR name )
519 LOGFONTA logfont;
521 logfont.lfHeight = height;
522 logfont.lfWidth = width;
523 logfont.lfEscapement = esc;
524 logfont.lfOrientation = orient;
525 logfont.lfWeight = weight;
526 logfont.lfItalic = italic;
527 logfont.lfUnderline = underline;
528 logfont.lfStrikeOut = strikeout;
529 logfont.lfCharSet = charset;
530 logfont.lfOutPrecision = outpres;
531 logfont.lfClipPrecision = clippres;
532 logfont.lfQuality = quality;
533 logfont.lfPitchAndFamily = pitch;
535 if (name)
536 lstrcpynA(logfont.lfFaceName,name,sizeof(logfont.lfFaceName));
537 else
538 logfont.lfFaceName[0] = '\0';
540 return CreateFontIndirectA( &logfont );
543 /*************************************************************************
544 * CreateFontW (GDI32.@)
546 HFONT WINAPI CreateFontW( INT height, INT width, INT esc,
547 INT orient, INT weight, DWORD italic,
548 DWORD underline, DWORD strikeout, DWORD charset,
549 DWORD outpres, DWORD clippres, DWORD quality,
550 DWORD pitch, LPCWSTR name )
552 LOGFONTW logfont;
554 logfont.lfHeight = height;
555 logfont.lfWidth = width;
556 logfont.lfEscapement = esc;
557 logfont.lfOrientation = orient;
558 logfont.lfWeight = weight;
559 logfont.lfItalic = italic;
560 logfont.lfUnderline = underline;
561 logfont.lfStrikeOut = strikeout;
562 logfont.lfCharSet = charset;
563 logfont.lfOutPrecision = outpres;
564 logfont.lfClipPrecision = clippres;
565 logfont.lfQuality = quality;
566 logfont.lfPitchAndFamily = pitch;
568 if (name)
569 lstrcpynW(logfont.lfFaceName, name,
570 sizeof(logfont.lfFaceName) / sizeof(WCHAR));
571 else
572 logfont.lfFaceName[0] = '\0';
574 return CreateFontIndirectW( &logfont );
578 /***********************************************************************
579 * FONT_GetObject16
581 INT16 FONT_GetObject16( FONTOBJ * font, INT16 count, LPSTR buffer )
583 LOGFONT16 lf16;
585 FONT_LogFontWTo16( &font->logfont, &lf16 );
587 if (count > sizeof(LOGFONT16)) count = sizeof(LOGFONT16);
588 memcpy( buffer, &lf16, count );
589 return count;
592 /***********************************************************************
593 * FONT_GetObjectA
595 INT FONT_GetObjectA( FONTOBJ *font, INT count, LPSTR buffer )
597 LOGFONTA lfA;
599 FONT_LogFontWToA( &font->logfont, &lfA );
601 if (count > sizeof(lfA)) count = sizeof(lfA);
602 memcpy( buffer, &lfA, count );
603 return count;
605 /***********************************************************************
606 * FONT_GetObjectW
608 INT FONT_GetObjectW( FONTOBJ *font, INT count, LPSTR buffer )
610 if (count > sizeof(LOGFONTW)) count = sizeof(LOGFONTW);
611 memcpy( buffer, &font->logfont, count );
612 return count;
616 /***********************************************************************
617 * FONT_EnumInstance16
619 * Called by the device driver layer to pass font info
620 * down to the application.
622 static INT FONT_EnumInstance16( LPENUMLOGFONTEXW plf, LPNEWTEXTMETRICEXW ptm,
623 DWORD fType, LPARAM lp )
625 #define pfe ((fontEnum16*)lp)
626 if( pfe->lpLogFontParam->lfCharSet == DEFAULT_CHARSET ||
627 pfe->lpLogFontParam->lfCharSet == plf->elfLogFont.lfCharSet )
629 FONT_EnumLogFontExWTo16(plf, pfe->lpLogFont);
630 FONT_NewTextMetricExWTo16(ptm, pfe->lpTextMetric);
631 return pfe->lpEnumFunc( pfe->segLogFont, pfe->segTextMetric,
632 (UINT16)fType, (LPARAM)(pfe->lpData) );
634 #undef pfe
635 return 1;
638 /***********************************************************************
639 * FONT_EnumInstance
641 static INT FONT_EnumInstance( LPENUMLOGFONTEXW plf, LPNEWTEXTMETRICEXW ptm,
642 DWORD fType, LPARAM lp )
644 /* lfCharSet is at the same offset in both LOGFONTA and LOGFONTW */
646 #define pfe ((fontEnum32*)lp)
647 if( pfe->lpLogFontParam->lfCharSet == DEFAULT_CHARSET ||
648 pfe->lpLogFontParam->lfCharSet == plf->elfLogFont.lfCharSet )
650 /* convert font metrics */
652 if( pfe->dwFlags & ENUM_UNICODE )
654 return pfe->lpEnumFunc( plf, ptm, fType, pfe->lpData );
656 else
658 ENUMLOGFONTEXA logfont;
659 NEWTEXTMETRICEXA tmA;
661 FONT_EnumLogFontExWToA( plf, &logfont);
662 FONT_NewTextMetricExWToA( ptm, &tmA );
664 return pfe->lpEnumFunc( (LPENUMLOGFONTEXW)&logfont,
665 (LPNEWTEXTMETRICEXW)&tmA, fType,
666 pfe->lpData );
669 #undef pfe
670 return 1;
673 /***********************************************************************
674 * EnumFontFamiliesEx16 (GDI.613)
676 INT16 WINAPI EnumFontFamiliesEx16( HDC16 hDC, LPLOGFONT16 plf,
677 FONTENUMPROCEX16 efproc, LPARAM lParam,
678 DWORD dwFlags)
680 BOOL (*enum_func)(HDC,LPLOGFONTW,DEVICEFONTENUMPROC,LPARAM);
681 INT16 retVal = 0;
682 DC* dc = DC_GetDCPtr( hDC );
684 if (!dc) return 0;
685 enum_func = dc->funcs->pEnumDeviceFonts;
686 GDI_ReleaseObj( hDC );
688 if (enum_func)
690 LPNEWTEXTMETRICEX16 lptm16 = SEGPTR_ALLOC( sizeof(NEWTEXTMETRICEX16) );
691 if( lptm16 )
693 LPENUMLOGFONTEX16 lplf16 = SEGPTR_ALLOC( sizeof(ENUMLOGFONTEX16) );
694 if( lplf16 )
696 fontEnum16 fe16;
697 LOGFONTW lfW;
698 FONT_LogFont16ToW(plf, &lfW);
700 fe16.lpLogFontParam = plf;
701 fe16.lpEnumFunc = efproc;
702 fe16.lpData = lParam;
704 fe16.lpTextMetric = lptm16;
705 fe16.lpLogFont = lplf16;
706 fe16.segTextMetric = SEGPTR_GET(lptm16);
707 fe16.segLogFont = SEGPTR_GET(lplf16);
709 retVal = enum_func( hDC, &lfW, FONT_EnumInstance16,
710 (LPARAM)&fe16 );
711 SEGPTR_FREE(lplf16);
713 SEGPTR_FREE(lptm16);
716 return retVal;
719 /***********************************************************************
720 * FONT_EnumFontFamiliesEx
722 static INT FONT_EnumFontFamiliesEx( HDC hDC, LPLOGFONTW plf,
723 FONTENUMPROCEXW efproc,
724 LPARAM lParam, DWORD dwUnicode)
726 BOOL (*enum_func)(HDC,LPLOGFONTW,DEVICEFONTENUMPROC,LPARAM);
727 INT ret = 0;
728 DC *dc = DC_GetDCPtr( hDC );
730 if (!dc) return 0;
731 enum_func = dc->funcs->pEnumDeviceFonts;
732 GDI_ReleaseObj( hDC );
734 if (enum_func)
736 fontEnum32 fe32;
738 fe32.lpLogFontParam = plf;
739 fe32.lpEnumFunc = efproc;
740 fe32.lpData = lParam;
742 fe32.dwFlags = dwUnicode;
744 ret = enum_func( hDC, plf, FONT_EnumInstance, (LPARAM)&fe32 );
746 return ret;
749 /***********************************************************************
750 * EnumFontFamiliesExW (GDI32.@)
752 INT WINAPI EnumFontFamiliesExW( HDC hDC, LPLOGFONTW plf,
753 FONTENUMPROCEXW efproc,
754 LPARAM lParam, DWORD dwFlags )
756 return FONT_EnumFontFamiliesEx( hDC, plf, efproc, lParam, ENUM_UNICODE );
759 /***********************************************************************
760 * EnumFontFamiliesExA (GDI32.@)
762 INT WINAPI EnumFontFamiliesExA( HDC hDC, LPLOGFONTA plf,
763 FONTENUMPROCEXA efproc,
764 LPARAM lParam, DWORD dwFlags)
766 LOGFONTW lfW;
767 FONT_LogFontAToW( plf, &lfW );
769 return FONT_EnumFontFamiliesEx( hDC, &lfW,
770 (FONTENUMPROCEXW)efproc, lParam, 0);
773 /***********************************************************************
774 * EnumFontFamilies16 (GDI.330)
776 INT16 WINAPI EnumFontFamilies16( HDC16 hDC, LPCSTR lpFamily,
777 FONTENUMPROC16 efproc, LPARAM lpData )
779 LOGFONT16 lf;
781 lf.lfCharSet = DEFAULT_CHARSET;
782 if( lpFamily ) lstrcpynA( lf.lfFaceName, lpFamily, LF_FACESIZE );
783 else lf.lfFaceName[0] = '\0';
785 return EnumFontFamiliesEx16( hDC, &lf, (FONTENUMPROCEX16)efproc, lpData, 0 );
788 /***********************************************************************
789 * EnumFontFamiliesA (GDI32.@)
791 INT WINAPI EnumFontFamiliesA( HDC hDC, LPCSTR lpFamily,
792 FONTENUMPROCA efproc, LPARAM lpData )
794 LOGFONTA lf;
796 lf.lfCharSet = DEFAULT_CHARSET;
797 if( lpFamily ) lstrcpynA( lf.lfFaceName, lpFamily, LF_FACESIZE );
798 else lf.lfFaceName[0] = lf.lfFaceName[1] = '\0';
800 return EnumFontFamiliesExA( hDC, &lf, (FONTENUMPROCEXA)efproc, lpData, 0 );
803 /***********************************************************************
804 * EnumFontFamiliesW (GDI32.@)
806 INT WINAPI EnumFontFamiliesW( HDC hDC, LPCWSTR lpFamily,
807 FONTENUMPROCW efproc, LPARAM lpData )
809 LOGFONTW lf;
811 lf.lfCharSet = DEFAULT_CHARSET;
812 if( lpFamily ) lstrcpynW( lf.lfFaceName, lpFamily, LF_FACESIZE );
813 else lf.lfFaceName[0] = 0;
815 return EnumFontFamiliesExW( hDC, &lf, (FONTENUMPROCEXW)efproc, lpData, 0 );
818 /***********************************************************************
819 * EnumFonts16 (GDI.70)
821 INT16 WINAPI EnumFonts16( HDC16 hDC, LPCSTR lpName, FONTENUMPROC16 efproc,
822 LPARAM lpData )
824 return EnumFontFamilies16( hDC, lpName, (FONTENUMPROCEX16)efproc, lpData );
827 /***********************************************************************
828 * EnumFontsA (GDI32.@)
830 INT WINAPI EnumFontsA( HDC hDC, LPCSTR lpName, FONTENUMPROCA efproc,
831 LPARAM lpData )
833 return EnumFontFamiliesA( hDC, lpName, efproc, lpData );
836 /***********************************************************************
837 * EnumFontsW (GDI32.@)
839 INT WINAPI EnumFontsW( HDC hDC, LPCWSTR lpName, FONTENUMPROCW efproc,
840 LPARAM lpData )
842 return EnumFontFamiliesW( hDC, lpName, efproc, lpData );
846 /***********************************************************************
847 * GetTextCharacterExtra (GDI.89)
849 INT16 WINAPI GetTextCharacterExtra16( HDC16 hdc )
851 return (INT16)GetTextCharacterExtra( hdc );
855 /***********************************************************************
856 * GetTextCharacterExtra (GDI32.@)
858 INT WINAPI GetTextCharacterExtra( HDC hdc )
860 INT ret;
861 DC *dc = DC_GetDCPtr( hdc );
862 if (!dc) return 0;
863 ret = abs( (dc->charExtra * dc->wndExtX + dc->vportExtX / 2)
864 / dc->vportExtX );
865 GDI_ReleaseObj( hdc );
866 return ret;
870 /***********************************************************************
871 * SetTextCharacterExtra (GDI.8)
873 INT16 WINAPI SetTextCharacterExtra16( HDC16 hdc, INT16 extra )
875 return (INT16)SetTextCharacterExtra( hdc, extra );
879 /***********************************************************************
880 * SetTextCharacterExtra (GDI32.@)
882 INT WINAPI SetTextCharacterExtra( HDC hdc, INT extra )
884 INT prev;
885 DC * dc = DC_GetDCPtr( hdc );
886 if (!dc) return 0;
887 if (dc->funcs->pSetTextCharacterExtra)
888 prev = dc->funcs->pSetTextCharacterExtra( dc, extra );
889 else
891 extra = (extra * dc->vportExtX + dc->wndExtX / 2) / dc->wndExtX;
892 prev = (dc->charExtra * dc->wndExtX + dc->vportExtX / 2) / dc->vportExtX;
893 dc->charExtra = abs(extra);
895 GDI_ReleaseObj( hdc );
896 return prev;
900 /***********************************************************************
901 * SetTextJustification (GDI.10)
903 INT16 WINAPI SetTextJustification16( HDC16 hdc, INT16 extra, INT16 breaks )
905 return SetTextJustification( hdc, extra, breaks );
909 /***********************************************************************
910 * SetTextJustification (GDI32.@)
912 BOOL WINAPI SetTextJustification( HDC hdc, INT extra, INT breaks )
914 BOOL ret = TRUE;
915 DC * dc = DC_GetDCPtr( hdc );
916 if (!dc) return FALSE;
917 if (dc->funcs->pSetTextJustification)
918 ret = dc->funcs->pSetTextJustification( dc, extra, breaks );
919 else
921 extra = abs((extra * dc->vportExtX + dc->wndExtX / 2) / dc->wndExtX);
922 if (!extra) breaks = 0;
923 dc->breakTotalExtra = extra;
924 dc->breakCount = breaks;
925 if (breaks)
927 dc->breakExtra = extra / breaks;
928 dc->breakRem = extra - (dc->breakCount * dc->breakExtra);
930 else
932 dc->breakExtra = 0;
933 dc->breakRem = 0;
936 GDI_ReleaseObj( hdc );
937 return ret;
941 /***********************************************************************
942 * GetTextFace (GDI.92)
944 INT16 WINAPI GetTextFace16( HDC16 hdc, INT16 count, LPSTR name )
946 return GetTextFaceA(hdc,count,name);
949 /***********************************************************************
950 * GetTextFaceA (GDI32.@)
952 INT WINAPI GetTextFaceA( HDC hdc, INT count, LPSTR name )
954 INT res = GetTextFaceW(hdc, 0, NULL);
955 LPWSTR nameW = HeapAlloc( GetProcessHeap(), 0, res * 2 );
956 GetTextFaceW( hdc, res, nameW );
958 if (name)
959 res = WideCharToMultiByte( CP_ACP, 0, nameW, -1, name, count,
960 NULL, NULL);
961 else
962 res = WideCharToMultiByte( CP_ACP, 0, nameW, -1, NULL, 0, NULL, NULL);
963 HeapFree( GetProcessHeap(), 0, nameW );
964 return res;
967 /***********************************************************************
968 * GetTextFaceW (GDI32.@)
970 INT WINAPI GetTextFaceW( HDC hdc, INT count, LPWSTR name )
972 FONTOBJ *font;
973 INT ret = 0;
975 DC * dc = DC_GetDCPtr( hdc );
976 if (!dc) return 0;
978 if ((font = (FONTOBJ *) GDI_GetObjPtr( dc->hFont, FONT_MAGIC )))
980 if (name)
982 lstrcpynW( name, font->logfont.lfFaceName, count );
983 ret = strlenW(name);
985 else ret = strlenW(font->logfont.lfFaceName) + 1;
986 GDI_ReleaseObj( dc->hFont );
988 GDI_ReleaseObj( hdc );
989 return ret;
993 /***********************************************************************
994 * GetTextExtent (GDI.91)
996 DWORD WINAPI GetTextExtent16( HDC16 hdc, LPCSTR str, INT16 count )
998 SIZE16 size;
999 if (!GetTextExtentPoint16( hdc, str, count, &size )) return 0;
1000 return MAKELONG( size.cx, size.cy );
1004 /***********************************************************************
1005 * GetTextExtentPoint (GDI.471)
1007 * FIXME: Should this have a bug for compatibility?
1008 * Original Windows versions of GetTextExtentPoint{A,W} have documented
1009 * bugs (-> MSDN KB q147647.txt).
1011 BOOL16 WINAPI GetTextExtentPoint16( HDC16 hdc, LPCSTR str, INT16 count,
1012 LPSIZE16 size )
1014 SIZE size32;
1015 BOOL ret;
1016 TRACE("%04x, %p (%s), %d, %p\n", hdc, str, debugstr_an(str, count), count, size);
1017 ret = GetTextExtentPoint32A( hdc, str, count, &size32 );
1018 size->cx = size32.cx;
1019 size->cy = size32.cy;
1020 return (BOOL16)ret;
1024 /***********************************************************************
1025 * GetTextExtentPoint32A (GDI32.@)
1027 BOOL WINAPI GetTextExtentPoint32A( HDC hdc, LPCSTR str, INT count,
1028 LPSIZE size )
1030 BOOL ret = FALSE;
1031 UINT codepage = CP_ACP; /* FIXME: get codepage of font charset */
1032 DC * dc = DC_GetDCPtr( hdc );
1034 if (!dc) return FALSE;
1036 if (dc->funcs->pGetTextExtentPoint)
1038 /* str may not be 0 terminated so we can't use HEAP_strdupWtoA.
1039 * So we use MultiByteToWideChar.
1041 UINT wlen = MultiByteToWideChar(codepage,0,str,count,NULL,0);
1042 LPWSTR p = HeapAlloc( GetProcessHeap(), 0, wlen * sizeof(WCHAR) );
1043 if (p)
1045 wlen = MultiByteToWideChar(codepage,0,str,count,p,wlen);
1046 ret = dc->funcs->pGetTextExtentPoint( dc, p, wlen, size );
1047 HeapFree( GetProcessHeap(), 0, p );
1050 GDI_ReleaseObj( hdc );
1051 TRACE("(%08x %s %d %p): returning %ld x %ld\n",
1052 hdc, debugstr_an (str, count), count, size, size->cx, size->cy );
1053 return ret;
1057 /***********************************************************************
1058 * GetTextExtentPoint32W [GDI32.@] Computes width/height for a string
1060 * Computes width and height of the specified string.
1062 * RETURNS
1063 * Success: TRUE
1064 * Failure: FALSE
1066 BOOL WINAPI GetTextExtentPoint32W(
1067 HDC hdc, /* [in] Handle of device context */
1068 LPCWSTR str, /* [in] Address of text string */
1069 INT count, /* [in] Number of characters in string */
1070 LPSIZE size) /* [out] Address of structure for string size */
1072 BOOL ret = FALSE;
1073 DC * dc = DC_GetDCPtr( hdc );
1074 if (dc)
1076 if(dc->funcs->pGetTextExtentPoint)
1077 ret = dc->funcs->pGetTextExtentPoint( dc, str, count, size );
1078 GDI_ReleaseObj( hdc );
1080 TRACE("(%08x %s %d %p): returning %ld x %ld\n",
1081 hdc, debugstr_wn (str, count), count, size, size->cx, size->cy );
1082 return ret;
1086 /***********************************************************************
1087 * GetTextExtentPointA (GDI32.@)
1089 BOOL WINAPI GetTextExtentPointA( HDC hdc, LPCSTR str, INT count,
1090 LPSIZE size )
1092 TRACE("not bug compatible.\n");
1093 return GetTextExtentPoint32A( hdc, str, count, size );
1096 /***********************************************************************
1097 * GetTextExtentPointW (GDI32.@)
1099 BOOL WINAPI GetTextExtentPointW( HDC hdc, LPCWSTR str, INT count,
1100 LPSIZE size )
1102 TRACE("not bug compatible.\n");
1103 return GetTextExtentPoint32W( hdc, str, count, size );
1107 /***********************************************************************
1108 * GetTextExtentExPointA (GDI32.@)
1110 BOOL WINAPI GetTextExtentExPointA( HDC hdc, LPCSTR str, INT count,
1111 INT maxExt, LPINT lpnFit,
1112 LPINT alpDx, LPSIZE size )
1114 BOOL ret;
1116 DWORD len = MultiByteToWideChar( CP_ACP, 0, str, count, NULL, 0 );
1117 LPWSTR p = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) );
1118 MultiByteToWideChar( CP_ACP, 0, str, count, p, len );
1119 ret = GetTextExtentExPointW( hdc, p, len, maxExt, lpnFit, alpDx, size);
1120 HeapFree( GetProcessHeap(), 0, p );
1121 return ret;
1125 /***********************************************************************
1126 * GetTextExtentExPointW (GDI32.@)
1129 BOOL WINAPI GetTextExtentExPointW( HDC hdc, LPCWSTR str, INT count,
1130 INT maxExt, LPINT lpnFit,
1131 LPINT alpDx, LPSIZE size )
1133 int index, nFit, extent;
1134 SIZE tSize;
1135 BOOL ret = FALSE;
1136 DC * dc = DC_GetDCPtr( hdc );
1137 if (!dc) return FALSE;
1139 if (!dc->funcs->pGetTextExtentPoint) goto done;
1141 size->cx = size->cy = nFit = extent = 0;
1142 for(index = 0; index < count; index++)
1144 if(!dc->funcs->pGetTextExtentPoint( dc, str, 1, &tSize )) goto done;
1145 if( extent+tSize.cx < maxExt )
1147 extent+=tSize.cx;
1148 nFit++;
1149 str++;
1150 if( alpDx ) alpDx[index] = extent;
1151 if( tSize.cy > size->cy ) size->cy = tSize.cy;
1153 else break;
1155 size->cx = extent;
1156 if(lpnFit) *lpnFit = nFit;
1157 ret = TRUE;
1159 TRACE("(%08x %s %d) returning %d %ld x %ld\n",
1160 hdc,debugstr_wn(str,count),maxExt,nFit, size->cx,size->cy);
1162 done:
1163 GDI_ReleaseObj( hdc );
1164 return ret;
1167 /***********************************************************************
1168 * GetTextMetrics (GDI.93)
1170 BOOL16 WINAPI GetTextMetrics16( HDC16 hdc, TEXTMETRIC16 *metrics )
1172 TEXTMETRICW tm32;
1174 if (!GetTextMetricsW( (HDC)hdc, &tm32 )) return FALSE;
1175 FONT_TextMetricWTo16( &tm32, metrics );
1176 return TRUE;
1180 /***********************************************************************
1181 * GetTextMetricsA (GDI32.@)
1183 BOOL WINAPI GetTextMetricsA( HDC hdc, TEXTMETRICA *metrics )
1185 TEXTMETRICW tm32;
1187 if (!GetTextMetricsW( hdc, &tm32 )) return FALSE;
1188 FONT_TextMetricWToA( &tm32, metrics );
1189 return TRUE;
1192 /***********************************************************************
1193 * GetTextMetricsW (GDI32.@)
1195 BOOL WINAPI GetTextMetricsW( HDC hdc, TEXTMETRICW *metrics )
1197 BOOL ret = FALSE;
1198 DC * dc = DC_GetDCPtr( hdc );
1199 if (!dc) return FALSE;
1201 if (dc->funcs->pGetTextMetrics && dc->funcs->pGetTextMetrics( dc, metrics ))
1203 /* device layer returns values in device units
1204 * therefore we have to convert them to logical */
1206 #define WDPTOLP(x) ((x<0)? \
1207 (-abs((x)*dc->wndExtX/dc->vportExtX)): \
1208 (abs((x)*dc->wndExtX/dc->vportExtX)))
1209 #define HDPTOLP(y) ((y<0)? \
1210 (-abs((y)*dc->wndExtY/dc->vportExtY)): \
1211 (abs((y)*dc->wndExtY/dc->vportExtY)))
1213 metrics->tmHeight = HDPTOLP(metrics->tmHeight);
1214 metrics->tmAscent = HDPTOLP(metrics->tmAscent);
1215 metrics->tmDescent = HDPTOLP(metrics->tmDescent);
1216 metrics->tmInternalLeading = HDPTOLP(metrics->tmInternalLeading);
1217 metrics->tmExternalLeading = HDPTOLP(metrics->tmExternalLeading);
1218 metrics->tmAveCharWidth = WDPTOLP(metrics->tmAveCharWidth);
1219 metrics->tmMaxCharWidth = WDPTOLP(metrics->tmMaxCharWidth);
1220 metrics->tmOverhang = WDPTOLP(metrics->tmOverhang);
1221 ret = TRUE;
1223 TRACE("text metrics:\n"
1224 " Weight = %03li\t FirstChar = %i\t AveCharWidth = %li\n"
1225 " Italic = % 3i\t LastChar = %i\t\t MaxCharWidth = %li\n"
1226 " UnderLined = %01i\t DefaultChar = %i\t Overhang = %li\n"
1227 " StruckOut = %01i\t BreakChar = %i\t CharSet = %i\n"
1228 " PitchAndFamily = %02x\n"
1229 " --------------------\n"
1230 " InternalLeading = %li\n"
1231 " Ascent = %li\n"
1232 " Descent = %li\n"
1233 " Height = %li\n",
1234 metrics->tmWeight, metrics->tmFirstChar, metrics->tmAveCharWidth,
1235 metrics->tmItalic, metrics->tmLastChar, metrics->tmMaxCharWidth,
1236 metrics->tmUnderlined, metrics->tmDefaultChar, metrics->tmOverhang,
1237 metrics->tmStruckOut, metrics->tmBreakChar, metrics->tmCharSet,
1238 metrics->tmPitchAndFamily,
1239 metrics->tmInternalLeading,
1240 metrics->tmAscent,
1241 metrics->tmDescent,
1242 metrics->tmHeight );
1244 GDI_ReleaseObj( hdc );
1245 return ret;
1249 /***********************************************************************
1250 * GetOutlineTextMetrics [GDI.308] Gets metrics for TrueType fonts.
1252 * NOTES
1253 * lpOTM should be LPOUTLINETEXTMETRIC
1255 * RETURNS
1256 * Success: Non-zero or size of required buffer
1257 * Failure: 0
1259 UINT16 WINAPI GetOutlineTextMetrics16(
1260 HDC16 hdc, /* [in] Handle of device context */
1261 UINT16 cbData, /* [in] Size of metric data array */
1262 LPOUTLINETEXTMETRIC16 lpOTM) /* [out] Address of metric data array */
1264 FIXME("(%04x,%04x,%p): stub\n", hdc,cbData,lpOTM);
1265 return 0;
1269 /***********************************************************************
1270 * GetOutlineTextMetricsA (GDI32.@)
1271 * Gets metrics for TrueType fonts.
1274 * RETURNS
1275 * Success: Non-zero or size of required buffer
1276 * Failure: 0
1278 UINT WINAPI GetOutlineTextMetricsA(
1279 HDC hdc, /* [in] Handle of device context */
1280 UINT cbData, /* [in] Size of metric data array */
1281 LPOUTLINETEXTMETRICA lpOTM) /* [out] Address of metric data array */
1285 UINT rtn = FALSE;
1286 LPTEXTMETRICA lptxtMetr;
1290 if (lpOTM == 0)
1293 lpOTM = (LPOUTLINETEXTMETRICA)HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(OUTLINETEXTMETRICA));
1294 rtn = sizeof(OUTLINETEXTMETRICA);
1295 cbData = rtn;
1296 } else
1298 cbData = sizeof(*lpOTM);
1299 rtn = cbData;
1302 lpOTM->otmSize = cbData;
1304 lptxtMetr =HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(TEXTMETRICA));
1306 if (!GetTextMetricsA(hdc,lptxtMetr))
1308 return 0;
1309 } else
1311 memcpy(&(lpOTM->otmTextMetrics),lptxtMetr,sizeof(TEXTMETRICA));
1314 HeapFree(GetProcessHeap(),HEAP_ZERO_MEMORY,lptxtMetr);
1316 lpOTM->otmFiller = 0;
1318 lpOTM->otmPanoseNumber.bFamilyType = 0;
1319 lpOTM->otmPanoseNumber.bSerifStyle = 0;
1320 lpOTM->otmPanoseNumber.bWeight = 0;
1321 lpOTM->otmPanoseNumber.bProportion = 0;
1322 lpOTM->otmPanoseNumber.bContrast = 0;
1323 lpOTM->otmPanoseNumber.bStrokeVariation = 0;
1324 lpOTM->otmPanoseNumber.bArmStyle = 0;
1325 lpOTM->otmPanoseNumber.bLetterform = 0;
1326 lpOTM->otmPanoseNumber.bMidline = 0;
1327 lpOTM->otmPanoseNumber.bXHeight = 0;
1329 lpOTM->otmfsSelection = 0;
1330 lpOTM->otmfsType = 0;
1333 Further fill of the structure not implemented,
1334 Needs real values for the structure members
1337 return rtn;
1340 /***********************************************************************
1341 * GetOutlineTextMetricsW [GDI32.@]
1343 UINT WINAPI GetOutlineTextMetricsW(
1344 HDC hdc, /* [in] Handle of device context */
1345 UINT cbData, /* [in] Size of metric data array */
1346 LPOUTLINETEXTMETRICW lpOTM) /* [out] Address of metric data array */
1348 FIXME("(%d,%d,%p): stub\n", hdc, cbData, lpOTM);
1349 return 0;
1352 /***********************************************************************
1353 * GetCharWidth (GDI.350)
1355 BOOL16 WINAPI GetCharWidth16( HDC16 hdc, UINT16 firstChar, UINT16 lastChar,
1356 LPINT16 buffer )
1358 BOOL retVal = FALSE;
1360 if( firstChar != lastChar )
1362 LPINT buf32 = (LPINT)HeapAlloc(GetProcessHeap(), 0,
1363 sizeof(INT)*(1 + (lastChar - firstChar)));
1364 if( buf32 )
1366 LPINT obuf32 = buf32;
1367 int i;
1369 retVal = GetCharWidth32A(hdc, firstChar, lastChar, buf32);
1370 if (retVal)
1372 for (i = firstChar; i <= lastChar; i++)
1373 *buffer++ = *buf32++;
1375 HeapFree(GetProcessHeap(), 0, obuf32);
1378 else /* happens quite often to warrant a special treatment */
1380 INT chWidth;
1381 retVal = GetCharWidth32A(hdc, firstChar, lastChar, &chWidth );
1382 *buffer = chWidth;
1384 return retVal;
1388 /***********************************************************************
1389 * GetCharWidthA (GDI32.@)
1390 * GetCharWidth32A (GDI32.@)
1392 BOOL WINAPI GetCharWidth32A( HDC hdc, UINT firstChar, UINT lastChar,
1393 LPINT buffer )
1395 UINT i, extra;
1396 BOOL ret = FALSE;
1397 DC * dc = DC_GetDCPtr( hdc );
1398 if (!dc) return FALSE;
1400 if (dc->funcs->pGetCharWidth && dc->funcs->pGetCharWidth( dc, firstChar, lastChar, buffer))
1402 /* convert device units to logical */
1404 extra = dc->vportExtX >> 1;
1405 for( i = firstChar; i <= lastChar; i++, buffer++ )
1406 *buffer = (*buffer * dc->wndExtX + extra) / dc->vportExtX;
1407 ret = TRUE;
1409 GDI_ReleaseObj( hdc );
1410 return ret;
1414 /***********************************************************************
1415 * GetCharWidthW (GDI32.@)
1416 * GetCharWidth32W (GDI32.@)
1418 BOOL WINAPI GetCharWidth32W( HDC hdc, UINT firstChar, UINT lastChar,
1419 LPINT buffer )
1421 return GetCharWidth32A( hdc, firstChar, lastChar, buffer );
1425 /* FIXME: all following APIs ******************************************/
1428 /***********************************************************************
1429 * SetMapperFlags (GDI.349)
1431 DWORD WINAPI SetMapperFlags16( HDC16 hDC, DWORD dwFlag )
1433 return SetMapperFlags( hDC, dwFlag );
1437 /***********************************************************************
1438 * SetMapperFlags (GDI32.@)
1440 DWORD WINAPI SetMapperFlags( HDC hDC, DWORD dwFlag )
1442 DC *dc = DC_GetDCPtr( hDC );
1443 DWORD ret = 0;
1444 if(!dc) return 0;
1445 if(dc->funcs->pSetMapperFlags)
1446 ret = dc->funcs->pSetMapperFlags( dc, dwFlag );
1447 else
1448 FIXME("(0x%04x, 0x%08lx): stub - harmless\n", hDC, dwFlag);
1449 GDI_ReleaseObj( hDC );
1450 return ret;
1453 /***********************************************************************
1454 * GetAspectRatioFilterEx (GDI.486)
1456 BOOL16 WINAPI GetAspectRatioFilterEx16( HDC16 hdc, LPSIZE16 pAspectRatio )
1458 FIXME("(%04x, %p): -- Empty Stub !\n", hdc, pAspectRatio);
1459 return FALSE;
1462 /***********************************************************************
1463 * GetAspectRatioFilterEx (GDI32.@)
1465 BOOL WINAPI GetAspectRatioFilterEx( HDC hdc, LPSIZE pAspectRatio )
1467 FIXME("(%04x, %p): -- Empty Stub !\n", hdc, pAspectRatio);
1468 return FALSE;
1471 /***********************************************************************
1472 * GetCharABCWidths (GDI.307)
1474 BOOL16 WINAPI GetCharABCWidths16( HDC16 hdc, UINT16 firstChar, UINT16 lastChar,
1475 LPABC16 abc )
1477 LPABC abc32 = HeapAlloc(GetProcessHeap(),0,sizeof(ABC)*(lastChar-firstChar+1));
1478 int i;
1480 if (!GetCharABCWidthsA( hdc, firstChar, lastChar, abc32 )) {
1481 HeapFree(GetProcessHeap(),0,abc32);
1482 return FALSE;
1485 for (i=firstChar;i<=lastChar;i++) {
1486 abc[i-firstChar].abcA = abc32[i-firstChar].abcA;
1487 abc[i-firstChar].abcB = abc32[i-firstChar].abcB;
1488 abc[i-firstChar].abcC = abc32[i-firstChar].abcC;
1490 HeapFree(GetProcessHeap(),0,abc32);
1491 return TRUE;
1495 /***********************************************************************
1496 * GetCharABCWidthsA (GDI32.@)
1498 BOOL WINAPI GetCharABCWidthsA(HDC hdc, UINT firstChar, UINT lastChar,
1499 LPABC abc )
1501 return GetCharABCWidthsW( hdc, firstChar, lastChar, abc );
1505 /******************************************************************************
1506 * GetCharABCWidthsW [GDI32.@] Retrieves widths of characters in range
1508 * PARAMS
1509 * hdc [I] Handle of device context
1510 * firstChar [I] First character in range to query
1511 * lastChar [I] Last character in range to query
1512 * abc [O] Address of character-width structure
1514 * NOTES
1515 * Only works with TrueType fonts
1517 * RETURNS
1518 * Success: TRUE
1519 * Failure: FALSE
1521 BOOL WINAPI GetCharABCWidthsW( HDC hdc, UINT firstChar, UINT lastChar,
1522 LPABC abc )
1524 int i;
1525 LPINT widths = HeapAlloc(GetProcessHeap(),0,(lastChar-firstChar+1)*sizeof(INT));
1527 FIXME("(%04x,%04x,%04x,%p), returns slightly bogus values.\n", hdc, firstChar, lastChar, abc);
1529 GetCharWidth32A(hdc,firstChar,lastChar,widths);
1531 for (i=firstChar;i<=lastChar;i++) {
1532 abc[i-firstChar].abcA = 0; /* left distance */
1533 abc[i-firstChar].abcB = widths[i-firstChar];/* width */
1534 abc[i-firstChar].abcC = 0; /* right distance */
1536 HeapFree(GetProcessHeap(),0,widths);
1537 return TRUE;
1541 /***********************************************************************
1542 * GetGlyphOutline (GDI.309)
1544 DWORD WINAPI GetGlyphOutline16( HDC16 hdc, UINT16 uChar, UINT16 fuFormat,
1545 LPGLYPHMETRICS16 lpgm, DWORD cbBuffer,
1546 LPVOID lpBuffer, const MAT2 *lpmat2 )
1548 FIXME("(%04x, '%c', %04x, %p, %ld, %p, %p): stub\n",
1549 hdc, uChar, fuFormat, lpgm, cbBuffer, lpBuffer, lpmat2 );
1550 return (DWORD)-1; /* failure */
1554 /***********************************************************************
1555 * GetGlyphOutlineA (GDI32.@)
1557 DWORD WINAPI GetGlyphOutlineA( HDC hdc, UINT uChar, UINT fuFormat,
1558 LPGLYPHMETRICS lpgm, DWORD cbBuffer,
1559 LPVOID lpBuffer, const MAT2 *lpmat2 )
1561 FIXME("(%04x, '%c', %04x, %p, %ld, %p, %p): stub\n",
1562 hdc, uChar, fuFormat, lpgm, cbBuffer, lpBuffer, lpmat2 );
1563 return (DWORD)-1; /* failure */
1566 /***********************************************************************
1567 * GetGlyphOutlineW (GDI32.@)
1569 DWORD WINAPI GetGlyphOutlineW( HDC hdc, UINT uChar, UINT fuFormat,
1570 LPGLYPHMETRICS lpgm, DWORD cbBuffer,
1571 LPVOID lpBuffer, const MAT2 *lpmat2 )
1573 FIXME("(%04x, '%c', %04x, %p, %ld, %p, %p): stub\n",
1574 hdc, uChar, fuFormat, lpgm, cbBuffer, lpBuffer, lpmat2 );
1575 return (DWORD)-1; /* failure */
1578 /***********************************************************************
1579 * CreateScalableFontResource (GDI.310)
1581 BOOL16 WINAPI CreateScalableFontResource16( UINT16 fHidden,
1582 LPCSTR lpszResourceFile,
1583 LPCSTR fontFile, LPCSTR path )
1585 return CreateScalableFontResourceA( fHidden, lpszResourceFile,
1586 fontFile, path );
1589 /***********************************************************************
1590 * CreateScalableFontResourceA (GDI32.@)
1592 BOOL WINAPI CreateScalableFontResourceA( DWORD fHidden,
1593 LPCSTR lpszResourceFile,
1594 LPCSTR lpszFontFile,
1595 LPCSTR lpszCurrentPath )
1597 /* fHidden=1 - only visible for the calling app, read-only, not
1598 * enumbered with EnumFonts/EnumFontFamilies
1599 * lpszCurrentPath can be NULL
1601 FIXME("(%ld,%s,%s,%s): stub\n",
1602 fHidden, lpszResourceFile, lpszFontFile, lpszCurrentPath );
1603 return FALSE; /* create failed */
1606 /***********************************************************************
1607 * CreateScalableFontResourceW (GDI32.@)
1609 BOOL WINAPI CreateScalableFontResourceW( DWORD fHidden,
1610 LPCWSTR lpszResourceFile,
1611 LPCWSTR lpszFontFile,
1612 LPCWSTR lpszCurrentPath )
1614 FIXME("(%ld,%p,%p,%p): stub\n",
1615 fHidden, lpszResourceFile, lpszFontFile, lpszCurrentPath );
1616 return FALSE; /* create failed */
1620 /*************************************************************************
1621 * GetRasterizerCaps (GDI.313)
1623 BOOL16 WINAPI GetRasterizerCaps16( LPRASTERIZER_STATUS lprs, UINT16 cbNumBytes)
1625 return GetRasterizerCaps( lprs, cbNumBytes );
1629 /*************************************************************************
1630 * GetRasterizerCaps (GDI32.@)
1632 BOOL WINAPI GetRasterizerCaps( LPRASTERIZER_STATUS lprs, UINT cbNumBytes)
1634 lprs->nSize = sizeof(RASTERIZER_STATUS);
1635 lprs->wFlags = TT_AVAILABLE|TT_ENABLED;
1636 lprs->nLanguageID = 0;
1637 return TRUE;
1641 /*************************************************************************
1642 * GetKerningPairs (GDI.332)
1644 INT16 WINAPI GetKerningPairs16( HDC16 hDC, INT16 cPairs,
1645 LPKERNINGPAIR16 lpKerningPairs )
1647 /* At this time kerning is ignored (set to 0) */
1648 int i;
1649 FIXME("(%x,%d,%p): almost empty stub!\n", hDC, cPairs, lpKerningPairs);
1650 for (i = 0; i < cPairs; i++)
1651 lpKerningPairs[i].iKernAmount = 0;
1652 return 0;
1657 /*************************************************************************
1658 * GetKerningPairsA (GDI32.@)
1660 DWORD WINAPI GetKerningPairsA( HDC hDC, DWORD cPairs,
1661 LPKERNINGPAIR lpKerningPairs )
1663 int i;
1664 FIXME("(%x,%ld,%p): almost empty stub!\n", hDC, cPairs, lpKerningPairs);
1665 for (i = 0; i < cPairs; i++)
1666 lpKerningPairs[i].iKernAmount = 0;
1667 return 0;
1671 /*************************************************************************
1672 * GetKerningPairsW (GDI32.@)
1674 DWORD WINAPI GetKerningPairsW( HDC hDC, DWORD cPairs,
1675 LPKERNINGPAIR lpKerningPairs )
1677 return GetKerningPairsA( hDC, cPairs, lpKerningPairs );
1680 /*************************************************************************
1681 * TranslateCharsetInfo [GDI32.@]
1682 * TranslateCharsetInfo [USER32.@]
1684 * Fills a CHARSETINFO structure for a character set, code page, or
1685 * font. This allows making the correspondance between different labelings
1686 * (character set, Windows, ANSI, and OEM codepages, and Unicode ranges)
1687 * of the same encoding.
1689 * Only one codepage will be set in lpCs->fs. If TCI_SRCFONTSIG is used,
1690 * only one codepage should be set in *lpSrc.
1692 * RETURNS
1693 * TRUE on success, FALSE on failure.
1696 BOOL WINAPI TranslateCharsetInfo(
1697 LPDWORD lpSrc, /* [in]
1698 if flags == TCI_SRCFONTSIG: pointer to fsCsb of a FONTSIGNATURE
1699 if flags == TCI_SRCCHARSET: a character set value
1700 if flags == TCI_SRCCODEPAGE: a code page value
1702 LPCHARSETINFO lpCs, /* [out] structure to receive charset information */
1703 DWORD flags /* [in] determines interpretation of lpSrc */
1705 int index = 0;
1706 switch (flags) {
1707 case TCI_SRCFONTSIG:
1708 while (!(*lpSrc>>index & 0x0001) && index<MAXTCIINDEX) index++;
1709 break;
1710 case TCI_SRCCODEPAGE:
1711 while ((UINT) (lpSrc) != FONT_tci[index].ciACP && index < MAXTCIINDEX) index++;
1712 break;
1713 case TCI_SRCCHARSET:
1714 while ((UINT) (lpSrc) != FONT_tci[index].ciCharset && index < MAXTCIINDEX) index++;
1715 break;
1716 default:
1717 return FALSE;
1719 if (index >= MAXTCIINDEX || FONT_tci[index].ciCharset == DEFAULT_CHARSET) return FALSE;
1720 memcpy(lpCs, &FONT_tci[index], sizeof(CHARSETINFO));
1721 return TRUE;
1724 /*************************************************************************
1725 * GetFontLanguageInfo (GDI32.@)
1727 DWORD WINAPI GetFontLanguageInfo(HDC hdc) {
1728 /* return value 0 is correct for most cases anyway */
1729 FIXME("(%x):stub!\n", hdc);
1730 return 0;
1733 /*************************************************************************
1734 * GetFontLanguageInfo (GDI.616)
1736 DWORD WINAPI GetFontLanguageInfo16(HDC16 hdc) {
1737 /* return value 0 is correct for most cases anyway */
1738 FIXME("(%x):stub!\n",hdc);
1739 return 0;
1742 /*************************************************************************
1743 * GetFontData [GDI32.@] Retrieve data for TrueType font
1745 * RETURNS
1747 * success: Number of bytes returned
1748 * failure: GDI_ERROR
1750 * NOTES
1752 * Calls SetLastError()
1754 * BUGS
1756 * Unimplemented
1758 DWORD WINAPI GetFontData(HDC hdc, DWORD table, DWORD offset,
1759 LPVOID buffer, DWORD length)
1761 FIXME("(%x,%ld,%ld,%p,%ld): stub\n", hdc, table, offset, buffer, length);
1762 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
1763 return GDI_ERROR;
1766 /*************************************************************************
1767 * GetFontData [GDI.311]
1770 DWORD WINAPI GetFontData16(HDC16 hdc, DWORD dwTable, DWORD dwOffset,
1771 LPVOID lpvBuffer, DWORD cbData)
1773 return GetFontData(hdc, dwTable, dwOffset, lpvBuffer, cbData);
1776 /*************************************************************************
1777 * GetCharacterPlacementA [GDI32.@]
1779 * NOTES:
1780 * the web browser control of ie4 calls this with dwFlags=0
1782 DWORD WINAPI
1783 GetCharacterPlacementA(HDC hdc, LPCSTR lpString, INT uCount,
1784 INT nMaxExtent, GCP_RESULTSA *lpResults,
1785 DWORD dwFlags)
1787 DWORD ret=0;
1788 SIZE size;
1790 TRACE("%s 0x%08x 0x%08x 0x%08lx:stub!\n",
1791 debugstr_a(lpString), uCount, nMaxExtent, dwFlags);
1793 TRACE("lpOrder=%p lpDx=%p lpCaretPos=%p lpClass=%p "
1794 "lpOutString=%p lpGlyphs=%p\n",
1795 lpResults->lpOrder, lpResults->lpDx, lpResults->lpCaretPos,
1796 lpResults->lpClass, lpResults->lpOutString, lpResults->lpGlyphs);
1798 if(dwFlags) FIXME("flags 0x%08lx ignored\n", dwFlags);
1799 if(lpResults->lpOrder) FIXME("reordering not implemented\n");
1800 if(lpResults->lpCaretPos) FIXME("caret positions not implemented\n");
1801 if(lpResults->lpClass) FIXME("classes not implemented\n");
1802 if(lpResults->lpGlyphs) FIXME("glyphs not implemented\n");
1804 /* copy will do if the GCP_REORDER flag is not set */
1805 if(lpResults->lpOutString)
1807 lstrcpynA(lpResults->lpOutString, lpString, uCount);
1810 if (lpResults->lpDx)
1812 int i, c;
1813 for (i=0; i<uCount;i++)
1815 if (GetCharWidth32A(hdc, lpString[i], lpString[i], &c))
1816 lpResults->lpDx[i]= c;
1820 if (GetTextExtentPoint32A(hdc, lpString, uCount, &size))
1821 ret = MAKELONG(size.cx, size.cy);
1823 return ret;
1826 /*************************************************************************
1827 * GetCharacterPlacementW [GDI32.@]
1829 DWORD WINAPI
1830 GetCharacterPlacementW(HDC hdc, LPCWSTR lpString, INT uCount,
1831 INT nMaxExtent, GCP_RESULTSW *lpResults,
1832 DWORD dwFlags)
1834 /* return value 0 is correct for most cases anyway */
1835 FIXME(":stub!\n");
1836 return 0;
1839 /*************************************************************************
1840 * GetCharABCWidthsFloatA [GDI32.@]
1842 BOOL WINAPI GetCharABCWidthsFloatA(HDC hdc, UINT iFirstChar, UINT iLastChar,
1843 LPABCFLOAT lpABCF)
1845 FIXME_(gdi)("GetCharABCWidthsFloatA, stub\n");
1846 return 0;
1849 /*************************************************************************
1850 * GetCharABCWidthsFloatW [GDI32.@]
1852 BOOL WINAPI GetCharABCWidthsFloatW(HDC hdc, UINT iFirstChar,
1853 UINT iLastChar, LPABCFLOAT lpABCF)
1855 FIXME_(gdi)("GetCharABCWidthsFloatW, stub\n");
1856 return 0;
1859 /*************************************************************************
1860 * GetCharWidthFloatA [GDI32.@]
1862 BOOL WINAPI GetCharWidthFloatA(HDC hdc, UINT iFirstChar,
1863 UINT iLastChar, PFLOAT pxBuffer)
1865 FIXME_(gdi)("GetCharWidthFloatA, stub\n");
1866 return 0;
1869 /*************************************************************************
1870 * GetCharWidthFloatW [GDI32.@]
1872 BOOL WINAPI GetCharWidthFloatW(HDC hdc, UINT iFirstChar,
1873 UINT iLastChar, PFLOAT pxBuffer)
1875 FIXME_(gdi)("GetCharWidthFloatW, stub\n");
1876 return 0;
1880 /***********************************************************************
1882 * Font Resource API *
1884 ***********************************************************************/
1885 /***********************************************************************
1886 * AddFontResource (GDI.119)
1888 * Can be either .FON, or .FNT, or .TTF, or .FOT font file.
1890 * FIXME: Load header and find the best-matching font in the fontList;
1891 * fixup dfPoints if all metrics are identical, otherwise create
1892 * new fontAlias. When soft font support is ready this will
1893 * simply create a new fontResource ('filename' will go into
1894 * the pfr->resource field) with FR_SOFTFONT/FR_SOFTRESOURCE
1895 * flag set.
1897 INT16 WINAPI AddFontResource16( LPCSTR filename )
1899 return AddFontResourceA( filename );
1903 /***********************************************************************
1904 * AddFontResourceA (GDI32.@)
1906 INT WINAPI AddFontResourceA( LPCSTR str )
1908 FIXME("(%s): stub! Read the Wine User Guide on how to install "
1909 "this font manually.\n", debugres_a(str));
1910 return 1;
1914 /***********************************************************************
1915 * AddFontResourceW (GDI32.@)
1917 INT WINAPI AddFontResourceW( LPCWSTR str )
1919 FIXME("(%s): stub! Read the Wine User Guide on how to install "
1920 "this font manually.\n", debugres_w(str));
1921 return 1;
1924 /***********************************************************************
1925 * RemoveFontResource (GDI.136)
1927 BOOL16 WINAPI RemoveFontResource16( LPCSTR str )
1929 FIXME("(%s): stub\n", debugres_a(str));
1930 return TRUE;
1934 /***********************************************************************
1935 * RemoveFontResourceA (GDI32.@)
1937 BOOL WINAPI RemoveFontResourceA( LPCSTR str )
1939 /* This is how it should look like */
1941 fontResource** ppfr;
1942 BOOL32 retVal = FALSE;
1944 EnterCriticalSection( &crtsc_fonts_X11 );
1945 for( ppfr = &fontList; *ppfr; ppfr = &(*ppfr)->next )
1946 if( !strcasecmp( (*ppfr)->lfFaceName, str ) )
1948 if(((*ppfr)->fr_flags & (FR_SOFTFONT | FR_SOFTRESOURCE)) &&
1949 (*ppfr)->hOwnerProcess == GetCurrentProcess() )
1951 if( (*ppfr)->fo_count )
1952 (*ppfr)->fr_flags |= FR_REMOVED;
1953 else
1954 XFONT_RemoveFontResource( ppfr );
1956 retVal = TRUE;
1958 LeaveCriticalSection( &crtsc_fonts_X11 );
1959 return retVal;
1961 FIXME("(%s): stub\n", debugres_a(str));
1962 return TRUE;
1966 /***********************************************************************
1967 * RemoveFontResourceW (GDI32.@)
1969 BOOL WINAPI RemoveFontResourceW( LPCWSTR str )
1971 FIXME("(%s): stub\n", debugres_w(str) );
1972 return TRUE;