Handle the LB_GETTEXT and CB_GETLBTEXT cases for 32W to 16 mapping.
[wine.git] / objects / font.c
blobf1f930adb949f2ea05c7d37c466a30dd350d83d3
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 "wine/winestring.h"
11 #include "font.h"
12 #include "heap.h"
13 #include "metafile.h"
14 #include "options.h"
15 #include "debugtools.h"
16 #include "winerror.h"
17 #include "dc.h"
18 #include "winnls.h"
20 DEFAULT_DEBUG_CHANNEL(font)
21 DECLARE_DEBUG_CHANNEL(gdi)
23 #define ENUM_UNICODE 0x00000001
25 typedef struct
27 LPLOGFONT16 lpLogFontParam;
28 FONTENUMPROCEX16 lpEnumFunc;
29 LPARAM lpData;
31 LPNEWTEXTMETRICEX16 lpTextMetric;
32 LPENUMLOGFONTEX16 lpLogFont;
33 SEGPTR segTextMetric;
34 SEGPTR segLogFont;
35 } fontEnum16;
37 typedef struct
39 LPLOGFONTW lpLogFontParam;
40 FONTENUMPROCEXW lpEnumFunc;
41 LPARAM lpData;
43 LPNEWTEXTMETRICEXW lpTextMetric;
44 LPENUMLOGFONTEXW lpLogFont;
45 DWORD dwFlags;
46 } fontEnum32;
49 * For TranslateCharsetInfo
51 #define FS(x) {{0,0,0,0},{0x1<<(x),0}}
52 #define MAXTCIINDEX 32
53 static CHARSETINFO FONT_tci[MAXTCIINDEX] = {
54 /* ANSI */
55 { ANSI_CHARSET, 1252, FS(0)},
56 { EASTEUROPE_CHARSET, 1250, FS(1)},
57 { RUSSIAN_CHARSET, 1251, FS(2)},
58 { GREEK_CHARSET, 1253, FS(3)},
59 { TURKISH_CHARSET, 1254, FS(4)},
60 { HEBREW_CHARSET, 1255, FS(5)},
61 { ARABIC_CHARSET, 1256, FS(6)},
62 { BALTIC_CHARSET, 1257, FS(7)},
63 /* reserved by ANSI */
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 { DEFAULT_CHARSET, 0, FS(0)},
69 { DEFAULT_CHARSET, 0, FS(0)},
70 { DEFAULT_CHARSET, 0, FS(0)},
71 { DEFAULT_CHARSET, 0, FS(0)},
72 /* ANSI and OEM */
73 { THAI_CHARSET, 874, FS(16)},
74 { SHIFTJIS_CHARSET, 932, FS(17)},
75 { GB2312_CHARSET, 936, FS(18)},
76 { HANGEUL_CHARSET, 949, FS(19)},
77 { CHINESEBIG5_CHARSET, 950, FS(20)},
78 { JOHAB_CHARSET, 1361, FS(21)},
79 /* reserved for alternate ANSI and OEM */
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 { DEFAULT_CHARSET, 0, FS(0)},
85 { DEFAULT_CHARSET, 0, FS(0)},
86 { DEFAULT_CHARSET, 0, FS(0)},
87 { DEFAULT_CHARSET, 0, FS(0)},
88 /* reserved for system */
89 { DEFAULT_CHARSET, 0, FS(0)},
90 { DEFAULT_CHARSET, 0, FS(0)},
93 /***********************************************************************
94 * LOGFONT conversion functions.
96 void FONT_LogFont32ATo16( const LOGFONTA* font32, LPLOGFONT16 font16 )
98 font16->lfHeight = font32->lfHeight;
99 font16->lfWidth = font32->lfWidth;
100 font16->lfEscapement = font32->lfEscapement;
101 font16->lfOrientation = font32->lfOrientation;
102 font16->lfWeight = font32->lfWeight;
103 font16->lfItalic = font32->lfItalic;
104 font16->lfUnderline = font32->lfUnderline;
105 font16->lfStrikeOut = font32->lfStrikeOut;
106 font16->lfCharSet = font32->lfCharSet;
107 font16->lfOutPrecision = font32->lfOutPrecision;
108 font16->lfClipPrecision = font32->lfClipPrecision;
109 font16->lfQuality = font32->lfQuality;
110 font16->lfPitchAndFamily = font32->lfPitchAndFamily;
111 lstrcpynA( font16->lfFaceName, font32->lfFaceName, LF_FACESIZE );
114 void FONT_LogFont32WTo16( const LOGFONTW* font32, LPLOGFONT16 font16 )
116 font16->lfHeight = font32->lfHeight;
117 font16->lfWidth = font32->lfWidth;
118 font16->lfEscapement = font32->lfEscapement;
119 font16->lfOrientation = font32->lfOrientation;
120 font16->lfWeight = font32->lfWeight;
121 font16->lfItalic = font32->lfItalic;
122 font16->lfUnderline = font32->lfUnderline;
123 font16->lfStrikeOut = font32->lfStrikeOut;
124 font16->lfCharSet = font32->lfCharSet;
125 font16->lfOutPrecision = font32->lfOutPrecision;
126 font16->lfClipPrecision = font32->lfClipPrecision;
127 font16->lfQuality = font32->lfQuality;
128 font16->lfPitchAndFamily = font32->lfPitchAndFamily;
129 lstrcpynWtoA( font16->lfFaceName, font32->lfFaceName, LF_FACESIZE );
132 void FONT_LogFont16To32A( const LPLOGFONT16 font16, LPLOGFONTA font32 )
134 font32->lfHeight = font16->lfHeight;
135 font32->lfWidth = font16->lfWidth;
136 font32->lfEscapement = font16->lfEscapement;
137 font32->lfOrientation = font16->lfOrientation;
138 font32->lfWeight = font16->lfWeight;
139 font32->lfItalic = font16->lfItalic;
140 font32->lfUnderline = font16->lfUnderline;
141 font32->lfStrikeOut = font16->lfStrikeOut;
142 font32->lfCharSet = font16->lfCharSet;
143 font32->lfOutPrecision = font16->lfOutPrecision;
144 font32->lfClipPrecision = font16->lfClipPrecision;
145 font32->lfQuality = font16->lfQuality;
146 font32->lfPitchAndFamily = font16->lfPitchAndFamily;
147 lstrcpynA( font32->lfFaceName, font16->lfFaceName, LF_FACESIZE );
150 void FONT_LogFont16To32W( const LPLOGFONT16 font16, LPLOGFONTW font32 )
152 font32->lfHeight = font16->lfHeight;
153 font32->lfWidth = font16->lfWidth;
154 font32->lfEscapement = font16->lfEscapement;
155 font32->lfOrientation = font16->lfOrientation;
156 font32->lfWeight = font16->lfWeight;
157 font32->lfItalic = font16->lfItalic;
158 font32->lfUnderline = font16->lfUnderline;
159 font32->lfStrikeOut = font16->lfStrikeOut;
160 font32->lfCharSet = font16->lfCharSet;
161 font32->lfOutPrecision = font16->lfOutPrecision;
162 font32->lfClipPrecision = font16->lfClipPrecision;
163 font32->lfQuality = font16->lfQuality;
164 font32->lfPitchAndFamily = font16->lfPitchAndFamily;
165 lstrcpynAtoW( font32->lfFaceName, font16->lfFaceName, LF_FACESIZE );
168 void FONT_EnumLogFontEx16To32A( const LPENUMLOGFONTEX16 font16, LPENUMLOGFONTEXA font32 )
170 FONT_LogFont16To32A( (LPLOGFONT16)font16, (LPLOGFONTA)font32);
171 lstrcpynA( font32->elfFullName, font16->elfFullName, LF_FULLFACESIZE );
172 lstrcpynA( font32->elfStyle, font16->elfStyle, LF_FACESIZE );
173 lstrcpynA( font32->elfScript, font16->elfScript, LF_FACESIZE );
176 void FONT_EnumLogFontEx16To32W( const LPENUMLOGFONTEX16 font16, LPENUMLOGFONTEXW font32 )
178 FONT_LogFont16To32W( (LPLOGFONT16)font16, (LPLOGFONTW)font32);
179 lstrcpynAtoW( font32->elfFullName, font16->elfFullName, LF_FULLFACESIZE );
180 lstrcpynAtoW( font32->elfStyle, font16->elfStyle, LF_FACESIZE );
181 lstrcpynAtoW( font32->elfScript, font16->elfScript, LF_FACESIZE );
184 /***********************************************************************
185 * TEXTMETRIC conversion functions.
187 void FONT_TextMetric32Ato16(const LPTEXTMETRICA ptm32, LPTEXTMETRIC16 ptm16 )
189 ptm16->tmHeight = ptm32->tmHeight;
190 ptm16->tmAscent = ptm32->tmAscent;
191 ptm16->tmDescent = ptm32->tmDescent;
192 ptm16->tmInternalLeading = ptm32->tmInternalLeading;
193 ptm16->tmExternalLeading = ptm32->tmExternalLeading;
194 ptm16->tmAveCharWidth = ptm32->tmAveCharWidth;
195 ptm16->tmMaxCharWidth = ptm32->tmMaxCharWidth;
196 ptm16->tmWeight = ptm32->tmWeight;
197 ptm16->tmOverhang = ptm32->tmOverhang;
198 ptm16->tmDigitizedAspectX = ptm32->tmDigitizedAspectX;
199 ptm16->tmDigitizedAspectY = ptm32->tmDigitizedAspectY;
200 ptm16->tmFirstChar = ptm32->tmFirstChar;
201 ptm16->tmLastChar = ptm32->tmLastChar;
202 ptm16->tmDefaultChar = ptm32->tmDefaultChar;
203 ptm16->tmBreakChar = ptm32->tmBreakChar;
204 ptm16->tmItalic = ptm32->tmItalic;
205 ptm16->tmUnderlined = ptm32->tmUnderlined;
206 ptm16->tmStruckOut = ptm32->tmStruckOut;
207 ptm16->tmPitchAndFamily = ptm32->tmPitchAndFamily;
208 ptm16->tmCharSet = ptm32->tmCharSet;
211 void FONT_TextMetric32Wto16(const LPTEXTMETRICW ptm32, LPTEXTMETRIC16 ptm16 )
213 ptm16->tmHeight = ptm32->tmHeight;
214 ptm16->tmAscent = ptm32->tmAscent;
215 ptm16->tmDescent = ptm32->tmDescent;
216 ptm16->tmInternalLeading = ptm32->tmInternalLeading;
217 ptm16->tmExternalLeading = ptm32->tmExternalLeading;
218 ptm16->tmAveCharWidth = ptm32->tmAveCharWidth;
219 ptm16->tmMaxCharWidth = ptm32->tmMaxCharWidth;
220 ptm16->tmWeight = ptm32->tmWeight;
221 ptm16->tmOverhang = ptm32->tmOverhang;
222 ptm16->tmDigitizedAspectX = ptm32->tmDigitizedAspectX;
223 ptm16->tmDigitizedAspectY = ptm32->tmDigitizedAspectY;
224 ptm16->tmFirstChar = ptm32->tmFirstChar;
225 ptm16->tmLastChar = ptm32->tmLastChar;
226 ptm16->tmDefaultChar = ptm32->tmDefaultChar;
227 ptm16->tmBreakChar = ptm32->tmBreakChar;
228 ptm16->tmItalic = ptm32->tmItalic;
229 ptm16->tmUnderlined = ptm32->tmUnderlined;
230 ptm16->tmStruckOut = ptm32->tmStruckOut;
231 ptm16->tmPitchAndFamily = ptm32->tmPitchAndFamily;
232 ptm16->tmCharSet = ptm32->tmCharSet;
235 void FONT_TextMetric16to32A(const LPTEXTMETRIC16 ptm16, LPTEXTMETRICA ptm32 )
237 ptm32->tmHeight = ptm16->tmHeight;
238 ptm32->tmAscent = ptm16->tmAscent;
239 ptm32->tmDescent = ptm16->tmDescent;
240 ptm32->tmInternalLeading = ptm16->tmInternalLeading;
241 ptm32->tmExternalLeading = ptm16->tmExternalLeading;
242 ptm32->tmAveCharWidth = ptm16->tmAveCharWidth;
243 ptm32->tmMaxCharWidth = ptm16->tmMaxCharWidth;
244 ptm32->tmWeight = ptm16->tmWeight;
245 ptm32->tmOverhang = ptm16->tmOverhang;
246 ptm32->tmDigitizedAspectX = ptm16->tmDigitizedAspectX;
247 ptm32->tmDigitizedAspectY = ptm16->tmDigitizedAspectY;
248 ptm32->tmFirstChar = ptm16->tmFirstChar;
249 ptm32->tmLastChar = ptm16->tmLastChar;
250 ptm32->tmDefaultChar = ptm16->tmDefaultChar;
251 ptm32->tmBreakChar = ptm16->tmBreakChar;
252 ptm32->tmItalic = ptm16->tmItalic;
253 ptm32->tmUnderlined = ptm16->tmUnderlined;
254 ptm32->tmStruckOut = ptm16->tmStruckOut;
255 ptm32->tmPitchAndFamily = ptm16->tmPitchAndFamily;
256 ptm32->tmCharSet = ptm16->tmCharSet;
259 void FONT_TextMetric16to32W(const LPTEXTMETRIC16 ptm16, LPTEXTMETRICW ptm32 )
261 ptm32->tmHeight = ptm16->tmHeight;
262 ptm32->tmAscent = ptm16->tmAscent;
263 ptm32->tmDescent = ptm16->tmDescent;
264 ptm32->tmInternalLeading = ptm16->tmInternalLeading;
265 ptm32->tmExternalLeading = ptm16->tmExternalLeading;
266 ptm32->tmAveCharWidth = ptm16->tmAveCharWidth;
267 ptm32->tmMaxCharWidth = ptm16->tmMaxCharWidth;
268 ptm32->tmWeight = ptm16->tmWeight;
269 ptm32->tmOverhang = ptm16->tmOverhang;
270 ptm32->tmDigitizedAspectX = ptm16->tmDigitizedAspectX;
271 ptm32->tmDigitizedAspectY = ptm16->tmDigitizedAspectY;
272 ptm32->tmFirstChar = ptm16->tmFirstChar;
273 ptm32->tmLastChar = ptm16->tmLastChar;
274 ptm32->tmDefaultChar = ptm16->tmDefaultChar;
275 ptm32->tmBreakChar = ptm16->tmBreakChar;
276 ptm32->tmItalic = ptm16->tmItalic;
277 ptm32->tmUnderlined = ptm16->tmUnderlined;
278 ptm32->tmStruckOut = ptm16->tmStruckOut;
279 ptm32->tmPitchAndFamily = ptm16->tmPitchAndFamily;
280 ptm32->tmCharSet = ptm16->tmCharSet;
283 void FONT_TextMetric32Ato32W(const LPTEXTMETRICA ptm32A, LPTEXTMETRICW ptm32W )
285 ptm32W->tmHeight = ptm32A->tmHeight;
286 ptm32W->tmAscent = ptm32A->tmAscent;
287 ptm32W->tmDescent = ptm32A->tmDescent;
288 ptm32W->tmInternalLeading = ptm32A->tmInternalLeading;
289 ptm32W->tmExternalLeading = ptm32A->tmExternalLeading;
290 ptm32W->tmAveCharWidth = ptm32A->tmAveCharWidth;
291 ptm32W->tmMaxCharWidth = ptm32A->tmMaxCharWidth;
292 ptm32W->tmWeight = ptm32A->tmWeight;
293 ptm32W->tmOverhang = ptm32A->tmOverhang;
294 ptm32W->tmDigitizedAspectX = ptm32A->tmDigitizedAspectX;
295 ptm32W->tmDigitizedAspectY = ptm32A->tmDigitizedAspectY;
296 ptm32W->tmFirstChar = ptm32A->tmFirstChar;
297 ptm32W->tmLastChar = ptm32A->tmLastChar;
298 ptm32W->tmDefaultChar = ptm32A->tmDefaultChar;
299 ptm32W->tmBreakChar = ptm32A->tmBreakChar;
300 ptm32W->tmItalic = ptm32A->tmItalic;
301 ptm32W->tmUnderlined = ptm32A->tmUnderlined;
302 ptm32W->tmStruckOut = ptm32A->tmStruckOut;
303 ptm32W->tmPitchAndFamily = ptm32A->tmPitchAndFamily;
304 ptm32W->tmCharSet = ptm32A->tmCharSet;
307 /***********************************************************************
308 * CreateFontIndirect16 (GDI.57)
310 HFONT16 WINAPI CreateFontIndirect16( const LOGFONT16 *font )
312 HFONT hFont = 0;
314 if (font)
316 FONTOBJ* fontPtr;
317 if ((fontPtr = GDI_AllocObject( sizeof(FONTOBJ), FONT_MAGIC, &hFont )))
319 memcpy( &fontPtr->logfont, font, sizeof(LOGFONT16) );
321 TRACE("(%i %i %i %i) '%s' %s %s => %04x\n",
322 font->lfHeight, font->lfWidth,
323 font->lfEscapement, font->lfOrientation,
324 font->lfFaceName ? font->lfFaceName : "NULL",
325 font->lfWeight > 400 ? "Bold" : "",
326 font->lfItalic ? "Italic" : "", hFont);
328 if (font->lfEscapement != font->lfOrientation) {
329 /* this should really depend on whether GM_ADVANCED is set */
330 fontPtr->logfont.lfOrientation = fontPtr->logfont.lfEscapement;
331 WARN("orientation angle %f set to "
332 "escapement angle %f for new font %04x\n",
333 font->lfOrientation/10., font->lfEscapement/10., hFont);
335 GDI_ReleaseObj( hFont );
338 else WARN("(NULL) => NULL\n");
340 return hFont;
343 /***********************************************************************
344 * CreateFontIndirectA (GDI32.44)
346 HFONT WINAPI CreateFontIndirectA( const LOGFONTA *font )
348 LOGFONT16 font16;
350 FONT_LogFont32ATo16( font, &font16 );
351 return CreateFontIndirect16( &font16 );
354 /***********************************************************************
355 * CreateFontIndirectW (GDI32.45)
357 HFONT WINAPI CreateFontIndirectW( const LOGFONTW *font )
359 LOGFONT16 font16;
361 FONT_LogFont32WTo16( font, &font16 );
362 return CreateFontIndirect16( &font16 );
365 /***********************************************************************
366 * CreateFont16 (GDI.56)
368 HFONT16 WINAPI CreateFont16(INT16 height, INT16 width, INT16 esc, INT16 orient,
369 INT16 weight, BYTE italic, BYTE underline,
370 BYTE strikeout, BYTE charset, BYTE outpres,
371 BYTE clippres, BYTE quality, BYTE pitch,
372 LPCSTR name )
374 LOGFONT16 logfont;
376 TRACE("('%s',%d,%d)\n", (name ? name : "(null)") , height, width);
378 logfont.lfHeight = height;
379 logfont.lfWidth = width;
380 logfont.lfEscapement = esc;
381 logfont.lfOrientation = orient;
382 logfont.lfWeight = weight;
383 logfont.lfItalic = italic;
384 logfont.lfUnderline = underline;
385 logfont.lfStrikeOut = strikeout;
386 logfont.lfCharSet = charset;
387 logfont.lfOutPrecision = outpres;
388 logfont.lfClipPrecision = clippres;
389 logfont.lfQuality = quality;
390 logfont.lfPitchAndFamily = pitch;
392 if (name)
393 lstrcpynA(logfont.lfFaceName,name,sizeof(logfont.lfFaceName));
394 else
395 logfont.lfFaceName[0] = '\0';
397 return CreateFontIndirect16( &logfont );
400 /*************************************************************************
401 * CreateFontA (GDI32.43)
403 HFONT WINAPI CreateFontA( INT height, INT width, INT esc,
404 INT orient, INT weight, DWORD italic,
405 DWORD underline, DWORD strikeout, DWORD charset,
406 DWORD outpres, DWORD clippres, DWORD quality,
407 DWORD pitch, LPCSTR name )
409 return (HFONT)CreateFont16( height, width, esc, orient, weight, italic,
410 underline, strikeout, charset, outpres,
411 clippres, quality, pitch, name );
414 /*************************************************************************
415 * CreateFontW (GDI32.46)
417 HFONT WINAPI CreateFontW( INT height, INT width, INT esc,
418 INT orient, INT weight, DWORD italic,
419 DWORD underline, DWORD strikeout, DWORD charset,
420 DWORD outpres, DWORD clippres, DWORD quality,
421 DWORD pitch, LPCWSTR name )
423 LPSTR namea = HEAP_strdupWtoA( GetProcessHeap(), 0, name );
424 HFONT ret = (HFONT)CreateFont16( height, width, esc, orient, weight,
425 italic, underline, strikeout, charset,
426 outpres, clippres, quality, pitch,
427 namea );
428 if (namea) HeapFree( GetProcessHeap(), 0, namea );
429 return ret;
433 /***********************************************************************
434 * FONT_GetObject16
436 INT16 FONT_GetObject16( FONTOBJ * font, INT16 count, LPSTR buffer )
438 if (count > sizeof(LOGFONT16)) count = sizeof(LOGFONT16);
439 memcpy( buffer, &font->logfont, count );
440 return count;
443 /***********************************************************************
444 * FONT_GetObjectA
446 INT FONT_GetObjectA( FONTOBJ *font, INT count, LPSTR buffer )
448 LOGFONTA fnt32;
450 FONT_LogFont16To32A( &font->logfont, &fnt32 );
452 if (count > sizeof(fnt32)) count = sizeof(fnt32);
453 memcpy( buffer, &fnt32, count );
454 return count;
456 /***********************************************************************
457 * FONT_GetObjectW
459 INT FONT_GetObjectW( FONTOBJ *font, INT count, LPSTR buffer )
461 LOGFONTW fnt32;
463 FONT_LogFont16To32W( &font->logfont, &fnt32 );
465 if (count > sizeof(fnt32)) count = sizeof(fnt32);
466 memcpy( buffer, &fnt32, count );
467 return count;
471 /***********************************************************************
472 * FONT_EnumInstance16
474 * Called by the device driver layer to pass font info
475 * down to the application.
477 static INT FONT_EnumInstance16( LPENUMLOGFONTEX16 plf,
478 LPNEWTEXTMETRIC16 ptm, UINT16 fType, LPARAM lp )
480 #define pfe ((fontEnum16*)lp)
481 if( pfe->lpLogFontParam->lfCharSet == DEFAULT_CHARSET ||
482 pfe->lpLogFontParam->lfCharSet == plf->elfLogFont.lfCharSet )
484 memcpy( pfe->lpLogFont, plf, sizeof(ENUMLOGFONT16) );
485 memcpy( pfe->lpTextMetric, ptm, sizeof(NEWTEXTMETRIC16) );
487 return pfe->lpEnumFunc( pfe->segLogFont, pfe->segTextMetric, fType, (LPARAM)(pfe->lpData) );
489 #undef pfe
490 return 1;
493 /***********************************************************************
494 * FONT_EnumInstance
496 static INT FONT_EnumInstance( LPENUMLOGFONTEX16 plf,
497 LPNEWTEXTMETRIC16 ptm, UINT16 fType, LPARAM lp )
499 /* lfCharSet is at the same offset in both LOGFONTA and LOGFONTW */
501 #define pfe ((fontEnum32*)lp)
502 if( pfe->lpLogFontParam->lfCharSet == DEFAULT_CHARSET ||
503 pfe->lpLogFontParam->lfCharSet == plf->elfLogFont.lfCharSet )
505 /* convert font metrics */
507 if( pfe->dwFlags & ENUM_UNICODE )
509 FONT_EnumLogFontEx16To32W( plf, pfe->lpLogFont );
510 FONT_TextMetric16to32W( (LPTEXTMETRIC16)ptm, (LPTEXTMETRICW)(pfe->lpTextMetric) );
512 return pfe->lpEnumFunc( pfe->lpLogFont, pfe->lpTextMetric, fType, pfe->lpData );
514 else
516 ENUMLOGFONTEXA logfont;
518 FONT_EnumLogFontEx16To32A( plf, &logfont);
519 FONT_TextMetric16to32A( (LPTEXTMETRIC16)ptm, (LPTEXTMETRICA)pfe->lpTextMetric );
521 return pfe->lpEnumFunc( (LPENUMLOGFONTEXW)&logfont,
522 pfe->lpTextMetric, fType, pfe->lpData );
525 #undef pfe
526 return 1;
529 /***********************************************************************
530 * EnumFontFamiliesEx16 (GDI.613)
532 INT16 WINAPI EnumFontFamiliesEx16( HDC16 hDC, LPLOGFONT16 plf,
533 FONTENUMPROCEX16 efproc, LPARAM lParam,
534 DWORD dwFlags)
536 BOOL (*enum_func)(HDC,LPLOGFONT16,DEVICEFONTENUMPROC,LPARAM);
537 INT16 retVal = 0;
538 DC* dc = DC_GetDCPtr( hDC );
540 if (!dc) return 0;
541 enum_func = dc->funcs->pEnumDeviceFonts;
542 GDI_ReleaseObj( hDC );
544 if (enum_func)
546 LPNEWTEXTMETRICEX16 lptm16 = SEGPTR_ALLOC( sizeof(NEWTEXTMETRICEX16) );
547 if( lptm16 )
549 LPENUMLOGFONTEX16 lplf16 = SEGPTR_ALLOC( sizeof(ENUMLOGFONTEX16) );
550 if( lplf16 )
552 fontEnum16 fe16;
554 fe16.lpLogFontParam = plf;
555 fe16.lpEnumFunc = efproc;
556 fe16.lpData = lParam;
558 fe16.lpTextMetric = lptm16;
559 fe16.lpLogFont = lplf16;
560 fe16.segTextMetric = SEGPTR_GET(lptm16);
561 fe16.segLogFont = SEGPTR_GET(lplf16);
563 retVal = enum_func( hDC, plf, FONT_EnumInstance16, (LPARAM)&fe16 );
564 SEGPTR_FREE(lplf16);
566 SEGPTR_FREE(lptm16);
569 return retVal;
572 /***********************************************************************
573 * FONT_EnumFontFamiliesEx
575 static INT FONT_EnumFontFamiliesEx( HDC hDC, LPLOGFONTW plf, FONTENUMPROCEXW efproc,
576 LPARAM lParam, DWORD dwUnicode)
578 BOOL (*enum_func)(HDC,LPLOGFONT16,DEVICEFONTENUMPROC,LPARAM);
579 INT ret = 0;
580 DC *dc = DC_GetDCPtr( hDC );
582 if (!dc) return 0;
583 enum_func = dc->funcs->pEnumDeviceFonts;
584 GDI_ReleaseObj( hDC );
586 if (enum_func)
588 LOGFONT16 lf16;
589 NEWTEXTMETRICEXW tm32w;
590 ENUMLOGFONTEXW lf32w;
591 fontEnum32 fe32;
593 fe32.lpLogFontParam = plf;
594 fe32.lpEnumFunc = efproc;
595 fe32.lpData = lParam;
597 fe32.lpTextMetric = &tm32w;
598 fe32.lpLogFont = &lf32w;
599 fe32.dwFlags = dwUnicode;
601 /* the only difference between LOGFONT32A and LOGFONT32W is in the lfFaceName */
603 if( plf->lfFaceName[0] )
605 if( dwUnicode )
606 lstrcpynWtoA( lf16.lfFaceName, plf->lfFaceName, LF_FACESIZE );
607 else
608 lstrcpynA( lf16.lfFaceName, (LPCSTR)plf->lfFaceName, LF_FACESIZE );
610 else lf16.lfFaceName[0] = '\0';
611 lf16.lfCharSet = plf->lfCharSet;
613 ret = enum_func( hDC, &lf16, FONT_EnumInstance, (LPARAM)&fe32 );
615 return ret;
618 /***********************************************************************
619 * EnumFontFamiliesExW (GDI32.82)
621 INT WINAPI EnumFontFamiliesExW( HDC hDC, LPLOGFONTW plf,
622 FONTENUMPROCEXW efproc,
623 LPARAM lParam, DWORD dwFlags )
625 return FONT_EnumFontFamiliesEx( hDC, plf, efproc, lParam, ENUM_UNICODE );
628 /***********************************************************************
629 * EnumFontFamiliesExA (GDI32.81)
631 INT WINAPI EnumFontFamiliesExA( HDC hDC, LPLOGFONTA plf,
632 FONTENUMPROCEXA efproc,
633 LPARAM lParam, DWORD dwFlags)
635 return FONT_EnumFontFamiliesEx( hDC, (LPLOGFONTW)plf,
636 (FONTENUMPROCEXW)efproc, lParam, 0);
639 /***********************************************************************
640 * EnumFontFamilies16 (GDI.330)
642 INT16 WINAPI EnumFontFamilies16( HDC16 hDC, LPCSTR lpFamily,
643 FONTENUMPROC16 efproc, LPARAM lpData )
645 LOGFONT16 lf;
647 lf.lfCharSet = DEFAULT_CHARSET;
648 if( lpFamily ) lstrcpynA( lf.lfFaceName, lpFamily, LF_FACESIZE );
649 else lf.lfFaceName[0] = '\0';
651 return EnumFontFamiliesEx16( hDC, &lf, (FONTENUMPROCEX16)efproc, lpData, 0 );
654 /***********************************************************************
655 * EnumFontFamiliesA (GDI32.80)
657 INT WINAPI EnumFontFamiliesA( HDC hDC, LPCSTR lpFamily,
658 FONTENUMPROCA efproc, LPARAM lpData )
660 LOGFONTA lf;
662 lf.lfCharSet = DEFAULT_CHARSET;
663 if( lpFamily ) lstrcpynA( lf.lfFaceName, lpFamily, LF_FACESIZE );
664 else lf.lfFaceName[0] = lf.lfFaceName[1] = '\0';
666 return FONT_EnumFontFamiliesEx( hDC, (LPLOGFONTW)&lf,
667 (FONTENUMPROCEXW)efproc, lpData, 0 );
670 /***********************************************************************
671 * EnumFontFamiliesW (GDI32.83)
673 INT WINAPI EnumFontFamiliesW( HDC hDC, LPCWSTR lpFamily,
674 FONTENUMPROCW efproc, LPARAM lpData )
676 LOGFONTW lf;
678 lf.lfCharSet = DEFAULT_CHARSET;
679 if( lpFamily ) lstrcpynW( lf.lfFaceName, lpFamily, LF_FACESIZE );
680 else lf.lfFaceName[0] = 0;
682 return FONT_EnumFontFamiliesEx( hDC, &lf, (FONTENUMPROCEXW)efproc,
683 lpData, ENUM_UNICODE );
686 /***********************************************************************
687 * EnumFonts16 (GDI.70)
689 INT16 WINAPI EnumFonts16( HDC16 hDC, LPCSTR lpName, FONTENUMPROC16 efproc,
690 LPARAM lpData )
692 return EnumFontFamilies16( hDC, lpName, (FONTENUMPROCEX16)efproc, lpData );
695 /***********************************************************************
696 * EnumFontsA (GDI32.84)
698 INT WINAPI EnumFontsA( HDC hDC, LPCSTR lpName, FONTENUMPROCA efproc,
699 LPARAM lpData )
701 return EnumFontFamiliesA( hDC, lpName, efproc, lpData );
704 /***********************************************************************
705 * EnumFontsW (GDI32.85)
707 INT WINAPI EnumFontsW( HDC hDC, LPCWSTR lpName, FONTENUMPROCW efproc,
708 LPARAM lpData )
710 return EnumFontFamiliesW( hDC, lpName, efproc, lpData );
714 /***********************************************************************
715 * GetTextCharacterExtra16 (GDI.89)
717 INT16 WINAPI GetTextCharacterExtra16( HDC16 hdc )
719 return (INT16)GetTextCharacterExtra( hdc );
723 /***********************************************************************
724 * GetTextCharacterExtra (GDI32.225)
726 INT WINAPI GetTextCharacterExtra( HDC hdc )
728 INT ret;
729 DC * dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC );
730 if (!dc) return 0;
731 ret = abs( (dc->w.charExtra * dc->wndExtX + dc->vportExtX / 2)
732 / dc->vportExtX );
733 GDI_ReleaseObj( hdc );
734 return ret;
738 /***********************************************************************
739 * SetTextCharacterExtra16 (GDI.8)
741 INT16 WINAPI SetTextCharacterExtra16( HDC16 hdc, INT16 extra )
743 return (INT16)SetTextCharacterExtra( hdc, extra );
747 /***********************************************************************
748 * SetTextCharacterExtra (GDI32.337)
750 INT WINAPI SetTextCharacterExtra( HDC hdc, INT extra )
752 INT prev;
753 DC * dc = DC_GetDCPtr( hdc );
754 if (!dc) return 0;
755 if (dc->funcs->pSetTextCharacterExtra)
756 prev = dc->funcs->pSetTextCharacterExtra( dc, extra );
757 else
759 extra = (extra * dc->vportExtX + dc->wndExtX / 2) / dc->wndExtX;
760 prev = (dc->w.charExtra * dc->wndExtX + dc->vportExtX / 2) / dc->vportExtX;
761 dc->w.charExtra = abs(extra);
763 GDI_ReleaseObj( hdc );
764 return prev;
768 /***********************************************************************
769 * SetTextJustification16 (GDI.10)
771 INT16 WINAPI SetTextJustification16( HDC16 hdc, INT16 extra, INT16 breaks )
773 return SetTextJustification( hdc, extra, breaks );
777 /***********************************************************************
778 * SetTextJustification (GDI32.339)
780 BOOL WINAPI SetTextJustification( HDC hdc, INT extra, INT breaks )
782 BOOL ret = TRUE;
783 DC * dc = DC_GetDCPtr( hdc );
784 if (!dc) return FALSE;
785 if (dc->funcs->pSetTextJustification)
786 ret = dc->funcs->pSetTextJustification( dc, extra, breaks );
787 else
789 extra = abs((extra * dc->vportExtX + dc->wndExtX / 2) / dc->wndExtX);
790 if (!extra) breaks = 0;
791 dc->w.breakTotalExtra = extra;
792 dc->w.breakCount = breaks;
793 if (breaks)
795 dc->w.breakExtra = extra / breaks;
796 dc->w.breakRem = extra - (dc->w.breakCount * dc->w.breakExtra);
798 else
800 dc->w.breakExtra = 0;
801 dc->w.breakRem = 0;
804 GDI_ReleaseObj( hdc );
805 return ret;
809 /***********************************************************************
810 * GetTextFace16 (GDI.92)
812 INT16 WINAPI GetTextFace16( HDC16 hdc, INT16 count, LPSTR name )
814 return GetTextFaceA(hdc,count,name);
817 /***********************************************************************
818 * GetTextFaceA (GDI32.234)
820 INT WINAPI GetTextFaceA( HDC hdc, INT count, LPSTR name )
822 FONTOBJ *font;
823 INT ret = 0;
825 DC * dc = (DC *) DC_GetDCPtr( hdc );
826 if (!dc) return 0;
828 if ((font = (FONTOBJ *) GDI_GetObjPtr( dc->w.hFont, FONT_MAGIC )))
830 if (name)
832 lstrcpynA( name, font->logfont.lfFaceName, count );
833 ret = strlen(name);
835 else ret = strlen(font->logfont.lfFaceName) + 1;
836 GDI_ReleaseObj( dc->w.hFont );
838 GDI_ReleaseObj( hdc );
839 return ret;
842 /***********************************************************************
843 * GetTextFaceW (GDI32.235)
845 INT WINAPI GetTextFaceW( HDC hdc, INT count, LPWSTR name )
847 LPSTR nameA = HeapAlloc( GetProcessHeap(), 0, count );
848 INT res = GetTextFaceA(hdc,count,nameA);
849 if (name) lstrcpyAtoW( name, nameA );
850 HeapFree( GetProcessHeap(), 0, nameA );
851 return res;
855 /***********************************************************************
856 * GetTextExtent16 (GDI.91)
858 DWORD WINAPI GetTextExtent16( HDC16 hdc, LPCSTR str, INT16 count )
860 SIZE16 size;
861 if (!GetTextExtentPoint16( hdc, str, count, &size )) return 0;
862 return MAKELONG( size.cx, size.cy );
866 /***********************************************************************
867 * GetTextExtentPoint16 (GDI.471)
869 * FIXME: Should this have a bug for compatibility?
870 * Original Windows versions of GetTextExtentPoint{A,W} have documented
871 * bugs (-> MSDN KB q147647.txt).
873 BOOL16 WINAPI GetTextExtentPoint16( HDC16 hdc, LPCSTR str, INT16 count,
874 LPSIZE16 size )
876 SIZE size32;
877 BOOL ret;
878 TRACE("%04x, %p (%s), %d, %p\n", hdc, str, debugstr_an(str, count), count,
879 size);
880 ret = GetTextExtentPoint32A( hdc, str, count, &size32 );
881 CONV_SIZE32TO16( &size32, size );
882 return (BOOL16)ret;
886 /***********************************************************************
887 * GetTextExtentPoint32A (GDI32.230)
889 BOOL WINAPI GetTextExtentPoint32A( HDC hdc, LPCSTR str, INT count,
890 LPSIZE size )
892 BOOL ret = FALSE;
893 DC * dc = DC_GetDCPtr( hdc );
895 if (!dc) return FALSE;
897 if (dc->funcs->pGetTextExtentPoint)
899 /* str may not be 0 terminated so we can't use HEAP_strdupWtoA.
900 * So we use MultiByteToWideChar.
902 UINT wlen = MultiByteToWideChar(dc->w.codepage,0,str,count,NULL,0);
903 LPWSTR p = HeapAlloc( GetProcessHeap(), 0, wlen * sizeof(WCHAR) );
904 if (p)
906 wlen = MultiByteToWideChar(dc->w.codepage,0,str,count,p,wlen);
907 ret = dc->funcs->pGetTextExtentPoint( dc, p, wlen, size );
908 HeapFree( GetProcessHeap(), 0, p );
911 GDI_ReleaseObj( hdc );
912 TRACE("(%08x %s %d %p): returning %d,%d\n",
913 hdc, debugstr_an (str, count), count, size, size->cx, size->cy );
914 return ret;
918 /***********************************************************************
919 * GetTextExtentPoint32W [GDI32.231] Computes width/height for a string
921 * Computes width and height of the specified string.
923 * RETURNS
924 * Success: TRUE
925 * Failure: FALSE
927 BOOL WINAPI GetTextExtentPoint32W(
928 HDC hdc, /* [in] Handle of device context */
929 LPCWSTR str, /* [in] Address of text string */
930 INT count, /* [in] Number of characters in string */
931 LPSIZE size) /* [out] Address of structure for string size */
933 BOOL ret = FALSE;
934 DC * dc = DC_GetDCPtr( hdc );
935 if (dc)
937 if(dc->funcs->pGetTextExtentPoint)
938 ret = dc->funcs->pGetTextExtentPoint( dc, str, count, size );
939 GDI_ReleaseObj( hdc );
941 TRACE("(%08x %s %d %p): returning %d,%d\n",
942 hdc, debugstr_wn (str, count), count, size, size->cx, size->cy );
943 return ret;
947 /***********************************************************************
948 * GetTextExtentPointA (GDI32.232)
950 BOOL WINAPI GetTextExtentPointA( HDC hdc, LPCSTR str, INT count,
951 LPSIZE size )
953 TRACE("not bug compatible.\n");
954 return GetTextExtentPoint32A( hdc, str, count, size );
957 /***********************************************************************
958 * GetTextExtentPointW (GDI32.233)
960 BOOL WINAPI GetTextExtentPointW( HDC hdc, LPCWSTR str, INT count,
961 LPSIZE size )
963 TRACE("not bug compatible.\n");
964 return GetTextExtentPoint32W( hdc, str, count, size );
968 /***********************************************************************
969 * GetTextExtentExPointA (GDI32.228)
971 BOOL WINAPI GetTextExtentExPointA( HDC hdc, LPCSTR str, INT count,
972 INT maxExt, LPINT lpnFit,
973 LPINT alpDx, LPSIZE size )
975 LPWSTR p;
976 BOOL ret;
978 /* Docs say str should be 0 terminated here, but we'll use count just in case
981 p = HeapAlloc( GetProcessHeap(), 0, (count+1) * sizeof(WCHAR) );
982 lstrcpynAtoW(p, str, count+1);
983 ret = GetTextExtentExPointW( hdc, p, count, maxExt, lpnFit, alpDx, size);
984 HeapFree( GetProcessHeap(), 0, p );
985 return ret;
989 /***********************************************************************
990 * GetTextExtentExPointW (GDI32.229)
993 BOOL WINAPI GetTextExtentExPointW( HDC hdc, LPCWSTR str, INT count,
994 INT maxExt, LPINT lpnFit,
995 LPINT alpDx, LPSIZE size )
997 int index, nFit, extent;
998 SIZE tSize;
999 BOOL ret = FALSE;
1000 DC * dc = DC_GetDCPtr( hdc );
1001 if (!dc) return FALSE;
1003 if (!dc->funcs->pGetTextExtentPoint) goto done;
1005 size->cx = size->cy = nFit = extent = 0;
1006 for(index = 0; index < count; index++)
1008 if(!dc->funcs->pGetTextExtentPoint( dc, str, 1, &tSize )) goto done;
1009 if( extent+tSize.cx < maxExt )
1011 extent+=tSize.cx;
1012 nFit++;
1013 str++;
1014 if( alpDx ) alpDx[index] = extent;
1015 if( tSize.cy > size->cy ) size->cy = tSize.cy;
1017 else break;
1019 size->cx = extent;
1020 *lpnFit = nFit;
1021 ret = TRUE;
1023 TRACE("(%08x %s %d) returning %d %d %d\n",
1024 hdc,debugstr_wn(str,count),maxExt,nFit, size->cx,size->cy);
1025 done:
1026 GDI_ReleaseObj( hdc );
1027 return ret;
1030 /***********************************************************************
1031 * GetTextMetrics16 (GDI.93)
1033 BOOL16 WINAPI GetTextMetrics16( HDC16 hdc, TEXTMETRIC16 *metrics )
1035 TEXTMETRICA tm32;
1037 if (!GetTextMetricsA( (HDC)hdc, &tm32 )) return FALSE;
1038 FONT_TextMetric32Ato16( &tm32, metrics );
1039 return TRUE;
1043 /***********************************************************************
1044 * GetTextMetricsA (GDI32.236)
1046 BOOL WINAPI GetTextMetricsA( HDC hdc, TEXTMETRICA *metrics )
1048 BOOL ret = FALSE;
1049 DC * dc = DC_GetDCPtr( hdc );
1050 if (!dc) return FALSE;
1052 if (dc->funcs->pGetTextMetrics && dc->funcs->pGetTextMetrics( dc, metrics ))
1054 /* device layer returns values in device units
1055 * therefore we have to convert them to logical */
1057 #define WDPTOLP(x) ((x<0)? \
1058 (-abs((x)*dc->wndExtX/dc->vportExtX)): \
1059 (abs((x)*dc->wndExtX/dc->vportExtX)))
1060 #define HDPTOLP(y) ((y<0)? \
1061 (-abs((y)*dc->wndExtY/dc->vportExtY)): \
1062 (abs((y)*dc->wndExtY/dc->vportExtY)))
1064 metrics->tmHeight = HDPTOLP(metrics->tmHeight);
1065 metrics->tmAscent = HDPTOLP(metrics->tmAscent);
1066 metrics->tmDescent = HDPTOLP(metrics->tmDescent);
1067 metrics->tmInternalLeading = HDPTOLP(metrics->tmInternalLeading);
1068 metrics->tmExternalLeading = HDPTOLP(metrics->tmExternalLeading);
1069 metrics->tmAveCharWidth = WDPTOLP(metrics->tmAveCharWidth);
1070 metrics->tmMaxCharWidth = WDPTOLP(metrics->tmMaxCharWidth);
1071 metrics->tmOverhang = WDPTOLP(metrics->tmOverhang);
1072 ret = TRUE;
1074 TRACE("text metrics:\n"
1075 " Weight = %03li\t FirstChar = %03i\t AveCharWidth = %li\n"
1076 " Italic = % 3i\t LastChar = %03i\t\t MaxCharWidth = %li\n"
1077 " UnderLined = %01i\t DefaultChar = %03i\t Overhang = %li\n"
1078 " StruckOut = %01i\t BreakChar = %03i\t CharSet = %i\n"
1079 " PitchAndFamily = %02x\n"
1080 " --------------------\n"
1081 " InternalLeading = %li\n"
1082 " Ascent = %li\n"
1083 " Descent = %li\n"
1084 " Height = %li\n",
1085 metrics->tmWeight, metrics->tmFirstChar, metrics->tmAveCharWidth,
1086 metrics->tmItalic, metrics->tmLastChar, metrics->tmMaxCharWidth,
1087 metrics->tmUnderlined, metrics->tmDefaultChar, metrics->tmOverhang,
1088 metrics->tmStruckOut, metrics->tmBreakChar, metrics->tmCharSet,
1089 metrics->tmPitchAndFamily,
1090 metrics->tmInternalLeading,
1091 metrics->tmAscent,
1092 metrics->tmDescent,
1093 metrics->tmHeight );
1095 GDI_ReleaseObj( hdc );
1096 return ret;
1100 /***********************************************************************
1101 * GetTextMetricsW (GDI32.237)
1103 BOOL WINAPI GetTextMetricsW( HDC hdc, TEXTMETRICW *metrics )
1105 TEXTMETRICA tm;
1106 if (!GetTextMetricsA( (HDC16)hdc, &tm )) return FALSE;
1107 FONT_TextMetric32Ato32W( &tm, metrics );
1108 return TRUE;
1112 /***********************************************************************
1113 * GetOutlineTextMetrics16 [GDI.308] Gets metrics for TrueType fonts.
1115 * NOTES
1116 * lpOTM should be LPOUTLINETEXTMETRIC
1118 * RETURNS
1119 * Success: Non-zero or size of required buffer
1120 * Failure: 0
1122 UINT16 WINAPI GetOutlineTextMetrics16(
1123 HDC16 hdc, /* [in] Handle of device context */
1124 UINT16 cbData, /* [in] Size of metric data array */
1125 LPOUTLINETEXTMETRIC16 lpOTM) /* [out] Address of metric data array */
1127 FIXME("(%04x,%04x,%p): stub\n", hdc,cbData,lpOTM);
1128 return 0;
1132 /***********************************************************************
1133 * GetOutlineTextMetricsA [GDI.207] Gets metrics for TrueType fonts.
1136 * RETURNS
1137 * Success: Non-zero or size of required buffer
1138 * Failure: 0
1140 UINT WINAPI GetOutlineTextMetricsA(
1141 HDC hdc, /* [in] Handle of device context */
1142 UINT cbData, /* [in] Size of metric data array */
1143 LPOUTLINETEXTMETRICA lpOTM) /* [out] Address of metric data array */
1147 UINT rtn = FALSE;
1148 LPTEXTMETRICA lptxtMetr;
1152 if (lpOTM == 0)
1155 lpOTM = (LPOUTLINETEXTMETRICA)HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(OUTLINETEXTMETRICA));
1156 rtn = sizeof(OUTLINETEXTMETRICA);
1157 cbData = rtn;
1158 } else
1160 cbData = sizeof(*lpOTM);
1161 rtn = cbData;
1164 lpOTM->otmSize = cbData;
1166 lptxtMetr =HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(TEXTMETRICA));
1168 if (!GetTextMetricsA(hdc,lptxtMetr))
1170 return 0;
1171 } else
1173 memcpy(&(lpOTM->otmTextMetrics),lptxtMetr,sizeof(TEXTMETRICA));
1176 HeapFree(GetProcessHeap(),HEAP_ZERO_MEMORY,lptxtMetr);
1178 lpOTM->otmFilter = 0;
1180 lpOTM->otmPanoseNumber.bFamilyType = 0;
1181 lpOTM->otmPanoseNumber.bSerifStyle = 0;
1182 lpOTM->otmPanoseNumber.bWeight = 0;
1183 lpOTM->otmPanoseNumber.bProportion = 0;
1184 lpOTM->otmPanoseNumber.bContrast = 0;
1185 lpOTM->otmPanoseNumber.bStrokeVariation = 0;
1186 lpOTM->otmPanoseNumber.bArmStyle = 0;
1187 lpOTM->otmPanoseNumber.bLetterform = 0;
1188 lpOTM->otmPanoseNumber.bMidline = 0;
1189 lpOTM->otmPanoseNumber.bXHeight = 0;
1191 lpOTM->otmfsSelection = 0;
1192 lpOTM->otmfsType = 0;
1195 Further fill of the structure not implemented,
1196 Needs real values for the structure members
1199 return rtn;
1202 /***********************************************************************
1203 * GetOutlineTextMetricsW [GDI32.208]
1205 UINT WINAPI GetOutlineTextMetricsW(
1206 HDC hdc, /* [in] Handle of device context */
1207 UINT cbData, /* [in] Size of metric data array */
1208 LPOUTLINETEXTMETRICW lpOTM) /* [out] Address of metric data array */
1210 FIXME("(%d,%d,%p): stub\n", hdc, cbData, lpOTM);
1211 return 0;
1214 /***********************************************************************
1215 * GetCharWidth16 (GDI.350)
1217 BOOL16 WINAPI GetCharWidth16( HDC16 hdc, UINT16 firstChar, UINT16 lastChar,
1218 LPINT16 buffer )
1220 BOOL retVal = FALSE;
1222 if( firstChar != lastChar )
1224 LPINT buf32 = (LPINT)HeapAlloc(GetProcessHeap(), 0,
1225 sizeof(INT)*(1 + (lastChar - firstChar)));
1226 if( buf32 )
1228 LPINT obuf32 = buf32;
1229 int i;
1231 retVal = GetCharWidth32A(hdc, firstChar, lastChar, buf32);
1232 if (retVal)
1234 for (i = firstChar; i <= lastChar; i++)
1235 *buffer++ = *buf32++;
1237 HeapFree(GetProcessHeap(), 0, obuf32);
1240 else /* happens quite often to warrant a special treatment */
1242 INT chWidth;
1243 retVal = GetCharWidth32A(hdc, firstChar, lastChar, &chWidth );
1244 *buffer = chWidth;
1246 return retVal;
1250 /***********************************************************************
1251 * GetCharWidth32A (GDI32.155)
1253 BOOL WINAPI GetCharWidth32A( HDC hdc, UINT firstChar, UINT lastChar,
1254 LPINT buffer )
1256 UINT i, extra;
1257 BOOL ret = FALSE;
1258 DC * dc = DC_GetDCPtr( hdc );
1259 if (!dc) return FALSE;
1261 if (dc->funcs->pGetCharWidth && dc->funcs->pGetCharWidth( dc, firstChar, lastChar, buffer))
1263 /* convert device units to logical */
1265 extra = dc->vportExtX >> 1;
1266 for( i = firstChar; i <= lastChar; i++, buffer++ )
1267 *buffer = (*buffer * dc->wndExtX + extra) / dc->vportExtX;
1268 ret = TRUE;
1270 GDI_ReleaseObj( hdc );
1271 return ret;
1275 /***********************************************************************
1276 * GetCharWidth32W (GDI32.158)
1278 BOOL WINAPI GetCharWidth32W( HDC hdc, UINT firstChar, UINT lastChar,
1279 LPINT buffer )
1281 return GetCharWidth32A( hdc, firstChar, lastChar, buffer );
1285 /* FIXME: all following APIs ******************************************/
1288 /***********************************************************************
1289 * SetMapperFlags16 (GDI.349)
1291 DWORD WINAPI SetMapperFlags16( HDC16 hDC, DWORD dwFlag )
1293 return SetMapperFlags( hDC, dwFlag );
1297 /***********************************************************************
1298 * SetMapperFlags (GDI32.322)
1300 DWORD WINAPI SetMapperFlags( HDC hDC, DWORD dwFlag )
1302 DC *dc = DC_GetDCPtr( hDC );
1303 DWORD ret = 0;
1304 if(!dc) return 0;
1305 if(dc->funcs->pSetMapperFlags)
1306 ret = dc->funcs->pSetMapperFlags( dc, dwFlag );
1307 else
1308 FIXME("(0x%04x, 0x%08lx): stub - harmless\n", hDC, dwFlag);
1309 GDI_ReleaseObj( hDC );
1310 return ret;
1313 /***********************************************************************
1314 * GetAspectRatioFilterEx16 (GDI.486)
1316 BOOL16 WINAPI GetAspectRatioFilterEx16( HDC16 hdc, LPSIZE16 pAspectRatio )
1318 FIXME("(%04x, %p): -- Empty Stub !\n", hdc, pAspectRatio);
1319 return FALSE;
1322 /***********************************************************************
1323 * GetAspectRatioFilterEx (GDI32.142)
1325 BOOL WINAPI GetAspectRatioFilterEx( HDC hdc, LPSIZE pAspectRatio )
1327 FIXME("(%04x, %p): -- Empty Stub !\n", hdc, pAspectRatio);
1328 return FALSE;
1331 /***********************************************************************
1332 * GetCharABCWidths16 (GDI.307)
1334 BOOL16 WINAPI GetCharABCWidths16( HDC16 hdc, UINT16 firstChar, UINT16 lastChar,
1335 LPABC16 abc )
1337 ABC abc32;
1338 if (!GetCharABCWidthsA( hdc, firstChar, lastChar, &abc32 )) return FALSE;
1339 abc->abcA = abc32.abcA;
1340 abc->abcB = abc32.abcB;
1341 abc->abcC = abc32.abcC;
1342 return TRUE;
1346 /***********************************************************************
1347 * GetCharABCWidthsA (GDI32.149)
1349 BOOL WINAPI GetCharABCWidthsA(HDC hdc, UINT firstChar, UINT lastChar,
1350 LPABC abc )
1352 return GetCharABCWidthsW( hdc, firstChar, lastChar, abc );
1356 /******************************************************************************
1357 * GetCharABCWidthsW [GDI32.152] Retrieves widths of characters in range
1359 * PARAMS
1360 * hdc [I] Handle of device context
1361 * firstChar [I] First character in range to query
1362 * lastChar [I] Last character in range to query
1363 * abc [O] Address of character-width structure
1365 * NOTES
1366 * Only works with TrueType fonts
1368 * RETURNS
1369 * Success: TRUE
1370 * Failure: FALSE
1372 BOOL WINAPI GetCharABCWidthsW( HDC hdc, UINT firstChar, UINT lastChar,
1373 LPABC abc )
1375 /* No TrueType fonts in Wine so far */
1376 FIXME("(%04x,%04x,%04x,%p): stub\n", hdc, firstChar, lastChar, abc);
1377 return FALSE;
1381 /***********************************************************************
1382 * GetGlyphOutline16 (GDI.309)
1384 DWORD WINAPI GetGlyphOutline16( HDC16 hdc, UINT16 uChar, UINT16 fuFormat,
1385 LPGLYPHMETRICS16 lpgm, DWORD cbBuffer,
1386 LPVOID lpBuffer, const MAT2 *lpmat2 )
1388 FIXME("(%04x, '%c', %04x, %p, %ld, %p, %p): stub\n",
1389 hdc, uChar, fuFormat, lpgm, cbBuffer, lpBuffer, lpmat2 );
1390 return (DWORD)-1; /* failure */
1394 /***********************************************************************
1395 * GetGlyphOutlineA (GDI32.186)
1397 DWORD WINAPI GetGlyphOutlineA( HDC hdc, UINT uChar, UINT fuFormat,
1398 LPGLYPHMETRICS lpgm, DWORD cbBuffer,
1399 LPVOID lpBuffer, const MAT2 *lpmat2 )
1401 FIXME("(%04x, '%c', %04x, %p, %ld, %p, %p): stub\n",
1402 hdc, uChar, fuFormat, lpgm, cbBuffer, lpBuffer, lpmat2 );
1403 return (DWORD)-1; /* failure */
1406 /***********************************************************************
1407 * GetGlyphOutlineW (GDI32.187)
1409 DWORD WINAPI GetGlyphOutlineW( HDC hdc, UINT uChar, UINT fuFormat,
1410 LPGLYPHMETRICS lpgm, DWORD cbBuffer,
1411 LPVOID lpBuffer, const MAT2 *lpmat2 )
1413 FIXME("(%04x, '%c', %04x, %p, %ld, %p, %p): stub\n",
1414 hdc, uChar, fuFormat, lpgm, cbBuffer, lpBuffer, lpmat2 );
1415 return (DWORD)-1; /* failure */
1418 /***********************************************************************
1419 * CreateScalableFontResource16 (GDI.310)
1421 BOOL16 WINAPI CreateScalableFontResource16( UINT16 fHidden,
1422 LPCSTR lpszResourceFile,
1423 LPCSTR fontFile, LPCSTR path )
1425 return CreateScalableFontResourceA( fHidden, lpszResourceFile,
1426 fontFile, path );
1429 /***********************************************************************
1430 * CreateScalableFontResourceA (GDI32.62)
1432 BOOL WINAPI CreateScalableFontResourceA( DWORD fHidden,
1433 LPCSTR lpszResourceFile,
1434 LPCSTR lpszFontFile,
1435 LPCSTR lpszCurrentPath )
1437 /* fHidden=1 - only visible for the calling app, read-only, not
1438 * enumbered with EnumFonts/EnumFontFamilies
1439 * lpszCurrentPath can be NULL
1441 FIXME("(%ld,%s,%s,%s): stub\n",
1442 fHidden, lpszResourceFile, lpszFontFile, lpszCurrentPath );
1443 return FALSE; /* create failed */
1446 /***********************************************************************
1447 * CreateScalableFontResourceW (GDI32.63)
1449 BOOL WINAPI CreateScalableFontResourceW( DWORD fHidden,
1450 LPCWSTR lpszResourceFile,
1451 LPCWSTR lpszFontFile,
1452 LPCWSTR lpszCurrentPath )
1454 FIXME("(%ld,%p,%p,%p): stub\n",
1455 fHidden, lpszResourceFile, lpszFontFile, lpszCurrentPath );
1456 return FALSE; /* create failed */
1460 /*************************************************************************
1461 * GetRasterizerCaps16 (GDI.313)
1463 BOOL16 WINAPI GetRasterizerCaps16( LPRASTERIZER_STATUS lprs, UINT16 cbNumBytes)
1465 return GetRasterizerCaps( lprs, cbNumBytes );
1469 /*************************************************************************
1470 * GetRasterizerCaps (GDI32.216)
1472 BOOL WINAPI GetRasterizerCaps( LPRASTERIZER_STATUS lprs, UINT cbNumBytes)
1474 lprs->nSize = sizeof(RASTERIZER_STATUS);
1475 lprs->wFlags = TT_AVAILABLE|TT_ENABLED;
1476 lprs->nLanguageID = 0;
1477 return TRUE;
1481 /*************************************************************************
1482 * GetKerningPairs16 (GDI.332)
1484 INT16 WINAPI GetKerningPairs16( HDC16 hDC, INT16 cPairs,
1485 LPKERNINGPAIR16 lpKerningPairs )
1487 /* At this time kerning is ignored (set to 0) */
1488 int i;
1489 FIXME("(%x,%d,%p): almost empty stub!\n", hDC, cPairs, lpKerningPairs);
1490 for (i = 0; i < cPairs; i++)
1491 lpKerningPairs[i].iKernAmount = 0;
1492 return 0;
1497 /*************************************************************************
1498 * GetKerningPairsA (GDI32.192)
1500 DWORD WINAPI GetKerningPairsA( HDC hDC, DWORD cPairs,
1501 LPKERNINGPAIR lpKerningPairs )
1503 int i;
1504 FIXME("(%x,%ld,%p): almost empty stub!\n", hDC, cPairs, lpKerningPairs);
1505 for (i = 0; i < cPairs; i++)
1506 lpKerningPairs[i].iKernAmount = 0;
1507 return 0;
1511 /*************************************************************************
1512 * GetKerningPairsW (GDI32.193)
1514 DWORD WINAPI GetKerningPairsW( HDC hDC, DWORD cPairs,
1515 LPKERNINGPAIR lpKerningPairs )
1517 return GetKerningPairsA( hDC, cPairs, lpKerningPairs );
1520 /*************************************************************************
1521 * TranslateCharsetInfo [GDI32.382]
1523 * Fills a CHARSETINFO structure for a character set, code page, or
1524 * font. This allows making the correspondance between different labelings
1525 * (character set, Windows, ANSI, and OEM codepages, and Unicode ranges)
1526 * of the same encoding.
1528 * Only one codepage will be set in lpCs->fs. If TCI_SRCFONTSIG is used,
1529 * only one codepage should be set in *lpSrc.
1531 * RETURNS
1532 * TRUE on success, FALSE on failure.
1535 BOOL WINAPI TranslateCharsetInfo(
1536 LPDWORD lpSrc, /*
1537 if flags == TCI_SRCFONTSIG: pointer to fsCsb of a FONTSIGNATURE
1538 if flags == TCI_SRCCHARSET: a character set value
1539 if flags == TCI_SRCCODEPAGE: a code page value
1541 LPCHARSETINFO lpCs, /* structure to receive charset information */
1542 DWORD flags /* determines interpretation of lpSrc */
1544 int index = 0;
1545 switch (flags) {
1546 case TCI_SRCFONTSIG:
1547 while (!(*lpSrc>>index & 0x0001) && index<MAXTCIINDEX) index++;
1548 break;
1549 case TCI_SRCCODEPAGE:
1550 while ((UINT) (lpSrc) != FONT_tci[index].ciACP && index < MAXTCIINDEX) index++;
1551 break;
1552 case TCI_SRCCHARSET:
1553 while ((UINT) (lpSrc) != FONT_tci[index].ciCharset && index < MAXTCIINDEX) index++;
1554 break;
1555 default:
1556 return FALSE;
1558 if (index >= MAXTCIINDEX || FONT_tci[index].ciCharset == DEFAULT_CHARSET) return FALSE;
1559 memcpy(lpCs, &FONT_tci[index], sizeof(CHARSETINFO));
1560 return TRUE;
1563 /*************************************************************************
1564 * GetFontLanguageInfo (GDI32.182)
1566 DWORD WINAPI GetFontLanguageInfo(HDC hdc) {
1567 /* return value 0 is correct for most cases anyway */
1568 FIXME("(%x):stub!\n", hdc);
1569 return 0;
1572 /*************************************************************************
1573 * GetFontLanguageInfo (GDI.616)
1575 DWORD WINAPI GetFontLanguageInfo16(HDC16 hdc) {
1576 /* return value 0 is correct for most cases anyway */
1577 FIXME("(%x):stub!\n",hdc);
1578 return 0;
1581 /*************************************************************************
1582 * GetFontData [GDI32.181] Retrieve data for TrueType font
1584 * RETURNS
1586 * success: Number of bytes returned
1587 * failure: GDI_ERROR
1589 * NOTES
1591 * Calls SetLastError()
1593 * BUGS
1595 * Unimplemented
1597 DWORD WINAPI GetFontData(HDC hdc, DWORD table, DWORD offset,
1598 LPVOID buffer, DWORD length)
1600 FIXME("(%x,%ld,%ld,%p,%ld): stub\n", hdc, table, offset, buffer, length);
1601 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
1602 return GDI_ERROR;
1605 /*************************************************************************
1606 * GetFontData16 [GDI.311]
1609 DWORD WINAPI GetFontData16(HDC16 hdc, DWORD dwTable, DWORD dwOffset,
1610 LPVOID lpvBuffer, DWORD cbData)
1612 return GetFontData(hdc, dwTable, dwOffset, lpvBuffer, cbData);
1615 /*************************************************************************
1616 * GetCharacterPlacementA [GDI32.160]
1618 * NOTES:
1619 * the web browser control of ie4 calls this with dwFlags=0
1621 DWORD WINAPI
1622 GetCharacterPlacementA(HDC hdc, LPCSTR lpString, INT uCount,
1623 INT nMaxExtent, GCP_RESULTSA *lpResults,
1624 DWORD dwFlags)
1626 DWORD ret=0;
1627 SIZE size;
1629 TRACE("%s 0x%08x 0x%08x 0x%08lx:stub!\n",
1630 debugstr_a(lpString), uCount, nMaxExtent, dwFlags);
1632 TRACE("lpOrder=%p lpDx=%p lpCaretPos=%p lpClass=%p "
1633 "lpOutString=%p lpGlyphs=%p\n",
1634 lpResults->lpOrder, lpResults->lpDx, lpResults->lpCaretPos,
1635 lpResults->lpClass, lpResults->lpOutString, lpResults->lpGlyphs);
1637 if(dwFlags) FIXME("flags 0x%08lx ignored\n", dwFlags);
1638 if(lpResults->lpOrder) FIXME("reordering not implemented\n");
1639 if(lpResults->lpCaretPos) FIXME("caret positions not implemented\n");
1640 if(lpResults->lpClass) FIXME("classes not implemented\n");
1641 if(lpResults->lpGlyphs) FIXME("glyphs not implemented\n");
1643 /* copy will do if the GCP_REORDER flag is not set */
1644 if(lpResults->lpOutString)
1646 lstrcpynA(lpResults->lpOutString, lpString, uCount);
1649 if (lpResults->lpDx)
1651 int i, c;
1652 for (i=0; i<uCount;i++)
1654 if (GetCharWidth32A(hdc, lpString[i], lpString[i], &c))
1655 lpResults->lpDx[i]= c;
1659 if (GetTextExtentPoint32A(hdc, lpString, uCount, &size))
1660 ret = MAKELONG(size.cx, size.cy);
1662 return ret;
1665 /*************************************************************************
1666 * GetCharacterPlacementW [GDI32.161]
1668 DWORD WINAPI
1669 GetCharacterPlacementW(HDC hdc, LPCWSTR lpString, INT uCount,
1670 INT nMaxExtent, GCP_RESULTSW *lpResults,
1671 DWORD dwFlags)
1673 /* return value 0 is correct for most cases anyway */
1674 FIXME(":stub!\n");
1675 return 0;
1678 /*************************************************************************
1679 * GetCharABCWidthsFloatA [GDI32.150]
1681 BOOL WINAPI GetCharABCWidthsFloatA(HDC hdc, UINT iFirstChar, UINT iLastChar,
1682 LPABCFLOAT lpABCF)
1684 FIXME_(gdi)("GetCharABCWidthsFloatA, stub\n");
1685 return 0;
1688 /*************************************************************************
1689 * GetCharABCWidthsFloatW [GDI32.151]
1691 BOOL WINAPI GetCharABCWidthsFloatW(HDC hdc, UINT iFirstChar,
1692 UINT iLastChar, LPABCFLOAT lpABCF)
1694 FIXME_(gdi)("GetCharABCWidthsFloatW, stub\n");
1695 return 0;
1698 /*************************************************************************
1699 * GetCharWidthFloatA [GDI32.156]
1701 BOOL WINAPI GetCharWidthFloatA(HDC hdc, UINT iFirstChar,
1702 UINT iLastChar, PFLOAT pxBuffer)
1704 FIXME_(gdi)("GetCharWidthFloatA, stub\n");
1705 return 0;
1708 /*************************************************************************
1709 * GetCharWidthFloatW [GDI32.157]
1711 BOOL WINAPI GetCharWidthFloatW(HDC hdc, UINT iFirstChar,
1712 UINT iLastChar, PFLOAT pxBuffer)
1714 FIXME_(gdi)("GetCharWidthFloatW, stub\n");
1715 return 0;
1719 /***********************************************************************
1721 * Font Resource API *
1723 ***********************************************************************/
1724 /***********************************************************************
1725 * AddFontResource16 (GDI.119)
1727 * Can be either .FON, or .FNT, or .TTF, or .FOT font file.
1729 * FIXME: Load header and find the best-matching font in the fontList;
1730 * fixup dfPoints if all metrics are identical, otherwise create
1731 * new fontAlias. When soft font support is ready this will
1732 * simply create a new fontResource ('filename' will go into
1733 * the pfr->resource field) with FR_SOFTFONT/FR_SOFTRESOURCE
1734 * flag set.
1736 INT16 WINAPI AddFontResource16( LPCSTR filename )
1738 return AddFontResourceA( filename );
1742 /***********************************************************************
1743 * AddFontResourceA (GDI32.2)
1745 INT WINAPI AddFontResourceA( LPCSTR str )
1747 FIXME("(%s): stub! Read \"documentation/fonts\" how to install "
1748 "this font manually.\n", debugres_a(str));
1749 return 1;
1753 /***********************************************************************
1754 * AddFontResourceW (GDI32.4)
1756 INT WINAPI AddFontResourceW( LPCWSTR str )
1758 FIXME("(%s): stub! Read \"documentation/fonts\" how to install "
1759 "this font manually.\n", debugres_w(str));
1760 return 1;
1763 /***********************************************************************
1764 * RemoveFontResource16 (GDI.136)
1766 BOOL16 WINAPI RemoveFontResource16( SEGPTR str )
1768 FIXME("(%s): stub\n", debugres_a(PTR_SEG_TO_LIN(str)));
1769 return TRUE;
1773 /***********************************************************************
1774 * RemoveFontResourceA (GDI32.284)
1776 BOOL WINAPI RemoveFontResourceA( LPCSTR str )
1778 /* This is how it should look like */
1780 fontResource** ppfr;
1781 BOOL32 retVal = FALSE;
1783 EnterCriticalSection( &crtsc_fonts_X11 );
1784 for( ppfr = &fontList; *ppfr; ppfr = &(*ppfr)->next )
1785 if( !strcasecmp( (*ppfr)->lfFaceName, str ) )
1787 if(((*ppfr)->fr_flags & (FR_SOFTFONT | FR_SOFTRESOURCE)) &&
1788 (*ppfr)->hOwnerProcess == GetCurrentProcess() )
1790 if( (*ppfr)->fo_count )
1791 (*ppfr)->fr_flags |= FR_REMOVED;
1792 else
1793 XFONT_RemoveFontResource( ppfr );
1795 retVal = TRUE;
1797 LeaveCriticalSection( &crtsc_fonts_X11 );
1798 return retVal;
1800 FIXME("(%s): stub\n", debugres_a(str));
1801 return TRUE;
1805 /***********************************************************************
1806 * RemoveFontResourceW (GDI32.286)
1808 BOOL WINAPI RemoveFontResourceW( LPCWSTR str )
1810 FIXME("(%s): stub\n", debugres_w(str) );
1811 return TRUE;