4 * Copyright 1993 Alexandre Julliard
10 #include "wine/winestring.h"
15 #include "debugtools.h"
19 DECLARE_DEBUG_CHANNEL(font
)
20 DECLARE_DEBUG_CHANNEL(gdi
)
22 #define ENUM_UNICODE 0x00000001
26 LPLOGFONT16 lpLogFontParam
;
27 FONTENUMPROCEX16 lpEnumFunc
;
30 LPNEWTEXTMETRICEX16 lpTextMetric
;
31 LPENUMLOGFONTEX16 lpLogFont
;
38 LPLOGFONTW lpLogFontParam
;
39 FONTENUMPROCEXW lpEnumFunc
;
42 LPNEWTEXTMETRICEXW lpTextMetric
;
43 LPENUMLOGFONTEXW lpLogFont
;
48 * For TranslateCharsetInfo
50 #define FS(x) {{0,0,0,0},{0x1<<(x),0}}
51 #define MAXTCIINDEX 32
52 static CHARSETINFO FONT_tci
[MAXTCIINDEX
] = {
54 { ANSI_CHARSET
, 1252, FS(0)},
55 { EASTEUROPE_CHARSET
, 1250, FS(1)},
56 { RUSSIAN_CHARSET
, 1251, FS(2)},
57 { GREEK_CHARSET
, 1253, FS(3)},
58 { TURKISH_CHARSET
, 1254, FS(4)},
59 { HEBREW_CHARSET
, 1255, FS(5)},
60 { ARABIC_CHARSET
, 1256, FS(6)},
61 { BALTIC_CHARSET
, 1257, FS(7)},
62 /* reserved by ANSI */
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 { DEFAULT_CHARSET
, 0, FS(0)},
69 { DEFAULT_CHARSET
, 0, FS(0)},
70 { DEFAULT_CHARSET
, 0, FS(0)},
72 { THAI_CHARSET
, 874, FS(16)},
73 { SHIFTJIS_CHARSET
, 932, FS(17)},
74 { GB2312_CHARSET
, 936, FS(18)},
75 { HANGEUL_CHARSET
, 949, FS(19)},
76 { CHINESEBIG5_CHARSET
, 950, FS(20)},
77 { JOHAB_CHARSET
, 1361, FS(21)},
78 /* reserved for alternate ANSI and OEM */
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 { DEFAULT_CHARSET
, 0, FS(0)},
85 { DEFAULT_CHARSET
, 0, FS(0)},
86 { DEFAULT_CHARSET
, 0, FS(0)},
87 /* reserved for system */
88 { DEFAULT_CHARSET
, 0, FS(0)},
89 { DEFAULT_CHARSET
, 0, FS(0)},
92 /***********************************************************************
93 * LOGFONT conversion functions.
95 void FONT_LogFont32ATo16( const LOGFONTA
* font32
, LPLOGFONT16 font16
)
97 font16
->lfHeight
= font32
->lfHeight
;
98 font16
->lfWidth
= font32
->lfWidth
;
99 font16
->lfEscapement
= font32
->lfEscapement
;
100 font16
->lfOrientation
= font32
->lfOrientation
;
101 font16
->lfWeight
= font32
->lfWeight
;
102 font16
->lfItalic
= font32
->lfItalic
;
103 font16
->lfUnderline
= font32
->lfUnderline
;
104 font16
->lfStrikeOut
= font32
->lfStrikeOut
;
105 font16
->lfCharSet
= font32
->lfCharSet
;
106 font16
->lfOutPrecision
= font32
->lfOutPrecision
;
107 font16
->lfClipPrecision
= font32
->lfClipPrecision
;
108 font16
->lfQuality
= font32
->lfQuality
;
109 font16
->lfPitchAndFamily
= font32
->lfPitchAndFamily
;
110 lstrcpynA( font16
->lfFaceName
, font32
->lfFaceName
, LF_FACESIZE
);
113 void FONT_LogFont32WTo16( const LOGFONTW
* font32
, LPLOGFONT16 font16
)
115 font16
->lfHeight
= font32
->lfHeight
;
116 font16
->lfWidth
= font32
->lfWidth
;
117 font16
->lfEscapement
= font32
->lfEscapement
;
118 font16
->lfOrientation
= font32
->lfOrientation
;
119 font16
->lfWeight
= font32
->lfWeight
;
120 font16
->lfItalic
= font32
->lfItalic
;
121 font16
->lfUnderline
= font32
->lfUnderline
;
122 font16
->lfStrikeOut
= font32
->lfStrikeOut
;
123 font16
->lfCharSet
= font32
->lfCharSet
;
124 font16
->lfOutPrecision
= font32
->lfOutPrecision
;
125 font16
->lfClipPrecision
= font32
->lfClipPrecision
;
126 font16
->lfQuality
= font32
->lfQuality
;
127 font16
->lfPitchAndFamily
= font32
->lfPitchAndFamily
;
128 lstrcpynWtoA( font16
->lfFaceName
, font32
->lfFaceName
, LF_FACESIZE
);
131 void FONT_LogFont16To32A( const LPLOGFONT16 font16
, LPLOGFONTA font32
)
133 font32
->lfHeight
= font16
->lfHeight
;
134 font32
->lfWidth
= font16
->lfWidth
;
135 font32
->lfEscapement
= font16
->lfEscapement
;
136 font32
->lfOrientation
= font16
->lfOrientation
;
137 font32
->lfWeight
= font16
->lfWeight
;
138 font32
->lfItalic
= font16
->lfItalic
;
139 font32
->lfUnderline
= font16
->lfUnderline
;
140 font32
->lfStrikeOut
= font16
->lfStrikeOut
;
141 font32
->lfCharSet
= font16
->lfCharSet
;
142 font32
->lfOutPrecision
= font16
->lfOutPrecision
;
143 font32
->lfClipPrecision
= font16
->lfClipPrecision
;
144 font32
->lfQuality
= font16
->lfQuality
;
145 font32
->lfPitchAndFamily
= font16
->lfPitchAndFamily
;
146 lstrcpynA( font32
->lfFaceName
, font16
->lfFaceName
, LF_FACESIZE
);
149 void FONT_LogFont16To32W( const LPLOGFONT16 font16
, LPLOGFONTW font32
)
151 font32
->lfHeight
= font16
->lfHeight
;
152 font32
->lfWidth
= font16
->lfWidth
;
153 font32
->lfEscapement
= font16
->lfEscapement
;
154 font32
->lfOrientation
= font16
->lfOrientation
;
155 font32
->lfWeight
= font16
->lfWeight
;
156 font32
->lfItalic
= font16
->lfItalic
;
157 font32
->lfUnderline
= font16
->lfUnderline
;
158 font32
->lfStrikeOut
= font16
->lfStrikeOut
;
159 font32
->lfCharSet
= font16
->lfCharSet
;
160 font32
->lfOutPrecision
= font16
->lfOutPrecision
;
161 font32
->lfClipPrecision
= font16
->lfClipPrecision
;
162 font32
->lfQuality
= font16
->lfQuality
;
163 font32
->lfPitchAndFamily
= font16
->lfPitchAndFamily
;
164 lstrcpynAtoW( font32
->lfFaceName
, font16
->lfFaceName
, LF_FACESIZE
);
167 void FONT_EnumLogFontEx16To32A( const LPENUMLOGFONTEX16 font16
, LPENUMLOGFONTEXA font32
)
169 FONT_LogFont16To32A( (LPLOGFONT16
)font16
, (LPLOGFONTA
)font32
);
170 lstrcpynA( font32
->elfFullName
, font16
->elfFullName
, LF_FULLFACESIZE
);
171 lstrcpynA( font32
->elfStyle
, font16
->elfStyle
, LF_FACESIZE
);
172 lstrcpynA( font32
->elfScript
, font16
->elfScript
, LF_FACESIZE
);
175 void FONT_EnumLogFontEx16To32W( const LPENUMLOGFONTEX16 font16
, LPENUMLOGFONTEXW font32
)
177 FONT_LogFont16To32W( (LPLOGFONT16
)font16
, (LPLOGFONTW
)font32
);
178 lstrcpynAtoW( font32
->elfFullName
, font16
->elfFullName
, LF_FULLFACESIZE
);
179 lstrcpynAtoW( font32
->elfStyle
, font16
->elfStyle
, LF_FACESIZE
);
180 lstrcpynAtoW( font32
->elfScript
, font16
->elfScript
, LF_FACESIZE
);
183 /***********************************************************************
184 * TEXTMETRIC conversion functions.
186 void FONT_TextMetric32Ato16(const LPTEXTMETRICA ptm32
, LPTEXTMETRIC16 ptm16
)
188 ptm16
->tmHeight
= ptm32
->tmHeight
;
189 ptm16
->tmAscent
= ptm32
->tmAscent
;
190 ptm16
->tmDescent
= ptm32
->tmDescent
;
191 ptm16
->tmInternalLeading
= ptm32
->tmInternalLeading
;
192 ptm16
->tmExternalLeading
= ptm32
->tmExternalLeading
;
193 ptm16
->tmAveCharWidth
= ptm32
->tmAveCharWidth
;
194 ptm16
->tmMaxCharWidth
= ptm32
->tmMaxCharWidth
;
195 ptm16
->tmWeight
= ptm32
->tmWeight
;
196 ptm16
->tmOverhang
= ptm32
->tmOverhang
;
197 ptm16
->tmDigitizedAspectX
= ptm32
->tmDigitizedAspectX
;
198 ptm16
->tmDigitizedAspectY
= ptm32
->tmDigitizedAspectY
;
199 ptm16
->tmFirstChar
= ptm32
->tmFirstChar
;
200 ptm16
->tmLastChar
= ptm32
->tmLastChar
;
201 ptm16
->tmDefaultChar
= ptm32
->tmDefaultChar
;
202 ptm16
->tmBreakChar
= ptm32
->tmBreakChar
;
203 ptm16
->tmItalic
= ptm32
->tmItalic
;
204 ptm16
->tmUnderlined
= ptm32
->tmUnderlined
;
205 ptm16
->tmStruckOut
= ptm32
->tmStruckOut
;
206 ptm16
->tmPitchAndFamily
= ptm32
->tmPitchAndFamily
;
207 ptm16
->tmCharSet
= ptm32
->tmCharSet
;
210 void FONT_TextMetric32Wto16(const LPTEXTMETRICW ptm32
, LPTEXTMETRIC16 ptm16
)
212 ptm16
->tmHeight
= ptm32
->tmHeight
;
213 ptm16
->tmAscent
= ptm32
->tmAscent
;
214 ptm16
->tmDescent
= ptm32
->tmDescent
;
215 ptm16
->tmInternalLeading
= ptm32
->tmInternalLeading
;
216 ptm16
->tmExternalLeading
= ptm32
->tmExternalLeading
;
217 ptm16
->tmAveCharWidth
= ptm32
->tmAveCharWidth
;
218 ptm16
->tmMaxCharWidth
= ptm32
->tmMaxCharWidth
;
219 ptm16
->tmWeight
= ptm32
->tmWeight
;
220 ptm16
->tmOverhang
= ptm32
->tmOverhang
;
221 ptm16
->tmDigitizedAspectX
= ptm32
->tmDigitizedAspectX
;
222 ptm16
->tmDigitizedAspectY
= ptm32
->tmDigitizedAspectY
;
223 ptm16
->tmFirstChar
= ptm32
->tmFirstChar
;
224 ptm16
->tmLastChar
= ptm32
->tmLastChar
;
225 ptm16
->tmDefaultChar
= ptm32
->tmDefaultChar
;
226 ptm16
->tmBreakChar
= ptm32
->tmBreakChar
;
227 ptm16
->tmItalic
= ptm32
->tmItalic
;
228 ptm16
->tmUnderlined
= ptm32
->tmUnderlined
;
229 ptm16
->tmStruckOut
= ptm32
->tmStruckOut
;
230 ptm16
->tmPitchAndFamily
= ptm32
->tmPitchAndFamily
;
231 ptm16
->tmCharSet
= ptm32
->tmCharSet
;
234 void FONT_TextMetric16to32A(const LPTEXTMETRIC16 ptm16
, LPTEXTMETRICA ptm32
)
236 ptm32
->tmHeight
= ptm16
->tmHeight
;
237 ptm32
->tmAscent
= ptm16
->tmAscent
;
238 ptm32
->tmDescent
= ptm16
->tmDescent
;
239 ptm32
->tmInternalLeading
= ptm16
->tmInternalLeading
;
240 ptm32
->tmExternalLeading
= ptm16
->tmExternalLeading
;
241 ptm32
->tmAveCharWidth
= ptm16
->tmAveCharWidth
;
242 ptm32
->tmMaxCharWidth
= ptm16
->tmMaxCharWidth
;
243 ptm32
->tmWeight
= ptm16
->tmWeight
;
244 ptm32
->tmOverhang
= ptm16
->tmOverhang
;
245 ptm32
->tmDigitizedAspectX
= ptm16
->tmDigitizedAspectX
;
246 ptm32
->tmDigitizedAspectY
= ptm16
->tmDigitizedAspectY
;
247 ptm32
->tmFirstChar
= ptm16
->tmFirstChar
;
248 ptm32
->tmLastChar
= ptm16
->tmLastChar
;
249 ptm32
->tmDefaultChar
= ptm16
->tmDefaultChar
;
250 ptm32
->tmBreakChar
= ptm16
->tmBreakChar
;
251 ptm32
->tmItalic
= ptm16
->tmItalic
;
252 ptm32
->tmUnderlined
= ptm16
->tmUnderlined
;
253 ptm32
->tmStruckOut
= ptm16
->tmStruckOut
;
254 ptm32
->tmPitchAndFamily
= ptm16
->tmPitchAndFamily
;
255 ptm32
->tmCharSet
= ptm16
->tmCharSet
;
258 void FONT_TextMetric16to32W(const LPTEXTMETRIC16 ptm16
, LPTEXTMETRICW ptm32
)
260 ptm32
->tmHeight
= ptm16
->tmHeight
;
261 ptm32
->tmAscent
= ptm16
->tmAscent
;
262 ptm32
->tmDescent
= ptm16
->tmDescent
;
263 ptm32
->tmInternalLeading
= ptm16
->tmInternalLeading
;
264 ptm32
->tmExternalLeading
= ptm16
->tmExternalLeading
;
265 ptm32
->tmAveCharWidth
= ptm16
->tmAveCharWidth
;
266 ptm32
->tmMaxCharWidth
= ptm16
->tmMaxCharWidth
;
267 ptm32
->tmWeight
= ptm16
->tmWeight
;
268 ptm32
->tmOverhang
= ptm16
->tmOverhang
;
269 ptm32
->tmDigitizedAspectX
= ptm16
->tmDigitizedAspectX
;
270 ptm32
->tmDigitizedAspectY
= ptm16
->tmDigitizedAspectY
;
271 ptm32
->tmFirstChar
= ptm16
->tmFirstChar
;
272 ptm32
->tmLastChar
= ptm16
->tmLastChar
;
273 ptm32
->tmDefaultChar
= ptm16
->tmDefaultChar
;
274 ptm32
->tmBreakChar
= ptm16
->tmBreakChar
;
275 ptm32
->tmItalic
= ptm16
->tmItalic
;
276 ptm32
->tmUnderlined
= ptm16
->tmUnderlined
;
277 ptm32
->tmStruckOut
= ptm16
->tmStruckOut
;
278 ptm32
->tmPitchAndFamily
= ptm16
->tmPitchAndFamily
;
279 ptm32
->tmCharSet
= ptm16
->tmCharSet
;
282 void FONT_TextMetric32Ato32W(const LPTEXTMETRICA ptm32A
, LPTEXTMETRICW ptm32W
)
284 ptm32W
->tmHeight
= ptm32A
->tmHeight
;
285 ptm32W
->tmAscent
= ptm32A
->tmAscent
;
286 ptm32W
->tmDescent
= ptm32A
->tmDescent
;
287 ptm32W
->tmInternalLeading
= ptm32A
->tmInternalLeading
;
288 ptm32W
->tmExternalLeading
= ptm32A
->tmExternalLeading
;
289 ptm32W
->tmAveCharWidth
= ptm32A
->tmAveCharWidth
;
290 ptm32W
->tmMaxCharWidth
= ptm32A
->tmMaxCharWidth
;
291 ptm32W
->tmWeight
= ptm32A
->tmWeight
;
292 ptm32W
->tmOverhang
= ptm32A
->tmOverhang
;
293 ptm32W
->tmDigitizedAspectX
= ptm32A
->tmDigitizedAspectX
;
294 ptm32W
->tmDigitizedAspectY
= ptm32A
->tmDigitizedAspectY
;
295 ptm32W
->tmFirstChar
= ptm32A
->tmFirstChar
;
296 ptm32W
->tmLastChar
= ptm32A
->tmLastChar
;
297 ptm32W
->tmDefaultChar
= ptm32A
->tmDefaultChar
;
298 ptm32W
->tmBreakChar
= ptm32A
->tmBreakChar
;
299 ptm32W
->tmItalic
= ptm32A
->tmItalic
;
300 ptm32W
->tmUnderlined
= ptm32A
->tmUnderlined
;
301 ptm32W
->tmStruckOut
= ptm32A
->tmStruckOut
;
302 ptm32W
->tmPitchAndFamily
= ptm32A
->tmPitchAndFamily
;
303 ptm32W
->tmCharSet
= ptm32A
->tmCharSet
;
306 /***********************************************************************
307 * CreateFontIndirect16 (GDI.57)
309 HFONT16 WINAPI
CreateFontIndirect16( const LOGFONT16
*font
)
315 hFont
= GDI_AllocObject( sizeof(FONTOBJ
), FONT_MAGIC
);
319 fontPtr
= (FONTOBJ
*) GDI_HEAP_LOCK( hFont
);
320 memcpy( &fontPtr
->logfont
, font
, sizeof(LOGFONT16
) );
322 TRACE_(font
)("(%i %i %i %i) '%s' %s %s => %04x\n",
323 font
->lfHeight
, font
->lfWidth
,
324 font
->lfEscapement
, font
->lfOrientation
,
325 font
->lfFaceName
? font
->lfFaceName
: "NULL",
326 font
->lfWeight
> 400 ? "Bold" : "",
327 font
->lfItalic
? "Italic" : "",
330 if (font
->lfEscapement
!= font
->lfOrientation
) {
331 /* this should really depend on whether GM_ADVANCED is set */
332 fontPtr
->logfont
.lfOrientation
= fontPtr
->logfont
.lfEscapement
;
334 "orientation angle %f set to escapement angle %f for new font %04x\n",
335 font
->lfOrientation
/10., font
->lfEscapement
/10., hFont
);
337 GDI_HEAP_UNLOCK( hFont
);
340 else WARN_(font
)("(NULL) => NULL\n");
345 /***********************************************************************
346 * CreateFontIndirectA (GDI32.44)
348 HFONT WINAPI
CreateFontIndirectA( const LOGFONTA
*font
)
352 FONT_LogFont32ATo16( font
, &font16
);
353 return CreateFontIndirect16( &font16
);
356 /***********************************************************************
357 * CreateFontIndirectW (GDI32.45)
359 HFONT WINAPI
CreateFontIndirectW( const LOGFONTW
*font
)
363 FONT_LogFont32WTo16( font
, &font16
);
364 return CreateFontIndirect16( &font16
);
367 /***********************************************************************
368 * CreateFont16 (GDI.56)
370 HFONT16 WINAPI
CreateFont16(INT16 height
, INT16 width
, INT16 esc
, INT16 orient
,
371 INT16 weight
, BYTE italic
, BYTE underline
,
372 BYTE strikeout
, BYTE charset
, BYTE outpres
,
373 BYTE clippres
, BYTE quality
, BYTE pitch
,
378 TRACE_(font
)("('%s',%d,%d)\n",
379 (name
? name
: "(null)") , height
, width
);
381 logfont
.lfHeight
= height
;
382 logfont
.lfWidth
= width
;
383 logfont
.lfEscapement
= esc
;
384 logfont
.lfOrientation
= orient
;
385 logfont
.lfWeight
= weight
;
386 logfont
.lfItalic
= italic
;
387 logfont
.lfUnderline
= underline
;
388 logfont
.lfStrikeOut
= strikeout
;
389 logfont
.lfCharSet
= charset
;
390 logfont
.lfOutPrecision
= outpres
;
391 logfont
.lfClipPrecision
= clippres
;
392 logfont
.lfQuality
= quality
;
393 logfont
.lfPitchAndFamily
= pitch
;
396 lstrcpynA(logfont
.lfFaceName
,name
,sizeof(logfont
.lfFaceName
));
398 logfont
.lfFaceName
[0] = '\0';
400 return CreateFontIndirect16( &logfont
);
403 /*************************************************************************
404 * CreateFontA (GDI32.43)
406 HFONT WINAPI
CreateFontA( INT height
, INT width
, INT esc
,
407 INT orient
, INT weight
, DWORD italic
,
408 DWORD underline
, DWORD strikeout
, DWORD charset
,
409 DWORD outpres
, DWORD clippres
, DWORD quality
,
410 DWORD pitch
, LPCSTR name
)
412 return (HFONT
)CreateFont16( height
, width
, esc
, orient
, weight
, italic
,
413 underline
, strikeout
, charset
, outpres
,
414 clippres
, quality
, pitch
, name
);
417 /*************************************************************************
418 * CreateFontW (GDI32.46)
420 HFONT WINAPI
CreateFontW( INT height
, INT width
, INT esc
,
421 INT orient
, INT weight
, DWORD italic
,
422 DWORD underline
, DWORD strikeout
, DWORD charset
,
423 DWORD outpres
, DWORD clippres
, DWORD quality
,
424 DWORD pitch
, LPCWSTR name
)
426 LPSTR namea
= HEAP_strdupWtoA( GetProcessHeap(), 0, name
);
427 HFONT ret
= (HFONT
)CreateFont16( height
, width
, esc
, orient
, weight
,
428 italic
, underline
, strikeout
, charset
,
429 outpres
, clippres
, quality
, pitch
,
431 if (namea
) HeapFree( GetProcessHeap(), 0, namea
);
436 /***********************************************************************
439 INT16
FONT_GetObject16( FONTOBJ
* font
, INT16 count
, LPSTR buffer
)
441 if (count
> sizeof(LOGFONT16
)) count
= sizeof(LOGFONT16
);
442 memcpy( buffer
, &font
->logfont
, count
);
446 /***********************************************************************
449 INT
FONT_GetObjectA( FONTOBJ
*font
, INT count
, LPSTR buffer
)
453 FONT_LogFont16To32A( &font
->logfont
, &fnt32
);
455 if (count
> sizeof(fnt32
)) count
= sizeof(fnt32
);
456 memcpy( buffer
, &fnt32
, count
);
459 /***********************************************************************
462 INT
FONT_GetObjectW( FONTOBJ
*font
, INT count
, LPSTR buffer
)
466 FONT_LogFont16To32W( &font
->logfont
, &fnt32
);
468 if (count
> sizeof(fnt32
)) count
= sizeof(fnt32
);
469 memcpy( buffer
, &fnt32
, count
);
474 /***********************************************************************
475 * FONT_EnumInstance16
477 * Called by the device driver layer to pass font info
478 * down to the application.
480 static INT
FONT_EnumInstance16( LPENUMLOGFONTEX16 plf
,
481 LPNEWTEXTMETRIC16 ptm
, UINT16 fType
, LPARAM lp
)
483 #define pfe ((fontEnum16*)lp)
484 if( pfe
->lpLogFontParam
->lfCharSet
== DEFAULT_CHARSET
||
485 pfe
->lpLogFontParam
->lfCharSet
== plf
->elfLogFont
.lfCharSet
)
487 memcpy( pfe
->lpLogFont
, plf
, sizeof(ENUMLOGFONT16
) );
488 memcpy( pfe
->lpTextMetric
, ptm
, sizeof(NEWTEXTMETRIC16
) );
490 return pfe
->lpEnumFunc( pfe
->segLogFont
, pfe
->segTextMetric
, fType
, (LPARAM
)(pfe
->lpData
) );
496 /***********************************************************************
499 static INT
FONT_EnumInstance( LPENUMLOGFONTEX16 plf
,
500 LPNEWTEXTMETRIC16 ptm
, UINT16 fType
, LPARAM lp
)
502 /* lfCharSet is at the same offset in both LOGFONT32A and LOGFONT32W */
504 #define pfe ((fontEnum32*)lp)
505 if( pfe
->lpLogFontParam
->lfCharSet
== DEFAULT_CHARSET
||
506 pfe
->lpLogFontParam
->lfCharSet
== plf
->elfLogFont
.lfCharSet
)
508 /* convert font metrics */
510 if( pfe
->dwFlags
& ENUM_UNICODE
)
512 FONT_EnumLogFontEx16To32W( plf
, pfe
->lpLogFont
);
513 FONT_TextMetric16to32W( (LPTEXTMETRIC16
)ptm
, (LPTEXTMETRICW
)(pfe
->lpTextMetric
) );
515 return pfe
->lpEnumFunc( pfe
->lpLogFont
, pfe
->lpTextMetric
, fType
, pfe
->lpData
);
519 ENUMLOGFONTEXA logfont
;
521 FONT_EnumLogFontEx16To32A( plf
, &logfont
);
522 FONT_TextMetric16to32A( (LPTEXTMETRIC16
)ptm
, (LPTEXTMETRICA
)pfe
->lpTextMetric
);
524 return pfe
->lpEnumFunc( (LPENUMLOGFONTEXW
)&logfont
,
525 pfe
->lpTextMetric
, fType
, pfe
->lpData
);
532 /***********************************************************************
533 * EnumFontFamiliesEx16 (GDI.613)
535 INT16 WINAPI
EnumFontFamiliesEx16( HDC16 hDC
, LPLOGFONT16 plf
,
536 FONTENUMPROCEX16 efproc
, LPARAM lParam
,
540 DC
* dc
= (DC
*) GDI_GetObjPtr( hDC
, DC_MAGIC
);
542 if( dc
&& dc
->funcs
->pEnumDeviceFonts
)
544 LPNEWTEXTMETRICEX16 lptm16
= SEGPTR_ALLOC( sizeof(NEWTEXTMETRICEX16
) );
547 LPENUMLOGFONTEX16 lplf16
= SEGPTR_ALLOC( sizeof(ENUMLOGFONTEX16
) );
552 fe16
.lpLogFontParam
= plf
;
553 fe16
.lpEnumFunc
= efproc
;
554 fe16
.lpData
= lParam
;
556 fe16
.lpTextMetric
= lptm16
;
557 fe16
.lpLogFont
= lplf16
;
558 fe16
.segTextMetric
= SEGPTR_GET(lptm16
);
559 fe16
.segLogFont
= SEGPTR_GET(lplf16
);
561 retVal
= dc
->funcs
->pEnumDeviceFonts( dc
, plf
, FONT_EnumInstance16
, (LPARAM
)&fe16
);
571 /***********************************************************************
572 * FONT_EnumFontFamiliesEx
574 static INT
FONT_EnumFontFamiliesEx( HDC hDC
, LPLOGFONTW plf
, FONTENUMPROCEXW efproc
,
575 LPARAM lParam
, DWORD dwUnicode
)
577 DC
* dc
= (DC
*) GDI_GetObjPtr( hDC
, DC_MAGIC
);
579 if( dc
&& dc
->funcs
->pEnumDeviceFonts
)
582 NEWTEXTMETRICEXW tm32w
;
583 ENUMLOGFONTEXW lf32w
;
586 fe32
.lpLogFontParam
= plf
;
587 fe32
.lpEnumFunc
= efproc
;
588 fe32
.lpData
= lParam
;
590 fe32
.lpTextMetric
= &tm32w
;
591 fe32
.lpLogFont
= &lf32w
;
592 fe32
.dwFlags
= dwUnicode
;
594 /* the only difference between LOGFONT32A and LOGFONT32W is in the lfFaceName */
596 if( plf
->lfFaceName
[0] )
599 lstrcpynWtoA( lf16
.lfFaceName
, plf
->lfFaceName
, LF_FACESIZE
);
601 lstrcpynA( lf16
.lfFaceName
, (LPCSTR
)plf
->lfFaceName
, LF_FACESIZE
);
603 else lf16
.lfFaceName
[0] = '\0';
604 lf16
.lfCharSet
= plf
->lfCharSet
;
606 return dc
->funcs
->pEnumDeviceFonts( dc
, &lf16
, FONT_EnumInstance
, (LPARAM
)&fe32
);
611 /***********************************************************************
612 * EnumFontFamiliesExW (GDI32.82)
614 INT WINAPI
EnumFontFamiliesExW( HDC hDC
, LPLOGFONTW plf
,
615 FONTENUMPROCEXW efproc
,
616 LPARAM lParam
, DWORD dwFlags
)
618 return FONT_EnumFontFamiliesEx( hDC
, plf
, efproc
, lParam
, ENUM_UNICODE
);
621 /***********************************************************************
622 * EnumFontFamiliesExA (GDI32.81)
624 INT WINAPI
EnumFontFamiliesExA( HDC hDC
, LPLOGFONTA plf
,
625 FONTENUMPROCEXA efproc
,
626 LPARAM lParam
, DWORD dwFlags
)
628 return FONT_EnumFontFamiliesEx( hDC
, (LPLOGFONTW
)plf
,
629 (FONTENUMPROCEXW
)efproc
, lParam
, 0);
632 /***********************************************************************
633 * EnumFontFamilies16 (GDI.330)
635 INT16 WINAPI
EnumFontFamilies16( HDC16 hDC
, LPCSTR lpFamily
,
636 FONTENUMPROC16 efproc
, LPARAM lpData
)
640 lf
.lfCharSet
= DEFAULT_CHARSET
;
641 if( lpFamily
) lstrcpynA( lf
.lfFaceName
, lpFamily
, LF_FACESIZE
);
642 else lf
.lfFaceName
[0] = '\0';
644 return EnumFontFamiliesEx16( hDC
, &lf
, (FONTENUMPROCEX16
)efproc
, lpData
, 0 );
647 /***********************************************************************
648 * EnumFontFamiliesA (GDI32.80)
650 INT WINAPI
EnumFontFamiliesA( HDC hDC
, LPCSTR lpFamily
,
651 FONTENUMPROCA efproc
, LPARAM lpData
)
655 lf
.lfCharSet
= DEFAULT_CHARSET
;
656 if( lpFamily
) lstrcpynA( lf
.lfFaceName
, lpFamily
, LF_FACESIZE
);
657 else lf
.lfFaceName
[0] = lf
.lfFaceName
[1] = '\0';
659 return FONT_EnumFontFamiliesEx( hDC
, (LPLOGFONTW
)&lf
,
660 (FONTENUMPROCEXW
)efproc
, lpData
, 0 );
663 /***********************************************************************
664 * EnumFontFamiliesW (GDI32.83)
666 INT WINAPI
EnumFontFamiliesW( HDC hDC
, LPCWSTR lpFamily
,
667 FONTENUMPROCW efproc
, LPARAM lpData
)
671 lf
.lfCharSet
= DEFAULT_CHARSET
;
672 if( lpFamily
) lstrcpynW( lf
.lfFaceName
, lpFamily
, LF_FACESIZE
);
673 else lf
.lfFaceName
[0] = 0;
675 return FONT_EnumFontFamiliesEx( hDC
, &lf
, (FONTENUMPROCEXW
)efproc
,
676 lpData
, ENUM_UNICODE
);
679 /***********************************************************************
680 * EnumFonts16 (GDI.70)
682 INT16 WINAPI
EnumFonts16( HDC16 hDC
, LPCSTR lpName
, FONTENUMPROC16 efproc
,
685 return EnumFontFamilies16( hDC
, lpName
, (FONTENUMPROCEX16
)efproc
, lpData
);
688 /***********************************************************************
689 * EnumFontsA (GDI32.84)
691 INT WINAPI
EnumFontsA( HDC hDC
, LPCSTR lpName
, FONTENUMPROCA efproc
,
694 return EnumFontFamiliesA( hDC
, lpName
, efproc
, lpData
);
697 /***********************************************************************
698 * EnumFontsW (GDI32.85)
700 INT WINAPI
EnumFontsW( HDC hDC
, LPCWSTR lpName
, FONTENUMPROCW efproc
,
703 return EnumFontFamiliesW( hDC
, lpName
, efproc
, lpData
);
707 /***********************************************************************
708 * GetTextCharacterExtra16 (GDI.89)
710 INT16 WINAPI
GetTextCharacterExtra16( HDC16 hdc
)
712 DC
* dc
= (DC
*) GDI_GetObjPtr( hdc
, DC_MAGIC
);
714 return abs( (dc
->w
.charExtra
* dc
->wndExtX
+ dc
->vportExtX
/ 2)
719 /***********************************************************************
720 * GetTextCharacterExtra (GDI32.225)
722 INT WINAPI
GetTextCharacterExtra( HDC hdc
)
724 DC
* dc
= (DC
*) GDI_GetObjPtr( hdc
, DC_MAGIC
);
726 return abs( (dc
->w
.charExtra
* dc
->wndExtX
+ dc
->vportExtX
/ 2)
731 /***********************************************************************
732 * SetTextCharacterExtra16 (GDI.8)
734 INT16 WINAPI
SetTextCharacterExtra16( HDC16 hdc
, INT16 extra
)
736 return (INT16
)SetTextCharacterExtra( hdc
, extra
);
740 /***********************************************************************
741 * SetTextCharacterExtra (GDI32.337)
743 INT WINAPI
SetTextCharacterExtra( HDC hdc
, INT extra
)
746 DC
* dc
= DC_GetDCPtr( hdc
);
748 if (dc
->funcs
->pSetTextCharacterExtra
)
749 return dc
->funcs
->pSetTextCharacterExtra( dc
, extra
);
750 extra
= (extra
* dc
->vportExtX
+ dc
->wndExtX
/ 2) / dc
->wndExtX
;
751 prev
= dc
->w
.charExtra
;
752 dc
->w
.charExtra
= abs(extra
);
753 return (prev
* dc
->wndExtX
+ dc
->vportExtX
/ 2) / dc
->vportExtX
;
757 /***********************************************************************
758 * SetTextJustification16 (GDI.10)
760 INT16 WINAPI
SetTextJustification16( HDC16 hdc
, INT16 extra
, INT16 breaks
)
762 return SetTextJustification( hdc
, extra
, breaks
);
766 /***********************************************************************
767 * SetTextJustification (GDI32.339)
769 BOOL WINAPI
SetTextJustification( HDC hdc
, INT extra
, INT breaks
)
771 DC
* dc
= DC_GetDCPtr( hdc
);
773 if (dc
->funcs
->pSetTextJustification
)
774 return dc
->funcs
->pSetTextJustification( dc
, extra
, breaks
);
776 extra
= abs((extra
* dc
->vportExtX
+ dc
->wndExtX
/ 2) / dc
->wndExtX
);
777 if (!extra
) breaks
= 0;
778 dc
->w
.breakTotalExtra
= extra
;
779 dc
->w
.breakCount
= breaks
;
782 dc
->w
.breakExtra
= extra
/ breaks
;
783 dc
->w
.breakRem
= extra
- (dc
->w
.breakCount
* dc
->w
.breakExtra
);
787 dc
->w
.breakExtra
= 0;
794 /***********************************************************************
795 * GetTextFace16 (GDI.92)
797 INT16 WINAPI
GetTextFace16( HDC16 hdc
, INT16 count
, LPSTR name
)
799 return GetTextFaceA(hdc
,count
,name
);
802 /***********************************************************************
803 * GetTextFaceA (GDI32.234)
805 INT WINAPI
GetTextFaceA( HDC hdc
, INT count
, LPSTR name
)
809 DC
* dc
= (DC
*) GDI_GetObjPtr( hdc
, DC_MAGIC
);
811 if (!(font
= (FONTOBJ
*) GDI_GetObjPtr( dc
->w
.hFont
, FONT_MAGIC
)))
814 lstrcpynA( name
, font
->logfont
.lfFaceName
, count
);
815 GDI_HEAP_UNLOCK( dc
->w
.hFont
);
819 return strlen(font
->logfont
.lfFaceName
) + 1;
822 /***********************************************************************
823 * GetTextFaceW (GDI32.235)
825 INT WINAPI
GetTextFaceW( HDC hdc
, INT count
, LPWSTR name
)
827 LPSTR nameA
= HeapAlloc( GetProcessHeap(), 0, count
);
828 INT res
= GetTextFaceA(hdc
,count
,nameA
);
829 lstrcpyAtoW( name
, nameA
);
830 HeapFree( GetProcessHeap(), 0, nameA
);
835 /***********************************************************************
836 * GetTextExtent16 (GDI.91)
838 DWORD WINAPI
GetTextExtent16( HDC16 hdc
, LPCSTR str
, INT16 count
)
841 if (!GetTextExtentPoint16( hdc
, str
, count
, &size
)) return 0;
842 return MAKELONG( size
.cx
, size
.cy
);
846 /***********************************************************************
847 * GetTextExtentPoint16 (GDI.471)
849 * FIXME: Should this have a bug for compatibility?
850 * Original Windows versions of GetTextExtentPoint{A,W} have documented
851 * bugs (-> MSDN KB q147647.txt).
853 BOOL16 WINAPI
GetTextExtentPoint16( HDC16 hdc
, LPCSTR str
, INT16 count
,
857 BOOL ret
= GetTextExtentPoint32A( hdc
, str
, count
, &size32
);
858 CONV_SIZE32TO16( &size32
, size
);
863 /***********************************************************************
864 * GetTextExtentPoint32A (GDI32.230)
866 BOOL WINAPI
GetTextExtentPoint32A( HDC hdc
, LPCSTR str
, INT count
,
869 DC
* dc
= (DC
*) GDI_GetObjPtr( hdc
, DC_MAGIC
);
872 if (!(dc
= (DC
*)GDI_GetObjPtr( hdc
, METAFILE_DC_MAGIC
)))
876 if (!dc
->funcs
->pGetTextExtentPoint
||
877 !dc
->funcs
->pGetTextExtentPoint( dc
, str
, count
, size
))
880 TRACE_(font
)("(%08x %s %d %p): returning %d,%d\n",
881 hdc
, debugstr_an (str
, count
), count
,
882 size
, size
->cx
, size
->cy
);
887 /***********************************************************************
888 * GetTextExtentPoint32W [GDI32.231] Computes width/height for a string
890 * Computes width and height of the specified string.
896 BOOL WINAPI
GetTextExtentPoint32W(
897 HDC hdc
, /* [in] Handle of device context */
898 LPCWSTR str
, /* [in] Address of text string */
899 INT count
, /* [in] Number of characters in string */
900 LPSIZE size
) /* [out] Address of structure for string size */
905 /* str may not be 0 terminated so we can't use HEAP_strdupWtoA.
906 * We allocate one more than we need so that lstrcpynWtoA can write a
907 * trailing 0 if it wants.
910 if(!count
) count
= lstrlenW(str
);
911 p
= HeapAlloc( GetProcessHeap(), 0, count
+1 );
912 lstrcpynWtoA(p
, str
, count
+1);
913 ret
= GetTextExtentPoint32A( hdc
, p
, count
, size
);
914 HeapFree( GetProcessHeap(), 0, p
);
919 /***********************************************************************
920 * GetTextExtentPointA (GDI32.232)
922 BOOL WINAPI
GetTextExtentPointA( HDC hdc
, LPCSTR str
, INT count
,
925 TRACE_(font
)("not bug compatible.\n");
926 return GetTextExtentPoint32A( hdc
, str
, count
, size
);
929 /***********************************************************************
930 * GetTextExtentPointW (GDI32.233)
932 BOOL WINAPI
GetTextExtentPointW( HDC hdc
, LPCWSTR str
, INT count
,
935 TRACE_(font
)("not bug compatible.\n");
936 return GetTextExtentPoint32W( hdc
, str
, count
, size
);
940 /***********************************************************************
941 * GetTextExtentExPointA (GDI32.228)
943 BOOL WINAPI
GetTextExtentExPointA( HDC hdc
, LPCSTR str
, INT count
,
944 INT maxExt
, LPINT lpnFit
,
945 LPINT alpDx
, LPSIZE size
)
947 int index
, nFit
, extent
;
949 DC
* dc
= (DC
*) GDI_GetObjPtr( hdc
, DC_MAGIC
);
953 if (!(dc
= (DC
*)GDI_GetObjPtr( hdc
, METAFILE_DC_MAGIC
)))
956 if (!dc
->funcs
->pGetTextExtentPoint
) return FALSE
;
958 size
->cx
= size
->cy
= nFit
= extent
= 0;
959 for(index
= 0; index
< count
; index
++)
961 if(!dc
->funcs
->pGetTextExtentPoint( dc
, str
, 1, &tSize
)) return FALSE
;
962 if( extent
+tSize
.cx
< maxExt
)
967 if( alpDx
) alpDx
[index
] = extent
;
968 if( tSize
.cy
> size
->cy
) size
->cy
= tSize
.cy
;
975 TRACE_(font
)("(%08x '%.*s' %d) returning %d %d %d\n",
976 hdc
,count
,str
,maxExt
,nFit
, size
->cx
,size
->cy
);
981 /***********************************************************************
982 * GetTextExtentExPointW (GDI32.229)
985 BOOL WINAPI
GetTextExtentExPointW( HDC hdc
, LPCWSTR str
, INT count
,
986 INT maxExt
, LPINT lpnFit
,
987 LPINT alpDx
, LPSIZE size
)
992 /* Docs say str should be 0 terminated here, but we'll use count just in case
995 if(!count
) count
= lstrlenW(str
);
996 p
= HeapAlloc( GetProcessHeap(), 0, count
+1 );
997 lstrcpynWtoA(p
, str
, count
+1);
998 ret
= GetTextExtentExPointA( hdc
, p
, count
, maxExt
,
999 lpnFit
, alpDx
, size
);
1000 HeapFree( GetProcessHeap(), 0, p
);
1004 /***********************************************************************
1005 * GetTextMetrics16 (GDI.93)
1007 BOOL16 WINAPI
GetTextMetrics16( HDC16 hdc
, TEXTMETRIC16
*metrics
)
1011 if (!GetTextMetricsA( (HDC
)hdc
, &tm32
)) return FALSE
;
1012 FONT_TextMetric32Ato16( &tm32
, metrics
);
1017 /***********************************************************************
1018 * GetTextMetricsA (GDI32.236)
1020 BOOL WINAPI
GetTextMetricsA( HDC hdc
, TEXTMETRICA
*metrics
)
1022 DC
* dc
= (DC
*) GDI_GetObjPtr( hdc
, DC_MAGIC
);
1025 if (!(dc
= (DC
*)GDI_GetObjPtr( hdc
, METAFILE_DC_MAGIC
)))
1029 if (!dc
->funcs
->pGetTextMetrics
||
1030 !dc
->funcs
->pGetTextMetrics( dc
, metrics
))
1033 /* device layer returns values in device units
1034 * therefore we have to convert them to logical */
1036 #define WDPTOLP(x) ((x<0)? \
1037 (-abs((x)*dc->wndExtX/dc->vportExtX)): \
1038 (abs((x)*dc->wndExtX/dc->vportExtX)))
1039 #define HDPTOLP(y) ((y<0)? \
1040 (-abs((y)*dc->wndExtY/dc->vportExtY)): \
1041 (abs((y)*dc->wndExtY/dc->vportExtY)))
1043 metrics
->tmHeight
= HDPTOLP(metrics
->tmHeight
);
1044 metrics
->tmAscent
= HDPTOLP(metrics
->tmAscent
);
1045 metrics
->tmDescent
= HDPTOLP(metrics
->tmDescent
);
1046 metrics
->tmInternalLeading
= HDPTOLP(metrics
->tmInternalLeading
);
1047 metrics
->tmExternalLeading
= HDPTOLP(metrics
->tmExternalLeading
);
1048 metrics
->tmAveCharWidth
= WDPTOLP(metrics
->tmAveCharWidth
);
1049 metrics
->tmMaxCharWidth
= WDPTOLP(metrics
->tmMaxCharWidth
);
1050 metrics
->tmOverhang
= WDPTOLP(metrics
->tmOverhang
);
1052 TRACE_(font
)("text metrics:\n"
1053 " Weight = %03li\t FirstChar = %03i\t AveCharWidth = %li\n"
1054 " Italic = % 3i\t LastChar = %03i\t\t MaxCharWidth = %li\n"
1055 " UnderLined = %01i\t DefaultChar = %03i\t Overhang = %li\n"
1056 " StruckOut = %01i\t BreakChar = %03i\t CharSet = %i\n"
1057 " PitchAndFamily = %02x\n"
1058 " --------------------\n"
1059 " InternalLeading = %li\n"
1063 metrics
->tmWeight
, metrics
->tmFirstChar
, metrics
->tmAveCharWidth
,
1064 metrics
->tmItalic
, metrics
->tmLastChar
, metrics
->tmMaxCharWidth
,
1065 metrics
->tmUnderlined
, metrics
->tmDefaultChar
, metrics
->tmOverhang
,
1066 metrics
->tmStruckOut
, metrics
->tmBreakChar
, metrics
->tmCharSet
,
1067 metrics
->tmPitchAndFamily
,
1068 metrics
->tmInternalLeading
,
1071 metrics
->tmHeight
);
1076 /***********************************************************************
1077 * GetTextMetricsW (GDI32.237)
1079 BOOL WINAPI
GetTextMetricsW( HDC hdc
, TEXTMETRICW
*metrics
)
1082 if (!GetTextMetricsA( (HDC16
)hdc
, &tm
)) return FALSE
;
1083 FONT_TextMetric32Ato32W( &tm
, metrics
);
1088 /***********************************************************************
1089 * GetOutlineTextMetrics16 [GDI.308] Gets metrics for TrueType fonts.
1092 * lpOTM should be LPOUTLINETEXTMETRIC
1095 * Success: Non-zero or size of required buffer
1098 UINT16 WINAPI
GetOutlineTextMetrics16(
1099 HDC16 hdc
, /* [in] Handle of device context */
1100 UINT16 cbData
, /* [in] Size of metric data array */
1101 LPOUTLINETEXTMETRIC16 lpOTM
) /* [out] Address of metric data array */
1103 FIXME_(font
)("(%04x,%04x,%p): stub\n", hdc
,cbData
,lpOTM
);
1108 /***********************************************************************
1109 * GetOutlineTextMetricsA [GDI.207] Gets metrics for TrueType fonts.
1113 * Success: Non-zero or size of required buffer
1116 UINT WINAPI
GetOutlineTextMetricsA(
1117 HDC hdc
, /* [in] Handle of device context */
1118 UINT cbData
, /* [in] Size of metric data array */
1119 LPOUTLINETEXTMETRICA lpOTM
) /* [out] Address of metric data array */
1124 LPTEXTMETRICA lptxtMetr
;
1131 lpOTM
= (LPOUTLINETEXTMETRICA
)HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY
,sizeof(OUTLINETEXTMETRICA
));
1132 rtn
= sizeof(OUTLINETEXTMETRICA
);
1136 cbData
= sizeof(*lpOTM
);
1140 lpOTM
->otmSize
= cbData
;
1142 lptxtMetr
=HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY
,sizeof(TEXTMETRICA
));
1144 if (!GetTextMetricsA(hdc
,lptxtMetr
))
1149 memcpy(&(lpOTM
->otmTextMetrics
),lptxtMetr
,sizeof(TEXTMETRICA
));
1152 HeapFree(GetProcessHeap(),HEAP_ZERO_MEMORY
,lptxtMetr
);
1154 lpOTM
->otmFilter
= 0;
1156 lpOTM
->otmPanoseNumber
.bFamilyType
= 0;
1157 lpOTM
->otmPanoseNumber
.bSerifStyle
= 0;
1158 lpOTM
->otmPanoseNumber
.bWeight
= 0;
1159 lpOTM
->otmPanoseNumber
.bProportion
= 0;
1160 lpOTM
->otmPanoseNumber
.bContrast
= 0;
1161 lpOTM
->otmPanoseNumber
.bStrokeVariation
= 0;
1162 lpOTM
->otmPanoseNumber
.bArmStyle
= 0;
1163 lpOTM
->otmPanoseNumber
.bLetterform
= 0;
1164 lpOTM
->otmPanoseNumber
.bMidline
= 0;
1165 lpOTM
->otmPanoseNumber
.bXHeight
= 0;
1167 lpOTM
->otmfsSelection
= 0;
1168 lpOTM
->otmfsType
= 0;
1171 Further fill of the structure not implemented,
1172 Needs real values for the structure members
1178 /***********************************************************************
1179 * GetOutlineTextMetricsW [GDI32.208]
1181 UINT WINAPI
GetOutlineTextMetricsW(
1182 HDC hdc
, /* [in] Handle of device context */
1183 UINT cbData
, /* [in] Size of metric data array */
1184 LPOUTLINETEXTMETRICW lpOTM
) /* [out] Address of metric data array */
1186 FIXME_(font
)("(%d,%d,%p): stub\n", hdc
, cbData
, lpOTM
);
1190 /***********************************************************************
1191 * GetCharWidth16 (GDI.350)
1193 BOOL16 WINAPI
GetCharWidth16( HDC16 hdc
, UINT16 firstChar
, UINT16 lastChar
,
1196 BOOL retVal
= FALSE
;
1198 if( firstChar
!= lastChar
)
1200 LPINT buf32
= (LPINT
)HeapAlloc(GetProcessHeap(), 0,
1201 sizeof(INT
)*(1 + (lastChar
- firstChar
)));
1204 LPINT obuf32
= buf32
;
1207 retVal
= GetCharWidth32A(hdc
, firstChar
, lastChar
, buf32
);
1210 for (i
= firstChar
; i
<= lastChar
; i
++)
1211 *buffer
++ = *buf32
++;
1213 HeapFree(GetProcessHeap(), 0, obuf32
);
1216 else /* happens quite often to warrant a special treatment */
1219 retVal
= GetCharWidth32A(hdc
, firstChar
, lastChar
, &chWidth
);
1226 /***********************************************************************
1227 * GetCharWidth32A (GDI32.155)
1229 BOOL WINAPI
GetCharWidth32A( HDC hdc
, UINT firstChar
, UINT lastChar
,
1233 DC
* dc
= (DC
*) GDI_GetObjPtr( hdc
, DC_MAGIC
);
1236 if (!(dc
= (DC
*)GDI_GetObjPtr( hdc
, METAFILE_DC_MAGIC
)))
1240 if (!dc
->funcs
->pGetCharWidth
||
1241 !dc
->funcs
->pGetCharWidth( dc
, firstChar
, lastChar
, buffer
))
1244 /* convert device units to logical */
1246 extra
= dc
->vportExtX
>> 1;
1247 for( i
= firstChar
; i
<= lastChar
; i
++, buffer
++ )
1248 *buffer
= (*buffer
* dc
->wndExtX
+ extra
) / dc
->vportExtX
;
1254 /***********************************************************************
1255 * GetCharWidth32W (GDI32.158)
1257 BOOL WINAPI
GetCharWidth32W( HDC hdc
, UINT firstChar
, UINT lastChar
,
1260 return GetCharWidth32A( hdc
, firstChar
, lastChar
, buffer
);
1265 /* FIXME: all following APIs *******************************************
1268 * SetMapperFlags16 (GDI.349)
1270 DWORD WINAPI
SetMapperFlags16( HDC16 hDC
, DWORD dwFlag
)
1272 return SetMapperFlags( hDC
, dwFlag
);
1276 /***********************************************************************
1277 * SetMapperFlags (GDI32.322)
1279 DWORD WINAPI
SetMapperFlags( HDC hDC
, DWORD dwFlag
)
1281 DC
*dc
= DC_GetDCPtr( hDC
);
1284 if(dc
->funcs
->pSetMapperFlags
)
1285 ret
= dc
->funcs
->pSetMapperFlags( dc
, dwFlag
);
1287 FIXME_(font
)("(0x%04x, 0x%08lx): stub - harmless\n", hDC
, dwFlag
);
1288 GDI_HEAP_UNLOCK( hDC
);
1292 /***********************************************************************
1293 * GetAspectRatioFilterEx16 (GDI.486)
1295 BOOL16 WINAPI
GetAspectRatioFilterEx16( HDC16 hdc
, LPSIZE16 pAspectRatio
)
1297 FIXME_(font
)("(%04x, %p): -- Empty Stub !\n",
1302 /***********************************************************************
1303 * GetAspectRatioFilterEx (GDI32.142)
1305 BOOL WINAPI
GetAspectRatioFilterEx( HDC hdc
, LPSIZE pAspectRatio
)
1307 FIXME_(font
)("(%04x, %p): -- Empty Stub !\n",
1312 /***********************************************************************
1313 * GetCharABCWidths16 (GDI.307)
1315 BOOL16 WINAPI
GetCharABCWidths16( HDC16 hdc
, UINT16 firstChar
, UINT16 lastChar
,
1319 if (!GetCharABCWidthsA( hdc
, firstChar
, lastChar
, &abc32
)) return FALSE
;
1320 abc
->abcA
= abc32
.abcA
;
1321 abc
->abcB
= abc32
.abcB
;
1322 abc
->abcC
= abc32
.abcC
;
1327 /***********************************************************************
1328 * GetCharABCWidthsA (GDI32.149)
1330 BOOL WINAPI
GetCharABCWidthsA(HDC hdc
, UINT firstChar
, UINT lastChar
,
1333 return GetCharABCWidthsW( hdc
, firstChar
, lastChar
, abc
);
1337 /******************************************************************************
1338 * GetCharABCWidthsW [GDI32.152] Retrieves widths of characters in range
1341 * hdc [I] Handle of device context
1342 * firstChar [I] First character in range to query
1343 * lastChar [I] Last character in range to query
1344 * abc [O] Address of character-width structure
1347 * Only works with TrueType fonts
1353 BOOL WINAPI
GetCharABCWidthsW( HDC hdc
, UINT firstChar
, UINT lastChar
,
1356 /* No TrueType fonts in Wine so far */
1357 FIXME_(font
)("(%04x,%04x,%04x,%p): stub\n", hdc
, firstChar
, lastChar
, abc
);
1362 /***********************************************************************
1363 * GetGlyphOutline16 (GDI.309)
1365 DWORD WINAPI
GetGlyphOutline16( HDC16 hdc
, UINT16 uChar
, UINT16 fuFormat
,
1366 LPGLYPHMETRICS16 lpgm
, DWORD cbBuffer
,
1367 LPVOID lpBuffer
, const MAT2
*lpmat2
)
1369 FIXME_(font
)("(%04x, '%c', %04x, %p, %ld, %p, %p): stub\n",
1370 hdc
, uChar
, fuFormat
, lpgm
, cbBuffer
, lpBuffer
, lpmat2
);
1371 return (DWORD
)-1; /* failure */
1375 /***********************************************************************
1376 * GetGlyphOutlineA (GDI32.186)
1378 DWORD WINAPI
GetGlyphOutlineA( HDC hdc
, UINT uChar
, UINT fuFormat
,
1379 LPGLYPHMETRICS lpgm
, DWORD cbBuffer
,
1380 LPVOID lpBuffer
, const MAT2
*lpmat2
)
1382 FIXME_(font
)("(%04x, '%c', %04x, %p, %ld, %p, %p): stub\n",
1383 hdc
, uChar
, fuFormat
, lpgm
, cbBuffer
, lpBuffer
, lpmat2
);
1384 return (DWORD
)-1; /* failure */
1387 /***********************************************************************
1388 * GetGlyphOutlineW (GDI32.187)
1390 DWORD WINAPI
GetGlyphOutlineW( HDC hdc
, UINT uChar
, UINT fuFormat
,
1391 LPGLYPHMETRICS lpgm
, DWORD cbBuffer
,
1392 LPVOID lpBuffer
, const MAT2
*lpmat2
)
1394 FIXME_(font
)("(%04x, '%c', %04x, %p, %ld, %p, %p): stub\n",
1395 hdc
, uChar
, fuFormat
, lpgm
, cbBuffer
, lpBuffer
, lpmat2
);
1396 return (DWORD
)-1; /* failure */
1399 /***********************************************************************
1400 * CreateScalableFontResource16 (GDI.310)
1402 BOOL16 WINAPI
CreateScalableFontResource16( UINT16 fHidden
,
1403 LPCSTR lpszResourceFile
,
1404 LPCSTR fontFile
, LPCSTR path
)
1406 return CreateScalableFontResourceA( fHidden
, lpszResourceFile
,
1410 /***********************************************************************
1411 * CreateScalableFontResourceA (GDI32.62)
1413 BOOL WINAPI
CreateScalableFontResourceA( DWORD fHidden
,
1414 LPCSTR lpszResourceFile
,
1415 LPCSTR lpszFontFile
,
1416 LPCSTR lpszCurrentPath
)
1418 /* fHidden=1 - only visible for the calling app, read-only, not
1419 * enumbered with EnumFonts/EnumFontFamilies
1420 * lpszCurrentPath can be NULL
1422 FIXME_(font
)("(%ld,%s,%s,%s): stub\n",
1423 fHidden
, lpszResourceFile
, lpszFontFile
, lpszCurrentPath
);
1424 return FALSE
; /* create failed */
1427 /***********************************************************************
1428 * CreateScalableFontResourceW (GDI32.63)
1430 BOOL WINAPI
CreateScalableFontResourceW( DWORD fHidden
,
1431 LPCWSTR lpszResourceFile
,
1432 LPCWSTR lpszFontFile
,
1433 LPCWSTR lpszCurrentPath
)
1435 FIXME_(font
)("(%ld,%p,%p,%p): stub\n",
1436 fHidden
, lpszResourceFile
, lpszFontFile
, lpszCurrentPath
);
1437 return FALSE
; /* create failed */
1441 /*************************************************************************
1442 * GetRasterizerCaps16 (GDI.313)
1444 BOOL16 WINAPI
GetRasterizerCaps16( LPRASTERIZER_STATUS lprs
, UINT16 cbNumBytes
)
1446 return GetRasterizerCaps( lprs
, cbNumBytes
);
1450 /*************************************************************************
1451 * GetRasterizerCaps (GDI32.216)
1453 BOOL WINAPI
GetRasterizerCaps( LPRASTERIZER_STATUS lprs
, UINT cbNumBytes
)
1455 lprs
->nSize
= sizeof(RASTERIZER_STATUS
);
1456 lprs
->wFlags
= TT_AVAILABLE
|TT_ENABLED
;
1457 lprs
->nLanguageID
= 0;
1462 /*************************************************************************
1463 * GetKerningPairs16 (GDI.332)
1465 INT16 WINAPI
GetKerningPairs16( HDC16 hDC
, INT16 cPairs
,
1466 LPKERNINGPAIR16 lpKerningPairs
)
1468 /* At this time kerning is ignored (set to 0) */
1470 FIXME_(font
)("(%x,%d,%p): almost empty stub!\n",
1471 hDC
, cPairs
, lpKerningPairs
);
1472 for (i
= 0; i
< cPairs
; i
++)
1473 lpKerningPairs
[i
].iKernAmount
= 0;
1479 /*************************************************************************
1480 * GetKerningPairsA (GDI32.192)
1482 DWORD WINAPI
GetKerningPairsA( HDC hDC
, DWORD cPairs
,
1483 LPKERNINGPAIR lpKerningPairs
)
1486 FIXME_(font
)("(%x,%ld,%p): almost empty stub!\n",
1487 hDC
, cPairs
, lpKerningPairs
);
1488 for (i
= 0; i
< cPairs
; i
++)
1489 lpKerningPairs
[i
].iKernAmount
= 0;
1494 /*************************************************************************
1495 * GetKerningPairsW (GDI32.193)
1497 DWORD WINAPI
GetKerningPairsW( HDC hDC
, DWORD cPairs
,
1498 LPKERNINGPAIR lpKerningPairs
)
1500 return GetKerningPairsA( hDC
, cPairs
, lpKerningPairs
);
1503 /*************************************************************************
1504 * TranslateCharsetInfo [GDI32.382]
1506 * Fills a CHARSETINFO structure for a character set, code page, or
1507 * font. This allows making the correspondance between different labelings
1508 * (character set, Windows, ANSI, and OEM codepages, and Unicode ranges)
1509 * of the same encoding.
1511 * Only one codepage will be set in lpCs->fs. If TCI_SRCFONTSIG is used,
1512 * only one codepage should be set in *lpSrc.
1515 * TRUE on success, FALSE on failure.
1518 BOOL WINAPI
TranslateCharsetInfo(
1520 if flags == TCI_SRCFONTSIG: pointer to fsCsb of a FONTSIGNATURE
1521 if flags == TCI_SRCCHARSET: a character set value
1522 if flags == TCI_SRCCODEPAGE: a code page value
1524 LPCHARSETINFO lpCs
, /* structure to receive charset information */
1525 DWORD flags
/* determines interpretation of lpSrc */
1529 case TCI_SRCFONTSIG
:
1530 while (!(*lpSrc
>>index
& 0x0001) && index
<MAXTCIINDEX
) index
++;
1532 case TCI_SRCCODEPAGE
:
1533 while ((UINT
) (lpSrc
) != FONT_tci
[index
].ciACP
&& index
< MAXTCIINDEX
) index
++;
1535 case TCI_SRCCHARSET
:
1536 while ((UINT
) (lpSrc
) != FONT_tci
[index
].ciCharset
&& index
< MAXTCIINDEX
) index
++;
1541 if (index
>= MAXTCIINDEX
|| FONT_tci
[index
].ciCharset
== DEFAULT_CHARSET
) return FALSE
;
1542 memcpy(lpCs
, &FONT_tci
[index
], sizeof(CHARSETINFO
));
1546 /*************************************************************************
1547 * GetFontLanguageInfo (GDI32.182)
1549 DWORD WINAPI
GetFontLanguageInfo(HDC hdc
) {
1550 /* return value 0 is correct for most cases anyway */
1551 FIXME_(font
)("(%x):stub!\n", hdc
);
1555 /*************************************************************************
1556 * GetFontLanguageInfo (GDI.616)
1558 DWORD WINAPI
GetFontLanguageInfo16(HDC16 hdc
) {
1559 /* return value 0 is correct for most cases anyway */
1560 FIXME_(font
)("(%x):stub!\n",hdc
);
1564 /*************************************************************************
1565 * GetFontData [GDI32.181] Retrieve data for TrueType font
1569 * success: Number of bytes returned
1570 * failure: GDI_ERROR
1574 * Calls SetLastError()
1580 DWORD WINAPI
GetFontData(HDC hdc
, DWORD table
, DWORD offset
,
1581 LPVOID buffer
, DWORD length
)
1583 FIXME_(font
)("(%x,%ld,%ld,%p,%ld): stub\n",
1584 hdc
, table
, offset
, buffer
, length
);
1585 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
1589 /*************************************************************************
1590 * GetFontData16 [GDI.311]
1593 DWORD WINAPI
GetFontData16(HDC16 hdc
, DWORD dwTable
, DWORD dwOffset
,
1594 LPVOID lpvBuffer
, DWORD cbData
)
1596 return GetFontData(hdc
, dwTable
, dwOffset
, lpvBuffer
, cbData
);
1599 /*************************************************************************
1600 * GetCharacterPlacementA [GDI32.160]
1603 * the web browser control of ie4 calls this with dwFlags=0
1606 GetCharacterPlacementA(HDC hdc
, LPCSTR lpString
, INT uCount
,
1607 INT nMaxExtent
, GCP_RESULTSA
*lpResults
,
1613 TRACE_(font
)("%s 0x%08x 0x%08x 0x%08lx:stub!\n",
1614 debugstr_a(lpString
), uCount
, nMaxExtent
, dwFlags
);
1616 TRACE_(font
)("lpOrder=%p lpDx=%p lpCaretPos=%p lpClass=%p lpOutString=%p lpGlyphs=%p\n",
1617 lpResults
->lpOrder
, lpResults
->lpDx
, lpResults
->lpCaretPos
, lpResults
->lpClass
,
1618 lpResults
->lpOutString
, lpResults
->lpGlyphs
);
1620 if(dwFlags
) FIXME_(font
)("flags 0x%08lx ignored\n", dwFlags
);
1621 if(lpResults
->lpOrder
) FIXME_(font
)("reordering not implemented\n");
1622 if(lpResults
->lpCaretPos
) FIXME_(font
)("caret positions not implemented\n");
1623 if(lpResults
->lpClass
) FIXME_(font
)("classes not implemented\n");
1624 if(lpResults
->lpGlyphs
) FIXME_(font
)("glyphs not implemented\n");
1626 /* copy will do if the GCP_REORDER flag is not set */
1627 if(lpResults
->lpOutString
)
1629 lstrcpynA(lpResults
->lpOutString
, lpString
, uCount
);
1632 if (lpResults
->lpDx
)
1635 for (i
=0; i
<uCount
;i
++)
1637 if (GetCharWidth32A(hdc
, lpString
[i
], lpString
[i
], &c
))
1638 lpResults
->lpDx
[i
]= c
;
1642 if (GetTextExtentPoint32A(hdc
, lpString
, uCount
, &size
))
1643 ret
= MAKELONG(size
.cx
, size
.cy
);
1648 /*************************************************************************
1649 * GetCharacterPlacementW [GDI32.161]
1652 GetCharacterPlacementW(HDC hdc
, LPCWSTR lpString
, INT uCount
,
1653 INT nMaxExtent
, GCP_RESULTSW
*lpResults
,
1656 /* return value 0 is correct for most cases anyway */
1657 FIXME_(font
)(":stub!\n");
1661 /*************************************************************************
1662 * GetCharABCWidthsFloatA [GDI32.150]
1664 BOOL WINAPI
GetCharABCWidthsFloatA(HDC hdc
, UINT iFirstChar
, UINT iLastChar
,
1667 FIXME_(gdi
)("GetCharABCWidthsFloatA, stub\n");
1671 /*************************************************************************
1672 * GetCharABCWidthsFloatW [GDI32.151]
1674 BOOL WINAPI
GetCharABCWidthsFloatW(HDC hdc
, UINT iFirstChar
,
1675 UINT iLastChar
, LPABCFLOAT lpABCF
)
1677 FIXME_(gdi
)("GetCharABCWidthsFloatW, stub\n");
1681 /*************************************************************************
1682 * GetCharWidthFloatA [GDI32.156]
1684 BOOL WINAPI
GetCharWidthFloatA(HDC hdc
, UINT iFirstChar
,
1685 UINT iLastChar
, PFLOAT pxBuffer
)
1687 FIXME_(gdi
)("GetCharWidthFloatA, stub\n");
1691 /*************************************************************************
1692 * GetCharWidthFloatW [GDI32.157]
1694 BOOL WINAPI
GetCharWidthFloatW(HDC hdc
, UINT iFirstChar
,
1695 UINT iLastChar
, PFLOAT pxBuffer
)
1697 FIXME_(gdi
)("GetCharWidthFloatW, stub\n");