4 * Copyright 1993 Alexandre Julliard
10 #include "wine/winestring.h"
15 #include "debugtools.h"
19 DEFAULT_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("(%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" : "", hFont
);
329 if (font
->lfEscapement
!= font
->lfOrientation
) {
330 /* this should really depend on whether GM_ADVANCED is set */
331 fontPtr
->logfont
.lfOrientation
= fontPtr
->logfont
.lfEscapement
;
332 WARN("orientation angle %f set to "
333 "escapement angle %f for new font %04x\n",
334 font
->lfOrientation
/10., font
->lfEscapement
/10., hFont
);
336 GDI_HEAP_UNLOCK( hFont
);
339 else WARN("(NULL) => NULL\n");
344 /***********************************************************************
345 * CreateFontIndirectA (GDI32.44)
347 HFONT WINAPI
CreateFontIndirectA( const LOGFONTA
*font
)
351 FONT_LogFont32ATo16( font
, &font16
);
352 return CreateFontIndirect16( &font16
);
355 /***********************************************************************
356 * CreateFontIndirectW (GDI32.45)
358 HFONT WINAPI
CreateFontIndirectW( const LOGFONTW
*font
)
362 FONT_LogFont32WTo16( font
, &font16
);
363 return CreateFontIndirect16( &font16
);
366 /***********************************************************************
367 * CreateFont16 (GDI.56)
369 HFONT16 WINAPI
CreateFont16(INT16 height
, INT16 width
, INT16 esc
, INT16 orient
,
370 INT16 weight
, BYTE italic
, BYTE underline
,
371 BYTE strikeout
, BYTE charset
, BYTE outpres
,
372 BYTE clippres
, BYTE quality
, BYTE pitch
,
377 TRACE("('%s',%d,%d)\n", (name
? name
: "(null)") , height
, width
);
379 logfont
.lfHeight
= height
;
380 logfont
.lfWidth
= width
;
381 logfont
.lfEscapement
= esc
;
382 logfont
.lfOrientation
= orient
;
383 logfont
.lfWeight
= weight
;
384 logfont
.lfItalic
= italic
;
385 logfont
.lfUnderline
= underline
;
386 logfont
.lfStrikeOut
= strikeout
;
387 logfont
.lfCharSet
= charset
;
388 logfont
.lfOutPrecision
= outpres
;
389 logfont
.lfClipPrecision
= clippres
;
390 logfont
.lfQuality
= quality
;
391 logfont
.lfPitchAndFamily
= pitch
;
394 lstrcpynA(logfont
.lfFaceName
,name
,sizeof(logfont
.lfFaceName
));
396 logfont
.lfFaceName
[0] = '\0';
398 return CreateFontIndirect16( &logfont
);
401 /*************************************************************************
402 * CreateFontA (GDI32.43)
404 HFONT WINAPI
CreateFontA( INT height
, INT width
, INT esc
,
405 INT orient
, INT weight
, DWORD italic
,
406 DWORD underline
, DWORD strikeout
, DWORD charset
,
407 DWORD outpres
, DWORD clippres
, DWORD quality
,
408 DWORD pitch
, LPCSTR name
)
410 return (HFONT
)CreateFont16( height
, width
, esc
, orient
, weight
, italic
,
411 underline
, strikeout
, charset
, outpres
,
412 clippres
, quality
, pitch
, name
);
415 /*************************************************************************
416 * CreateFontW (GDI32.46)
418 HFONT WINAPI
CreateFontW( INT height
, INT width
, INT esc
,
419 INT orient
, INT weight
, DWORD italic
,
420 DWORD underline
, DWORD strikeout
, DWORD charset
,
421 DWORD outpres
, DWORD clippres
, DWORD quality
,
422 DWORD pitch
, LPCWSTR name
)
424 LPSTR namea
= HEAP_strdupWtoA( GetProcessHeap(), 0, name
);
425 HFONT ret
= (HFONT
)CreateFont16( height
, width
, esc
, orient
, weight
,
426 italic
, underline
, strikeout
, charset
,
427 outpres
, clippres
, quality
, pitch
,
429 if (namea
) HeapFree( GetProcessHeap(), 0, namea
);
434 /***********************************************************************
437 INT16
FONT_GetObject16( FONTOBJ
* font
, INT16 count
, LPSTR buffer
)
439 if (count
> sizeof(LOGFONT16
)) count
= sizeof(LOGFONT16
);
440 memcpy( buffer
, &font
->logfont
, count
);
444 /***********************************************************************
447 INT
FONT_GetObjectA( FONTOBJ
*font
, INT count
, LPSTR buffer
)
451 FONT_LogFont16To32A( &font
->logfont
, &fnt32
);
453 if (count
> sizeof(fnt32
)) count
= sizeof(fnt32
);
454 memcpy( buffer
, &fnt32
, count
);
457 /***********************************************************************
460 INT
FONT_GetObjectW( FONTOBJ
*font
, INT count
, LPSTR buffer
)
464 FONT_LogFont16To32W( &font
->logfont
, &fnt32
);
466 if (count
> sizeof(fnt32
)) count
= sizeof(fnt32
);
467 memcpy( buffer
, &fnt32
, count
);
472 /***********************************************************************
473 * FONT_EnumInstance16
475 * Called by the device driver layer to pass font info
476 * down to the application.
478 static INT
FONT_EnumInstance16( LPENUMLOGFONTEX16 plf
,
479 LPNEWTEXTMETRIC16 ptm
, UINT16 fType
, LPARAM lp
)
481 #define pfe ((fontEnum16*)lp)
482 if( pfe
->lpLogFontParam
->lfCharSet
== DEFAULT_CHARSET
||
483 pfe
->lpLogFontParam
->lfCharSet
== plf
->elfLogFont
.lfCharSet
)
485 memcpy( pfe
->lpLogFont
, plf
, sizeof(ENUMLOGFONT16
) );
486 memcpy( pfe
->lpTextMetric
, ptm
, sizeof(NEWTEXTMETRIC16
) );
488 return pfe
->lpEnumFunc( pfe
->segLogFont
, pfe
->segTextMetric
, fType
, (LPARAM
)(pfe
->lpData
) );
494 /***********************************************************************
497 static INT
FONT_EnumInstance( LPENUMLOGFONTEX16 plf
,
498 LPNEWTEXTMETRIC16 ptm
, UINT16 fType
, LPARAM lp
)
500 /* lfCharSet is at the same offset in both LOGFONT32A and LOGFONT32W */
502 #define pfe ((fontEnum32*)lp)
503 if( pfe
->lpLogFontParam
->lfCharSet
== DEFAULT_CHARSET
||
504 pfe
->lpLogFontParam
->lfCharSet
== plf
->elfLogFont
.lfCharSet
)
506 /* convert font metrics */
508 if( pfe
->dwFlags
& ENUM_UNICODE
)
510 FONT_EnumLogFontEx16To32W( plf
, pfe
->lpLogFont
);
511 FONT_TextMetric16to32W( (LPTEXTMETRIC16
)ptm
, (LPTEXTMETRICW
)(pfe
->lpTextMetric
) );
513 return pfe
->lpEnumFunc( pfe
->lpLogFont
, pfe
->lpTextMetric
, fType
, pfe
->lpData
);
517 ENUMLOGFONTEXA logfont
;
519 FONT_EnumLogFontEx16To32A( plf
, &logfont
);
520 FONT_TextMetric16to32A( (LPTEXTMETRIC16
)ptm
, (LPTEXTMETRICA
)pfe
->lpTextMetric
);
522 return pfe
->lpEnumFunc( (LPENUMLOGFONTEXW
)&logfont
,
523 pfe
->lpTextMetric
, fType
, pfe
->lpData
);
530 /***********************************************************************
531 * EnumFontFamiliesEx16 (GDI.613)
533 INT16 WINAPI
EnumFontFamiliesEx16( HDC16 hDC
, LPLOGFONT16 plf
,
534 FONTENUMPROCEX16 efproc
, LPARAM lParam
,
538 DC
* dc
= (DC
*) GDI_GetObjPtr( hDC
, DC_MAGIC
);
540 if( dc
&& dc
->funcs
->pEnumDeviceFonts
)
542 LPNEWTEXTMETRICEX16 lptm16
= SEGPTR_ALLOC( sizeof(NEWTEXTMETRICEX16
) );
545 LPENUMLOGFONTEX16 lplf16
= SEGPTR_ALLOC( sizeof(ENUMLOGFONTEX16
) );
550 fe16
.lpLogFontParam
= plf
;
551 fe16
.lpEnumFunc
= efproc
;
552 fe16
.lpData
= lParam
;
554 fe16
.lpTextMetric
= lptm16
;
555 fe16
.lpLogFont
= lplf16
;
556 fe16
.segTextMetric
= SEGPTR_GET(lptm16
);
557 fe16
.segLogFont
= SEGPTR_GET(lplf16
);
559 retVal
= dc
->funcs
->pEnumDeviceFonts( dc
, plf
, FONT_EnumInstance16
, (LPARAM
)&fe16
);
569 /***********************************************************************
570 * FONT_EnumFontFamiliesEx
572 static INT
FONT_EnumFontFamiliesEx( HDC hDC
, LPLOGFONTW plf
, FONTENUMPROCEXW efproc
,
573 LPARAM lParam
, DWORD dwUnicode
)
575 DC
* dc
= (DC
*) GDI_GetObjPtr( hDC
, DC_MAGIC
);
577 if( dc
&& dc
->funcs
->pEnumDeviceFonts
)
580 NEWTEXTMETRICEXW tm32w
;
581 ENUMLOGFONTEXW lf32w
;
584 fe32
.lpLogFontParam
= plf
;
585 fe32
.lpEnumFunc
= efproc
;
586 fe32
.lpData
= lParam
;
588 fe32
.lpTextMetric
= &tm32w
;
589 fe32
.lpLogFont
= &lf32w
;
590 fe32
.dwFlags
= dwUnicode
;
592 /* the only difference between LOGFONT32A and LOGFONT32W is in the lfFaceName */
594 if( plf
->lfFaceName
[0] )
597 lstrcpynWtoA( lf16
.lfFaceName
, plf
->lfFaceName
, LF_FACESIZE
);
599 lstrcpynA( lf16
.lfFaceName
, (LPCSTR
)plf
->lfFaceName
, LF_FACESIZE
);
601 else lf16
.lfFaceName
[0] = '\0';
602 lf16
.lfCharSet
= plf
->lfCharSet
;
604 return dc
->funcs
->pEnumDeviceFonts( dc
, &lf16
, FONT_EnumInstance
, (LPARAM
)&fe32
);
609 /***********************************************************************
610 * EnumFontFamiliesExW (GDI32.82)
612 INT WINAPI
EnumFontFamiliesExW( HDC hDC
, LPLOGFONTW plf
,
613 FONTENUMPROCEXW efproc
,
614 LPARAM lParam
, DWORD dwFlags
)
616 return FONT_EnumFontFamiliesEx( hDC
, plf
, efproc
, lParam
, ENUM_UNICODE
);
619 /***********************************************************************
620 * EnumFontFamiliesExA (GDI32.81)
622 INT WINAPI
EnumFontFamiliesExA( HDC hDC
, LPLOGFONTA plf
,
623 FONTENUMPROCEXA efproc
,
624 LPARAM lParam
, DWORD dwFlags
)
626 return FONT_EnumFontFamiliesEx( hDC
, (LPLOGFONTW
)plf
,
627 (FONTENUMPROCEXW
)efproc
, lParam
, 0);
630 /***********************************************************************
631 * EnumFontFamilies16 (GDI.330)
633 INT16 WINAPI
EnumFontFamilies16( HDC16 hDC
, LPCSTR lpFamily
,
634 FONTENUMPROC16 efproc
, LPARAM lpData
)
638 lf
.lfCharSet
= DEFAULT_CHARSET
;
639 if( lpFamily
) lstrcpynA( lf
.lfFaceName
, lpFamily
, LF_FACESIZE
);
640 else lf
.lfFaceName
[0] = '\0';
642 return EnumFontFamiliesEx16( hDC
, &lf
, (FONTENUMPROCEX16
)efproc
, lpData
, 0 );
645 /***********************************************************************
646 * EnumFontFamiliesA (GDI32.80)
648 INT WINAPI
EnumFontFamiliesA( HDC hDC
, LPCSTR lpFamily
,
649 FONTENUMPROCA efproc
, LPARAM lpData
)
653 lf
.lfCharSet
= DEFAULT_CHARSET
;
654 if( lpFamily
) lstrcpynA( lf
.lfFaceName
, lpFamily
, LF_FACESIZE
);
655 else lf
.lfFaceName
[0] = lf
.lfFaceName
[1] = '\0';
657 return FONT_EnumFontFamiliesEx( hDC
, (LPLOGFONTW
)&lf
,
658 (FONTENUMPROCEXW
)efproc
, lpData
, 0 );
661 /***********************************************************************
662 * EnumFontFamiliesW (GDI32.83)
664 INT WINAPI
EnumFontFamiliesW( HDC hDC
, LPCWSTR lpFamily
,
665 FONTENUMPROCW efproc
, LPARAM lpData
)
669 lf
.lfCharSet
= DEFAULT_CHARSET
;
670 if( lpFamily
) lstrcpynW( lf
.lfFaceName
, lpFamily
, LF_FACESIZE
);
671 else lf
.lfFaceName
[0] = 0;
673 return FONT_EnumFontFamiliesEx( hDC
, &lf
, (FONTENUMPROCEXW
)efproc
,
674 lpData
, ENUM_UNICODE
);
677 /***********************************************************************
678 * EnumFonts16 (GDI.70)
680 INT16 WINAPI
EnumFonts16( HDC16 hDC
, LPCSTR lpName
, FONTENUMPROC16 efproc
,
683 return EnumFontFamilies16( hDC
, lpName
, (FONTENUMPROCEX16
)efproc
, lpData
);
686 /***********************************************************************
687 * EnumFontsA (GDI32.84)
689 INT WINAPI
EnumFontsA( HDC hDC
, LPCSTR lpName
, FONTENUMPROCA efproc
,
692 return EnumFontFamiliesA( hDC
, lpName
, efproc
, lpData
);
695 /***********************************************************************
696 * EnumFontsW (GDI32.85)
698 INT WINAPI
EnumFontsW( HDC hDC
, LPCWSTR lpName
, FONTENUMPROCW efproc
,
701 return EnumFontFamiliesW( hDC
, lpName
, efproc
, lpData
);
705 /***********************************************************************
706 * GetTextCharacterExtra16 (GDI.89)
708 INT16 WINAPI
GetTextCharacterExtra16( HDC16 hdc
)
710 DC
* dc
= (DC
*) GDI_GetObjPtr( hdc
, DC_MAGIC
);
712 return abs( (dc
->w
.charExtra
* dc
->wndExtX
+ dc
->vportExtX
/ 2)
717 /***********************************************************************
718 * GetTextCharacterExtra (GDI32.225)
720 INT WINAPI
GetTextCharacterExtra( HDC hdc
)
722 DC
* dc
= (DC
*) GDI_GetObjPtr( hdc
, DC_MAGIC
);
724 return abs( (dc
->w
.charExtra
* dc
->wndExtX
+ dc
->vportExtX
/ 2)
729 /***********************************************************************
730 * SetTextCharacterExtra16 (GDI.8)
732 INT16 WINAPI
SetTextCharacterExtra16( HDC16 hdc
, INT16 extra
)
734 return (INT16
)SetTextCharacterExtra( hdc
, extra
);
738 /***********************************************************************
739 * SetTextCharacterExtra (GDI32.337)
741 INT WINAPI
SetTextCharacterExtra( HDC hdc
, INT extra
)
744 DC
* dc
= DC_GetDCPtr( hdc
);
746 if (dc
->funcs
->pSetTextCharacterExtra
)
747 return dc
->funcs
->pSetTextCharacterExtra( dc
, extra
);
748 extra
= (extra
* dc
->vportExtX
+ dc
->wndExtX
/ 2) / dc
->wndExtX
;
749 prev
= dc
->w
.charExtra
;
750 dc
->w
.charExtra
= abs(extra
);
751 return (prev
* dc
->wndExtX
+ dc
->vportExtX
/ 2) / dc
->vportExtX
;
755 /***********************************************************************
756 * SetTextJustification16 (GDI.10)
758 INT16 WINAPI
SetTextJustification16( HDC16 hdc
, INT16 extra
, INT16 breaks
)
760 return SetTextJustification( hdc
, extra
, breaks
);
764 /***********************************************************************
765 * SetTextJustification (GDI32.339)
767 BOOL WINAPI
SetTextJustification( HDC hdc
, INT extra
, INT breaks
)
769 DC
* dc
= DC_GetDCPtr( hdc
);
771 if (dc
->funcs
->pSetTextJustification
)
772 return dc
->funcs
->pSetTextJustification( dc
, extra
, breaks
);
774 extra
= abs((extra
* dc
->vportExtX
+ dc
->wndExtX
/ 2) / dc
->wndExtX
);
775 if (!extra
) breaks
= 0;
776 dc
->w
.breakTotalExtra
= extra
;
777 dc
->w
.breakCount
= breaks
;
780 dc
->w
.breakExtra
= extra
/ breaks
;
781 dc
->w
.breakRem
= extra
- (dc
->w
.breakCount
* dc
->w
.breakExtra
);
785 dc
->w
.breakExtra
= 0;
792 /***********************************************************************
793 * GetTextFace16 (GDI.92)
795 INT16 WINAPI
GetTextFace16( HDC16 hdc
, INT16 count
, LPSTR name
)
797 return GetTextFaceA(hdc
,count
,name
);
800 /***********************************************************************
801 * GetTextFaceA (GDI32.234)
803 INT WINAPI
GetTextFaceA( HDC hdc
, INT count
, LPSTR name
)
807 DC
* dc
= (DC
*) GDI_GetObjPtr( hdc
, DC_MAGIC
);
809 if (!(font
= (FONTOBJ
*) GDI_GetObjPtr( dc
->w
.hFont
, FONT_MAGIC
)))
812 lstrcpynA( name
, font
->logfont
.lfFaceName
, count
);
813 GDI_HEAP_UNLOCK( dc
->w
.hFont
);
817 return strlen(font
->logfont
.lfFaceName
) + 1;
820 /***********************************************************************
821 * GetTextFaceW (GDI32.235)
823 INT WINAPI
GetTextFaceW( HDC hdc
, INT count
, LPWSTR name
)
825 LPSTR nameA
= HeapAlloc( GetProcessHeap(), 0, count
);
826 INT res
= GetTextFaceA(hdc
,count
,nameA
);
827 lstrcpyAtoW( name
, nameA
);
828 HeapFree( GetProcessHeap(), 0, nameA
);
833 /***********************************************************************
834 * GetTextExtent16 (GDI.91)
836 DWORD WINAPI
GetTextExtent16( HDC16 hdc
, LPCSTR str
, INT16 count
)
839 if (!GetTextExtentPoint16( hdc
, str
, count
, &size
)) return 0;
840 return MAKELONG( size
.cx
, size
.cy
);
844 /***********************************************************************
845 * GetTextExtentPoint16 (GDI.471)
847 * FIXME: Should this have a bug for compatibility?
848 * Original Windows versions of GetTextExtentPoint{A,W} have documented
849 * bugs (-> MSDN KB q147647.txt).
851 BOOL16 WINAPI
GetTextExtentPoint16( HDC16 hdc
, LPCSTR str
, INT16 count
,
855 BOOL ret
= GetTextExtentPoint32A( hdc
, str
, count
, &size32
);
856 CONV_SIZE32TO16( &size32
, size
);
861 /***********************************************************************
862 * GetTextExtentPoint32A (GDI32.230)
864 BOOL WINAPI
GetTextExtentPoint32A( HDC hdc
, LPCSTR str
, INT count
,
867 DC
* dc
= (DC
*) GDI_GetObjPtr( hdc
, DC_MAGIC
);
870 if (!(dc
= (DC
*)GDI_GetObjPtr( hdc
, METAFILE_DC_MAGIC
)))
874 if (!dc
->funcs
->pGetTextExtentPoint
||
875 !dc
->funcs
->pGetTextExtentPoint( dc
, str
, count
, size
))
878 TRACE("(%08x %s %d %p): returning %d,%d\n",
879 hdc
, debugstr_an (str
, count
), count
, size
, size
->cx
, size
->cy
);
884 /***********************************************************************
885 * GetTextExtentPoint32W [GDI32.231] Computes width/height for a string
887 * Computes width and height of the specified string.
893 BOOL WINAPI
GetTextExtentPoint32W(
894 HDC hdc
, /* [in] Handle of device context */
895 LPCWSTR str
, /* [in] Address of text string */
896 INT count
, /* [in] Number of characters in string */
897 LPSIZE size
) /* [out] Address of structure for string size */
902 /* str may not be 0 terminated so we can't use HEAP_strdupWtoA.
903 * We allocate one more than we need so that lstrcpynWtoA can write a
904 * trailing 0 if it wants.
907 if(!count
) count
= lstrlenW(str
);
908 p
= HeapAlloc( GetProcessHeap(), 0, count
+1 );
909 lstrcpynWtoA(p
, str
, count
+1);
910 ret
= GetTextExtentPoint32A( hdc
, p
, count
, size
);
911 HeapFree( GetProcessHeap(), 0, p
);
916 /***********************************************************************
917 * GetTextExtentPointA (GDI32.232)
919 BOOL WINAPI
GetTextExtentPointA( HDC hdc
, LPCSTR str
, INT count
,
922 TRACE("not bug compatible.\n");
923 return GetTextExtentPoint32A( hdc
, str
, count
, size
);
926 /***********************************************************************
927 * GetTextExtentPointW (GDI32.233)
929 BOOL WINAPI
GetTextExtentPointW( HDC hdc
, LPCWSTR str
, INT count
,
932 TRACE("not bug compatible.\n");
933 return GetTextExtentPoint32W( hdc
, str
, count
, size
);
937 /***********************************************************************
938 * GetTextExtentExPointA (GDI32.228)
940 BOOL WINAPI
GetTextExtentExPointA( HDC hdc
, LPCSTR str
, INT count
,
941 INT maxExt
, LPINT lpnFit
,
942 LPINT alpDx
, LPSIZE size
)
944 int index
, nFit
, extent
;
946 DC
* dc
= (DC
*) GDI_GetObjPtr( hdc
, DC_MAGIC
);
950 if (!(dc
= (DC
*)GDI_GetObjPtr( hdc
, METAFILE_DC_MAGIC
)))
953 if (!dc
->funcs
->pGetTextExtentPoint
) return FALSE
;
955 size
->cx
= size
->cy
= nFit
= extent
= 0;
956 for(index
= 0; index
< count
; index
++)
958 if(!dc
->funcs
->pGetTextExtentPoint( dc
, str
, 1, &tSize
)) return FALSE
;
959 if( extent
+tSize
.cx
< maxExt
)
964 if( alpDx
) alpDx
[index
] = extent
;
965 if( tSize
.cy
> size
->cy
) size
->cy
= tSize
.cy
;
972 TRACE("(%08x '%.*s' %d) returning %d %d %d\n",
973 hdc
,count
,str
,maxExt
,nFit
, size
->cx
,size
->cy
);
978 /***********************************************************************
979 * GetTextExtentExPointW (GDI32.229)
982 BOOL WINAPI
GetTextExtentExPointW( HDC hdc
, LPCWSTR str
, INT count
,
983 INT maxExt
, LPINT lpnFit
,
984 LPINT alpDx
, LPSIZE size
)
989 /* Docs say str should be 0 terminated here, but we'll use count just in case
992 if(!count
) count
= lstrlenW(str
);
993 p
= HeapAlloc( GetProcessHeap(), 0, count
+1 );
994 lstrcpynWtoA(p
, str
, count
+1);
995 ret
= GetTextExtentExPointA( hdc
, p
, count
, maxExt
,
996 lpnFit
, alpDx
, size
);
997 HeapFree( GetProcessHeap(), 0, p
);
1001 /***********************************************************************
1002 * GetTextMetrics16 (GDI.93)
1004 BOOL16 WINAPI
GetTextMetrics16( HDC16 hdc
, TEXTMETRIC16
*metrics
)
1008 if (!GetTextMetricsA( (HDC
)hdc
, &tm32
)) return FALSE
;
1009 FONT_TextMetric32Ato16( &tm32
, metrics
);
1014 /***********************************************************************
1015 * GetTextMetricsA (GDI32.236)
1017 BOOL WINAPI
GetTextMetricsA( HDC hdc
, TEXTMETRICA
*metrics
)
1019 DC
* dc
= (DC
*) GDI_GetObjPtr( hdc
, DC_MAGIC
);
1022 if (!(dc
= (DC
*)GDI_GetObjPtr( hdc
, METAFILE_DC_MAGIC
)))
1026 if (!dc
->funcs
->pGetTextMetrics
||
1027 !dc
->funcs
->pGetTextMetrics( dc
, metrics
))
1030 /* device layer returns values in device units
1031 * therefore we have to convert them to logical */
1033 #define WDPTOLP(x) ((x<0)? \
1034 (-abs((x)*dc->wndExtX/dc->vportExtX)): \
1035 (abs((x)*dc->wndExtX/dc->vportExtX)))
1036 #define HDPTOLP(y) ((y<0)? \
1037 (-abs((y)*dc->wndExtY/dc->vportExtY)): \
1038 (abs((y)*dc->wndExtY/dc->vportExtY)))
1040 metrics
->tmHeight
= HDPTOLP(metrics
->tmHeight
);
1041 metrics
->tmAscent
= HDPTOLP(metrics
->tmAscent
);
1042 metrics
->tmDescent
= HDPTOLP(metrics
->tmDescent
);
1043 metrics
->tmInternalLeading
= HDPTOLP(metrics
->tmInternalLeading
);
1044 metrics
->tmExternalLeading
= HDPTOLP(metrics
->tmExternalLeading
);
1045 metrics
->tmAveCharWidth
= WDPTOLP(metrics
->tmAveCharWidth
);
1046 metrics
->tmMaxCharWidth
= WDPTOLP(metrics
->tmMaxCharWidth
);
1047 metrics
->tmOverhang
= WDPTOLP(metrics
->tmOverhang
);
1049 TRACE("text metrics:\n"
1050 " Weight = %03li\t FirstChar = %03i\t AveCharWidth = %li\n"
1051 " Italic = % 3i\t LastChar = %03i\t\t MaxCharWidth = %li\n"
1052 " UnderLined = %01i\t DefaultChar = %03i\t Overhang = %li\n"
1053 " StruckOut = %01i\t BreakChar = %03i\t CharSet = %i\n"
1054 " PitchAndFamily = %02x\n"
1055 " --------------------\n"
1056 " InternalLeading = %li\n"
1060 metrics
->tmWeight
, metrics
->tmFirstChar
, metrics
->tmAveCharWidth
,
1061 metrics
->tmItalic
, metrics
->tmLastChar
, metrics
->tmMaxCharWidth
,
1062 metrics
->tmUnderlined
, metrics
->tmDefaultChar
, metrics
->tmOverhang
,
1063 metrics
->tmStruckOut
, metrics
->tmBreakChar
, metrics
->tmCharSet
,
1064 metrics
->tmPitchAndFamily
,
1065 metrics
->tmInternalLeading
,
1068 metrics
->tmHeight
);
1073 /***********************************************************************
1074 * GetTextMetricsW (GDI32.237)
1076 BOOL WINAPI
GetTextMetricsW( HDC hdc
, TEXTMETRICW
*metrics
)
1079 if (!GetTextMetricsA( (HDC16
)hdc
, &tm
)) return FALSE
;
1080 FONT_TextMetric32Ato32W( &tm
, metrics
);
1085 /***********************************************************************
1086 * GetOutlineTextMetrics16 [GDI.308] Gets metrics for TrueType fonts.
1089 * lpOTM should be LPOUTLINETEXTMETRIC
1092 * Success: Non-zero or size of required buffer
1095 UINT16 WINAPI
GetOutlineTextMetrics16(
1096 HDC16 hdc
, /* [in] Handle of device context */
1097 UINT16 cbData
, /* [in] Size of metric data array */
1098 LPOUTLINETEXTMETRIC16 lpOTM
) /* [out] Address of metric data array */
1100 FIXME("(%04x,%04x,%p): stub\n", hdc
,cbData
,lpOTM
);
1105 /***********************************************************************
1106 * GetOutlineTextMetricsA [GDI.207] Gets metrics for TrueType fonts.
1110 * Success: Non-zero or size of required buffer
1113 UINT WINAPI
GetOutlineTextMetricsA(
1114 HDC hdc
, /* [in] Handle of device context */
1115 UINT cbData
, /* [in] Size of metric data array */
1116 LPOUTLINETEXTMETRICA lpOTM
) /* [out] Address of metric data array */
1121 LPTEXTMETRICA lptxtMetr
;
1128 lpOTM
= (LPOUTLINETEXTMETRICA
)HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY
,sizeof(OUTLINETEXTMETRICA
));
1129 rtn
= sizeof(OUTLINETEXTMETRICA
);
1133 cbData
= sizeof(*lpOTM
);
1137 lpOTM
->otmSize
= cbData
;
1139 lptxtMetr
=HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY
,sizeof(TEXTMETRICA
));
1141 if (!GetTextMetricsA(hdc
,lptxtMetr
))
1146 memcpy(&(lpOTM
->otmTextMetrics
),lptxtMetr
,sizeof(TEXTMETRICA
));
1149 HeapFree(GetProcessHeap(),HEAP_ZERO_MEMORY
,lptxtMetr
);
1151 lpOTM
->otmFilter
= 0;
1153 lpOTM
->otmPanoseNumber
.bFamilyType
= 0;
1154 lpOTM
->otmPanoseNumber
.bSerifStyle
= 0;
1155 lpOTM
->otmPanoseNumber
.bWeight
= 0;
1156 lpOTM
->otmPanoseNumber
.bProportion
= 0;
1157 lpOTM
->otmPanoseNumber
.bContrast
= 0;
1158 lpOTM
->otmPanoseNumber
.bStrokeVariation
= 0;
1159 lpOTM
->otmPanoseNumber
.bArmStyle
= 0;
1160 lpOTM
->otmPanoseNumber
.bLetterform
= 0;
1161 lpOTM
->otmPanoseNumber
.bMidline
= 0;
1162 lpOTM
->otmPanoseNumber
.bXHeight
= 0;
1164 lpOTM
->otmfsSelection
= 0;
1165 lpOTM
->otmfsType
= 0;
1168 Further fill of the structure not implemented,
1169 Needs real values for the structure members
1175 /***********************************************************************
1176 * GetOutlineTextMetricsW [GDI32.208]
1178 UINT WINAPI
GetOutlineTextMetricsW(
1179 HDC hdc
, /* [in] Handle of device context */
1180 UINT cbData
, /* [in] Size of metric data array */
1181 LPOUTLINETEXTMETRICW lpOTM
) /* [out] Address of metric data array */
1183 FIXME("(%d,%d,%p): stub\n", hdc
, cbData
, lpOTM
);
1187 /***********************************************************************
1188 * GetCharWidth16 (GDI.350)
1190 BOOL16 WINAPI
GetCharWidth16( HDC16 hdc
, UINT16 firstChar
, UINT16 lastChar
,
1193 BOOL retVal
= FALSE
;
1195 if( firstChar
!= lastChar
)
1197 LPINT buf32
= (LPINT
)HeapAlloc(GetProcessHeap(), 0,
1198 sizeof(INT
)*(1 + (lastChar
- firstChar
)));
1201 LPINT obuf32
= buf32
;
1204 retVal
= GetCharWidth32A(hdc
, firstChar
, lastChar
, buf32
);
1207 for (i
= firstChar
; i
<= lastChar
; i
++)
1208 *buffer
++ = *buf32
++;
1210 HeapFree(GetProcessHeap(), 0, obuf32
);
1213 else /* happens quite often to warrant a special treatment */
1216 retVal
= GetCharWidth32A(hdc
, firstChar
, lastChar
, &chWidth
);
1223 /***********************************************************************
1224 * GetCharWidth32A (GDI32.155)
1226 BOOL WINAPI
GetCharWidth32A( HDC hdc
, UINT firstChar
, UINT lastChar
,
1230 DC
* dc
= (DC
*) GDI_GetObjPtr( hdc
, DC_MAGIC
);
1233 if (!(dc
= (DC
*)GDI_GetObjPtr( hdc
, METAFILE_DC_MAGIC
)))
1237 if (!dc
->funcs
->pGetCharWidth
||
1238 !dc
->funcs
->pGetCharWidth( dc
, firstChar
, lastChar
, buffer
))
1241 /* convert device units to logical */
1243 extra
= dc
->vportExtX
>> 1;
1244 for( i
= firstChar
; i
<= lastChar
; i
++, buffer
++ )
1245 *buffer
= (*buffer
* dc
->wndExtX
+ extra
) / dc
->vportExtX
;
1251 /***********************************************************************
1252 * GetCharWidth32W (GDI32.158)
1254 BOOL WINAPI
GetCharWidth32W( HDC hdc
, UINT firstChar
, UINT lastChar
,
1257 return GetCharWidth32A( hdc
, firstChar
, lastChar
, buffer
);
1262 /* FIXME: all following APIs *******************************************
1265 * SetMapperFlags16 (GDI.349)
1267 DWORD WINAPI
SetMapperFlags16( HDC16 hDC
, DWORD dwFlag
)
1269 return SetMapperFlags( hDC
, dwFlag
);
1273 /***********************************************************************
1274 * SetMapperFlags (GDI32.322)
1276 DWORD WINAPI
SetMapperFlags( HDC hDC
, DWORD dwFlag
)
1278 DC
*dc
= DC_GetDCPtr( hDC
);
1281 if(dc
->funcs
->pSetMapperFlags
)
1282 ret
= dc
->funcs
->pSetMapperFlags( dc
, dwFlag
);
1284 FIXME("(0x%04x, 0x%08lx): stub - harmless\n", hDC
, dwFlag
);
1285 GDI_HEAP_UNLOCK( hDC
);
1289 /***********************************************************************
1290 * GetAspectRatioFilterEx16 (GDI.486)
1292 BOOL16 WINAPI
GetAspectRatioFilterEx16( HDC16 hdc
, LPSIZE16 pAspectRatio
)
1294 FIXME("(%04x, %p): -- Empty Stub !\n", hdc
, pAspectRatio
);
1298 /***********************************************************************
1299 * GetAspectRatioFilterEx (GDI32.142)
1301 BOOL WINAPI
GetAspectRatioFilterEx( HDC hdc
, LPSIZE pAspectRatio
)
1303 FIXME("(%04x, %p): -- Empty Stub !\n", hdc
, pAspectRatio
);
1307 /***********************************************************************
1308 * GetCharABCWidths16 (GDI.307)
1310 BOOL16 WINAPI
GetCharABCWidths16( HDC16 hdc
, UINT16 firstChar
, UINT16 lastChar
,
1314 if (!GetCharABCWidthsA( hdc
, firstChar
, lastChar
, &abc32
)) return FALSE
;
1315 abc
->abcA
= abc32
.abcA
;
1316 abc
->abcB
= abc32
.abcB
;
1317 abc
->abcC
= abc32
.abcC
;
1322 /***********************************************************************
1323 * GetCharABCWidthsA (GDI32.149)
1325 BOOL WINAPI
GetCharABCWidthsA(HDC hdc
, UINT firstChar
, UINT lastChar
,
1328 return GetCharABCWidthsW( hdc
, firstChar
, lastChar
, abc
);
1332 /******************************************************************************
1333 * GetCharABCWidthsW [GDI32.152] Retrieves widths of characters in range
1336 * hdc [I] Handle of device context
1337 * firstChar [I] First character in range to query
1338 * lastChar [I] Last character in range to query
1339 * abc [O] Address of character-width structure
1342 * Only works with TrueType fonts
1348 BOOL WINAPI
GetCharABCWidthsW( HDC hdc
, UINT firstChar
, UINT lastChar
,
1351 /* No TrueType fonts in Wine so far */
1352 FIXME("(%04x,%04x,%04x,%p): stub\n", hdc
, firstChar
, lastChar
, abc
);
1357 /***********************************************************************
1358 * GetGlyphOutline16 (GDI.309)
1360 DWORD WINAPI
GetGlyphOutline16( HDC16 hdc
, UINT16 uChar
, UINT16 fuFormat
,
1361 LPGLYPHMETRICS16 lpgm
, DWORD cbBuffer
,
1362 LPVOID lpBuffer
, const MAT2
*lpmat2
)
1364 FIXME("(%04x, '%c', %04x, %p, %ld, %p, %p): stub\n",
1365 hdc
, uChar
, fuFormat
, lpgm
, cbBuffer
, lpBuffer
, lpmat2
);
1366 return (DWORD
)-1; /* failure */
1370 /***********************************************************************
1371 * GetGlyphOutlineA (GDI32.186)
1373 DWORD WINAPI
GetGlyphOutlineA( HDC hdc
, UINT uChar
, UINT fuFormat
,
1374 LPGLYPHMETRICS lpgm
, DWORD cbBuffer
,
1375 LPVOID lpBuffer
, const MAT2
*lpmat2
)
1377 FIXME("(%04x, '%c', %04x, %p, %ld, %p, %p): stub\n",
1378 hdc
, uChar
, fuFormat
, lpgm
, cbBuffer
, lpBuffer
, lpmat2
);
1379 return (DWORD
)-1; /* failure */
1382 /***********************************************************************
1383 * GetGlyphOutlineW (GDI32.187)
1385 DWORD WINAPI
GetGlyphOutlineW( HDC hdc
, UINT uChar
, UINT fuFormat
,
1386 LPGLYPHMETRICS lpgm
, DWORD cbBuffer
,
1387 LPVOID lpBuffer
, const MAT2
*lpmat2
)
1389 FIXME("(%04x, '%c', %04x, %p, %ld, %p, %p): stub\n",
1390 hdc
, uChar
, fuFormat
, lpgm
, cbBuffer
, lpBuffer
, lpmat2
);
1391 return (DWORD
)-1; /* failure */
1394 /***********************************************************************
1395 * CreateScalableFontResource16 (GDI.310)
1397 BOOL16 WINAPI
CreateScalableFontResource16( UINT16 fHidden
,
1398 LPCSTR lpszResourceFile
,
1399 LPCSTR fontFile
, LPCSTR path
)
1401 return CreateScalableFontResourceA( fHidden
, lpszResourceFile
,
1405 /***********************************************************************
1406 * CreateScalableFontResourceA (GDI32.62)
1408 BOOL WINAPI
CreateScalableFontResourceA( DWORD fHidden
,
1409 LPCSTR lpszResourceFile
,
1410 LPCSTR lpszFontFile
,
1411 LPCSTR lpszCurrentPath
)
1413 /* fHidden=1 - only visible for the calling app, read-only, not
1414 * enumbered with EnumFonts/EnumFontFamilies
1415 * lpszCurrentPath can be NULL
1417 FIXME("(%ld,%s,%s,%s): stub\n",
1418 fHidden
, lpszResourceFile
, lpszFontFile
, lpszCurrentPath
);
1419 return FALSE
; /* create failed */
1422 /***********************************************************************
1423 * CreateScalableFontResourceW (GDI32.63)
1425 BOOL WINAPI
CreateScalableFontResourceW( DWORD fHidden
,
1426 LPCWSTR lpszResourceFile
,
1427 LPCWSTR lpszFontFile
,
1428 LPCWSTR lpszCurrentPath
)
1430 FIXME("(%ld,%p,%p,%p): stub\n",
1431 fHidden
, lpszResourceFile
, lpszFontFile
, lpszCurrentPath
);
1432 return FALSE
; /* create failed */
1436 /*************************************************************************
1437 * GetRasterizerCaps16 (GDI.313)
1439 BOOL16 WINAPI
GetRasterizerCaps16( LPRASTERIZER_STATUS lprs
, UINT16 cbNumBytes
)
1441 return GetRasterizerCaps( lprs
, cbNumBytes
);
1445 /*************************************************************************
1446 * GetRasterizerCaps (GDI32.216)
1448 BOOL WINAPI
GetRasterizerCaps( LPRASTERIZER_STATUS lprs
, UINT cbNumBytes
)
1450 lprs
->nSize
= sizeof(RASTERIZER_STATUS
);
1451 lprs
->wFlags
= TT_AVAILABLE
|TT_ENABLED
;
1452 lprs
->nLanguageID
= 0;
1457 /*************************************************************************
1458 * GetKerningPairs16 (GDI.332)
1460 INT16 WINAPI
GetKerningPairs16( HDC16 hDC
, INT16 cPairs
,
1461 LPKERNINGPAIR16 lpKerningPairs
)
1463 /* At this time kerning is ignored (set to 0) */
1465 FIXME("(%x,%d,%p): almost empty stub!\n", hDC
, cPairs
, lpKerningPairs
);
1466 for (i
= 0; i
< cPairs
; i
++)
1467 lpKerningPairs
[i
].iKernAmount
= 0;
1473 /*************************************************************************
1474 * GetKerningPairsA (GDI32.192)
1476 DWORD WINAPI
GetKerningPairsA( HDC hDC
, DWORD cPairs
,
1477 LPKERNINGPAIR lpKerningPairs
)
1480 FIXME("(%x,%ld,%p): almost empty stub!\n", hDC
, cPairs
, lpKerningPairs
);
1481 for (i
= 0; i
< cPairs
; i
++)
1482 lpKerningPairs
[i
].iKernAmount
= 0;
1487 /*************************************************************************
1488 * GetKerningPairsW (GDI32.193)
1490 DWORD WINAPI
GetKerningPairsW( HDC hDC
, DWORD cPairs
,
1491 LPKERNINGPAIR lpKerningPairs
)
1493 return GetKerningPairsA( hDC
, cPairs
, lpKerningPairs
);
1496 /*************************************************************************
1497 * TranslateCharsetInfo [GDI32.382]
1499 * Fills a CHARSETINFO structure for a character set, code page, or
1500 * font. This allows making the correspondance between different labelings
1501 * (character set, Windows, ANSI, and OEM codepages, and Unicode ranges)
1502 * of the same encoding.
1504 * Only one codepage will be set in lpCs->fs. If TCI_SRCFONTSIG is used,
1505 * only one codepage should be set in *lpSrc.
1508 * TRUE on success, FALSE on failure.
1511 BOOL WINAPI
TranslateCharsetInfo(
1513 if flags == TCI_SRCFONTSIG: pointer to fsCsb of a FONTSIGNATURE
1514 if flags == TCI_SRCCHARSET: a character set value
1515 if flags == TCI_SRCCODEPAGE: a code page value
1517 LPCHARSETINFO lpCs
, /* structure to receive charset information */
1518 DWORD flags
/* determines interpretation of lpSrc */
1522 case TCI_SRCFONTSIG
:
1523 while (!(*lpSrc
>>index
& 0x0001) && index
<MAXTCIINDEX
) index
++;
1525 case TCI_SRCCODEPAGE
:
1526 while ((UINT
) (lpSrc
) != FONT_tci
[index
].ciACP
&& index
< MAXTCIINDEX
) index
++;
1528 case TCI_SRCCHARSET
:
1529 while ((UINT
) (lpSrc
) != FONT_tci
[index
].ciCharset
&& index
< MAXTCIINDEX
) index
++;
1534 if (index
>= MAXTCIINDEX
|| FONT_tci
[index
].ciCharset
== DEFAULT_CHARSET
) return FALSE
;
1535 memcpy(lpCs
, &FONT_tci
[index
], sizeof(CHARSETINFO
));
1539 /*************************************************************************
1540 * GetFontLanguageInfo (GDI32.182)
1542 DWORD WINAPI
GetFontLanguageInfo(HDC hdc
) {
1543 /* return value 0 is correct for most cases anyway */
1544 FIXME("(%x):stub!\n", hdc
);
1548 /*************************************************************************
1549 * GetFontLanguageInfo (GDI.616)
1551 DWORD WINAPI
GetFontLanguageInfo16(HDC16 hdc
) {
1552 /* return value 0 is correct for most cases anyway */
1553 FIXME("(%x):stub!\n",hdc
);
1557 /*************************************************************************
1558 * GetFontData [GDI32.181] Retrieve data for TrueType font
1562 * success: Number of bytes returned
1563 * failure: GDI_ERROR
1567 * Calls SetLastError()
1573 DWORD WINAPI
GetFontData(HDC hdc
, DWORD table
, DWORD offset
,
1574 LPVOID buffer
, DWORD length
)
1576 FIXME("(%x,%ld,%ld,%p,%ld): stub\n", hdc
, table
, offset
, buffer
, length
);
1577 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
1581 /*************************************************************************
1582 * GetFontData16 [GDI.311]
1585 DWORD WINAPI
GetFontData16(HDC16 hdc
, DWORD dwTable
, DWORD dwOffset
,
1586 LPVOID lpvBuffer
, DWORD cbData
)
1588 return GetFontData(hdc
, dwTable
, dwOffset
, lpvBuffer
, cbData
);
1591 /*************************************************************************
1592 * GetCharacterPlacementA [GDI32.160]
1595 * the web browser control of ie4 calls this with dwFlags=0
1598 GetCharacterPlacementA(HDC hdc
, LPCSTR lpString
, INT uCount
,
1599 INT nMaxExtent
, GCP_RESULTSA
*lpResults
,
1605 TRACE("%s 0x%08x 0x%08x 0x%08lx:stub!\n",
1606 debugstr_a(lpString
), uCount
, nMaxExtent
, dwFlags
);
1608 TRACE("lpOrder=%p lpDx=%p lpCaretPos=%p lpClass=%p "
1609 "lpOutString=%p lpGlyphs=%p\n",
1610 lpResults
->lpOrder
, lpResults
->lpDx
, lpResults
->lpCaretPos
,
1611 lpResults
->lpClass
, lpResults
->lpOutString
, lpResults
->lpGlyphs
);
1613 if(dwFlags
) FIXME("flags 0x%08lx ignored\n", dwFlags
);
1614 if(lpResults
->lpOrder
) FIXME("reordering not implemented\n");
1615 if(lpResults
->lpCaretPos
) FIXME("caret positions not implemented\n");
1616 if(lpResults
->lpClass
) FIXME("classes not implemented\n");
1617 if(lpResults
->lpGlyphs
) FIXME("glyphs not implemented\n");
1619 /* copy will do if the GCP_REORDER flag is not set */
1620 if(lpResults
->lpOutString
)
1622 lstrcpynA(lpResults
->lpOutString
, lpString
, uCount
);
1625 if (lpResults
->lpDx
)
1628 for (i
=0; i
<uCount
;i
++)
1630 if (GetCharWidth32A(hdc
, lpString
[i
], lpString
[i
], &c
))
1631 lpResults
->lpDx
[i
]= c
;
1635 if (GetTextExtentPoint32A(hdc
, lpString
, uCount
, &size
))
1636 ret
= MAKELONG(size
.cx
, size
.cy
);
1641 /*************************************************************************
1642 * GetCharacterPlacementW [GDI32.161]
1645 GetCharacterPlacementW(HDC hdc
, LPCWSTR lpString
, INT uCount
,
1646 INT nMaxExtent
, GCP_RESULTSW
*lpResults
,
1649 /* return value 0 is correct for most cases anyway */
1654 /*************************************************************************
1655 * GetCharABCWidthsFloatA [GDI32.150]
1657 BOOL WINAPI
GetCharABCWidthsFloatA(HDC hdc
, UINT iFirstChar
, UINT iLastChar
,
1660 FIXME_(gdi
)("GetCharABCWidthsFloatA, stub\n");
1664 /*************************************************************************
1665 * GetCharABCWidthsFloatW [GDI32.151]
1667 BOOL WINAPI
GetCharABCWidthsFloatW(HDC hdc
, UINT iFirstChar
,
1668 UINT iLastChar
, LPABCFLOAT lpABCF
)
1670 FIXME_(gdi
)("GetCharABCWidthsFloatW, stub\n");
1674 /*************************************************************************
1675 * GetCharWidthFloatA [GDI32.156]
1677 BOOL WINAPI
GetCharWidthFloatA(HDC hdc
, UINT iFirstChar
,
1678 UINT iLastChar
, PFLOAT pxBuffer
)
1680 FIXME_(gdi
)("GetCharWidthFloatA, stub\n");
1684 /*************************************************************************
1685 * GetCharWidthFloatW [GDI32.157]
1687 BOOL WINAPI
GetCharWidthFloatW(HDC hdc
, UINT iFirstChar
,
1688 UINT iLastChar
, PFLOAT pxBuffer
)
1690 FIXME_(gdi
)("GetCharWidthFloatW, stub\n");