4 * Copyright 1993 Alexandre Julliard
6 * Copyright 2002,2003 Shachar Shemesh
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 #include "wine/port.h"
36 #include "gdi_private.h"
37 #include "wine/unicode.h"
38 #include "wine/debug.h"
40 WINE_DEFAULT_DEBUG_CHANNEL(font);
41 WINE_DECLARE_DEBUG_CHANNEL(gdi);
43 /* Device -> World size conversion */
45 /* Performs a device to world transformation on the specified width (which
46 * is in integer format).
48 static inline INT INTERNAL_XDSTOWS(DC *dc, INT width)
52 /* Perform operation with floating point */
53 floatWidth = (FLOAT)width * dc->xformVport2World.eM11;
54 /* Round to integers */
55 return GDI_ROUND(floatWidth);
58 /* Performs a device to world transformation on the specified size (which
59 * is in integer format).
61 static inline INT INTERNAL_YDSTOWS(DC *dc, INT height)
65 /* Perform operation with floating point */
66 floatHeight = (FLOAT)height * dc->xformVport2World.eM22;
67 /* Round to integers */
68 return GDI_ROUND(floatHeight);
71 static inline INT INTERNAL_XWSTODS(DC *dc, INT width)
74 pt[0].x = pt[0].y = 0;
77 LPtoDP(dc->hSelf, pt, 2);
78 return pt[1].x - pt[0].x;
81 static inline INT INTERNAL_YWSTODS(DC *dc, INT height)
84 pt[0].x = pt[0].y = 0;
87 LPtoDP(dc->hSelf, pt, 2);
88 return pt[1].y - pt[0].y;
91 static HGDIOBJ FONT_SelectObject( HGDIOBJ handle, void *obj, HDC hdc );
92 static INT FONT_GetObject16( HGDIOBJ handle, void *obj, INT count, LPVOID buffer );
93 static INT FONT_GetObjectA( HGDIOBJ handle, void *obj, INT count, LPVOID buffer );
94 static INT FONT_GetObjectW( HGDIOBJ handle, void *obj, INT count, LPVOID buffer );
95 static BOOL FONT_DeleteObject( HGDIOBJ handle, void *obj );
97 static const struct gdi_obj_funcs font_funcs =
99 FONT_SelectObject, /* pSelectObject */
100 FONT_GetObject16, /* pGetObject16 */
101 FONT_GetObjectA, /* pGetObjectA */
102 FONT_GetObjectW, /* pGetObjectW */
103 NULL, /* pUnrealizeObject */
104 FONT_DeleteObject /* pDeleteObject */
107 #define ENUM_UNICODE 0x00000001
108 #define ENUM_CALLED 0x00000002
118 LPLOGFONT16 lpLogFontParam;
119 FONTENUMPROC16 lpEnumFunc;
122 LPNEWTEXTMETRICEX16 lpTextMetric;
123 LPENUMLOGFONTEX16 lpLogFont;
124 SEGPTR segTextMetric;
134 LPLOGFONTW lpLogFontParam;
135 FONTENUMPROCW lpEnumFunc;
144 * For TranslateCharsetInfo
146 #define FS(x) {{0,0,0,0},{0x1<<(x),0}}
147 #define MAXTCIINDEX 32
148 static const CHARSETINFO FONT_tci[MAXTCIINDEX] = {
150 { ANSI_CHARSET, 1252, FS(0)},
151 { EASTEUROPE_CHARSET, 1250, FS(1)},
152 { RUSSIAN_CHARSET, 1251, FS(2)},
153 { GREEK_CHARSET, 1253, FS(3)},
154 { TURKISH_CHARSET, 1254, FS(4)},
155 { HEBREW_CHARSET, 1255, FS(5)},
156 { ARABIC_CHARSET, 1256, FS(6)},
157 { BALTIC_CHARSET, 1257, FS(7)},
158 { VIETNAMESE_CHARSET, 1258, FS(8)},
159 /* reserved by ANSI */
160 { DEFAULT_CHARSET, 0, FS(0)},
161 { DEFAULT_CHARSET, 0, FS(0)},
162 { DEFAULT_CHARSET, 0, FS(0)},
163 { DEFAULT_CHARSET, 0, FS(0)},
164 { DEFAULT_CHARSET, 0, FS(0)},
165 { DEFAULT_CHARSET, 0, FS(0)},
166 { DEFAULT_CHARSET, 0, FS(0)},
168 { THAI_CHARSET, 874, FS(16)},
169 { SHIFTJIS_CHARSET, 932, FS(17)},
170 { GB2312_CHARSET, 936, FS(18)},
171 { HANGEUL_CHARSET, 949, FS(19)},
172 { CHINESEBIG5_CHARSET, 950, FS(20)},
173 { JOHAB_CHARSET, 1361, FS(21)},
174 /* reserved for alternate ANSI and OEM */
175 { DEFAULT_CHARSET, 0, FS(0)},
176 { DEFAULT_CHARSET, 0, FS(0)},
177 { DEFAULT_CHARSET, 0, FS(0)},
178 { DEFAULT_CHARSET, 0, FS(0)},
179 { DEFAULT_CHARSET, 0, FS(0)},
180 { DEFAULT_CHARSET, 0, FS(0)},
181 { DEFAULT_CHARSET, 0, FS(0)},
182 { DEFAULT_CHARSET, 0, FS(0)},
183 /* reserved for system */
184 { DEFAULT_CHARSET, 0, FS(0)},
185 { SYMBOL_CHARSET, CP_SYMBOL, FS(31)},
188 /***********************************************************************
189 * LOGFONT conversion functions.
191 static void FONT_LogFontWTo16( const LOGFONTW* font32, LPLOGFONT16 font16 )
193 font16->lfHeight = font32->lfHeight;
194 font16->lfWidth = font32->lfWidth;
195 font16->lfEscapement = font32->lfEscapement;
196 font16->lfOrientation = font32->lfOrientation;
197 font16->lfWeight = font32->lfWeight;
198 font16->lfItalic = font32->lfItalic;
199 font16->lfUnderline = font32->lfUnderline;
200 font16->lfStrikeOut = font32->lfStrikeOut;
201 font16->lfCharSet = font32->lfCharSet;
202 font16->lfOutPrecision = font32->lfOutPrecision;
203 font16->lfClipPrecision = font32->lfClipPrecision;
204 font16->lfQuality = font32->lfQuality;
205 font16->lfPitchAndFamily = font32->lfPitchAndFamily;
206 WideCharToMultiByte( CP_ACP, 0, font32->lfFaceName, -1,
207 font16->lfFaceName, LF_FACESIZE, NULL, NULL );
208 font16->lfFaceName[LF_FACESIZE-1] = 0;
211 static void FONT_LogFont16ToW( const LOGFONT16 *font16, LPLOGFONTW font32 )
213 font32->lfHeight = font16->lfHeight;
214 font32->lfWidth = font16->lfWidth;
215 font32->lfEscapement = font16->lfEscapement;
216 font32->lfOrientation = font16->lfOrientation;
217 font32->lfWeight = font16->lfWeight;
218 font32->lfItalic = font16->lfItalic;
219 font32->lfUnderline = font16->lfUnderline;
220 font32->lfStrikeOut = font16->lfStrikeOut;
221 font32->lfCharSet = font16->lfCharSet;
222 font32->lfOutPrecision = font16->lfOutPrecision;
223 font32->lfClipPrecision = font16->lfClipPrecision;
224 font32->lfQuality = font16->lfQuality;
225 font32->lfPitchAndFamily = font16->lfPitchAndFamily;
226 MultiByteToWideChar( CP_ACP, 0, font16->lfFaceName, -1, font32->lfFaceName, LF_FACESIZE );
227 font32->lfFaceName[LF_FACESIZE-1] = 0;
230 static void FONT_LogFontAToW( const LOGFONTA *fontA, LPLOGFONTW fontW )
232 memcpy(fontW, fontA, sizeof(LOGFONTA) - LF_FACESIZE);
233 MultiByteToWideChar(CP_ACP, 0, fontA->lfFaceName, -1, fontW->lfFaceName,
235 fontW->lfFaceName[LF_FACESIZE-1] = 0;
238 static void FONT_LogFontWToA( const LOGFONTW *fontW, LPLOGFONTA fontA )
240 memcpy(fontA, fontW, sizeof(LOGFONTA) - LF_FACESIZE);
241 WideCharToMultiByte(CP_ACP, 0, fontW->lfFaceName, -1, fontA->lfFaceName,
242 LF_FACESIZE, NULL, NULL);
243 fontA->lfFaceName[LF_FACESIZE-1] = 0;
246 static void FONT_EnumLogFontExWTo16( const ENUMLOGFONTEXW *fontW, LPENUMLOGFONTEX16 font16 )
248 FONT_LogFontWTo16( (LPLOGFONTW)fontW, (LPLOGFONT16)font16);
250 WideCharToMultiByte( CP_ACP, 0, fontW->elfFullName, -1,
251 (LPSTR) font16->elfFullName, LF_FULLFACESIZE, NULL, NULL );
252 font16->elfFullName[LF_FULLFACESIZE-1] = '\0';
253 WideCharToMultiByte( CP_ACP, 0, fontW->elfStyle, -1,
254 (LPSTR) font16->elfStyle, LF_FACESIZE, NULL, NULL );
255 font16->elfStyle[LF_FACESIZE-1] = '\0';
256 WideCharToMultiByte( CP_ACP, 0, fontW->elfScript, -1,
257 (LPSTR) font16->elfScript, LF_FACESIZE, NULL, NULL );
258 font16->elfScript[LF_FACESIZE-1] = '\0';
261 static void FONT_EnumLogFontExWToA( const ENUMLOGFONTEXW *fontW, LPENUMLOGFONTEXA fontA )
263 FONT_LogFontWToA( (LPLOGFONTW)fontW, (LPLOGFONTA)fontA);
265 WideCharToMultiByte( CP_ACP, 0, fontW->elfFullName, -1,
266 (LPSTR) fontA->elfFullName, LF_FULLFACESIZE, NULL, NULL );
267 fontA->elfFullName[LF_FULLFACESIZE-1] = '\0';
268 WideCharToMultiByte( CP_ACP, 0, fontW->elfStyle, -1,
269 (LPSTR) fontA->elfStyle, LF_FACESIZE, NULL, NULL );
270 fontA->elfStyle[LF_FACESIZE-1] = '\0';
271 WideCharToMultiByte( CP_ACP, 0, fontW->elfScript, -1,
272 (LPSTR) fontA->elfScript, LF_FACESIZE, NULL, NULL );
273 fontA->elfScript[LF_FACESIZE-1] = '\0';
276 /***********************************************************************
277 * TEXTMETRIC conversion functions.
279 static void FONT_TextMetricWToA(const TEXTMETRICW *ptmW, LPTEXTMETRICA ptmA )
281 ptmA->tmHeight = ptmW->tmHeight;
282 ptmA->tmAscent = ptmW->tmAscent;
283 ptmA->tmDescent = ptmW->tmDescent;
284 ptmA->tmInternalLeading = ptmW->tmInternalLeading;
285 ptmA->tmExternalLeading = ptmW->tmExternalLeading;
286 ptmA->tmAveCharWidth = ptmW->tmAveCharWidth;
287 ptmA->tmMaxCharWidth = ptmW->tmMaxCharWidth;
288 ptmA->tmWeight = ptmW->tmWeight;
289 ptmA->tmOverhang = ptmW->tmOverhang;
290 ptmA->tmDigitizedAspectX = ptmW->tmDigitizedAspectX;
291 ptmA->tmDigitizedAspectY = ptmW->tmDigitizedAspectY;
292 ptmA->tmFirstChar = ptmW->tmFirstChar > 255 ? 255 : ptmW->tmFirstChar;
293 ptmA->tmLastChar = ptmW->tmLastChar > 255 ? 255 : ptmW->tmLastChar;
294 ptmA->tmDefaultChar = ptmW->tmDefaultChar > 255 ? 255 : ptmW->tmDefaultChar;
295 ptmA->tmBreakChar = ptmW->tmBreakChar > 255 ? 255 : ptmW->tmBreakChar;
296 ptmA->tmItalic = ptmW->tmItalic;
297 ptmA->tmUnderlined = ptmW->tmUnderlined;
298 ptmA->tmStruckOut = ptmW->tmStruckOut;
299 ptmA->tmPitchAndFamily = ptmW->tmPitchAndFamily;
300 ptmA->tmCharSet = ptmW->tmCharSet;
304 static void FONT_NewTextMetricExWTo16(const NEWTEXTMETRICEXW *ptmW, LPNEWTEXTMETRICEX16 ptm16 )
306 ptm16->ntmTm.tmHeight = ptmW->ntmTm.tmHeight;
307 ptm16->ntmTm.tmAscent = ptmW->ntmTm.tmAscent;
308 ptm16->ntmTm.tmDescent = ptmW->ntmTm.tmDescent;
309 ptm16->ntmTm.tmInternalLeading = ptmW->ntmTm.tmInternalLeading;
310 ptm16->ntmTm.tmExternalLeading = ptmW->ntmTm.tmExternalLeading;
311 ptm16->ntmTm.tmAveCharWidth = ptmW->ntmTm.tmAveCharWidth;
312 ptm16->ntmTm.tmMaxCharWidth = ptmW->ntmTm.tmMaxCharWidth;
313 ptm16->ntmTm.tmWeight = ptmW->ntmTm.tmWeight;
314 ptm16->ntmTm.tmOverhang = ptmW->ntmTm.tmOverhang;
315 ptm16->ntmTm.tmDigitizedAspectX = ptmW->ntmTm.tmDigitizedAspectX;
316 ptm16->ntmTm.tmDigitizedAspectY = ptmW->ntmTm.tmDigitizedAspectY;
317 ptm16->ntmTm.tmFirstChar = ptmW->ntmTm.tmFirstChar > 255 ? 255 : ptmW->ntmTm.tmFirstChar;
318 ptm16->ntmTm.tmLastChar = ptmW->ntmTm.tmLastChar > 255 ? 255 : ptmW->ntmTm.tmLastChar;
319 ptm16->ntmTm.tmDefaultChar = ptmW->ntmTm.tmDefaultChar > 255 ? 255 : ptmW->ntmTm.tmDefaultChar;
320 ptm16->ntmTm.tmBreakChar = ptmW->ntmTm.tmBreakChar > 255 ? 255 : ptmW->ntmTm.tmBreakChar;
321 ptm16->ntmTm.tmItalic = ptmW->ntmTm.tmItalic;
322 ptm16->ntmTm.tmUnderlined = ptmW->ntmTm.tmUnderlined;
323 ptm16->ntmTm.tmStruckOut = ptmW->ntmTm.tmStruckOut;
324 ptm16->ntmTm.tmPitchAndFamily = ptmW->ntmTm.tmPitchAndFamily;
325 ptm16->ntmTm.tmCharSet = ptmW->ntmTm.tmCharSet;
326 ptm16->ntmTm.ntmFlags = ptmW->ntmTm.ntmFlags;
327 ptm16->ntmTm.ntmSizeEM = ptmW->ntmTm.ntmSizeEM;
328 ptm16->ntmTm.ntmCellHeight = ptmW->ntmTm.ntmCellHeight;
329 ptm16->ntmTm.ntmAvgWidth = ptmW->ntmTm.ntmAvgWidth;
330 memcpy(&ptm16->ntmFontSig, &ptmW->ntmFontSig, sizeof(FONTSIGNATURE));
333 static void FONT_NewTextMetricExWToA(const NEWTEXTMETRICEXW *ptmW, NEWTEXTMETRICEXA *ptmA )
335 FONT_TextMetricWToA((LPTEXTMETRICW)ptmW, (LPTEXTMETRICA)ptmA);
336 ptmA->ntmTm.ntmFlags = ptmW->ntmTm.ntmFlags;
337 ptmA->ntmTm.ntmSizeEM = ptmW->ntmTm.ntmSizeEM;
338 ptmA->ntmTm.ntmCellHeight = ptmW->ntmTm.ntmCellHeight;
339 ptmA->ntmTm.ntmAvgWidth = ptmW->ntmTm.ntmAvgWidth;
340 memcpy(&ptmA->ntmFontSig, &ptmW->ntmFontSig, sizeof(FONTSIGNATURE));
344 /***********************************************************************
347 * Returns a '\0' terminated Unicode translation of str using the
348 * charset of the currently selected font in hdc. If count is -1 then
349 * str is assumed to be '\0' terminated, otherwise it contains the
350 * number of bytes to convert. If plenW is non-NULL, on return it
351 * will point to the number of WCHARs (excluding the '\0') that have
352 * been written. If pCP is non-NULL, on return it will point to the
353 * codepage used in the conversion.
354 * The caller should free the returned LPWSTR from the process
357 static LPWSTR FONT_mbtowc(HDC hdc, LPCSTR str, INT count, INT *plenW, UINT *pCP)
363 int charset = GetTextCharset(hdc);
365 /* Hmm, nicely designed api this one! */
366 if(TranslateCharsetInfo((DWORD*)charset, &csi, TCI_SRCCHARSET))
373 case DEFAULT_CHARSET:
384 /* FIXME: These have no place here, but because x11drv
385 enumerates fonts with these (made up) charsets some apps
386 might use them and then the FIXME below would become
387 annoying. Now we could pick the intended codepage for
388 each of these, but since it's broken anyway we'll just
389 use CP_ACP and hope it'll go away...
395 FIXME("Can't find codepage for charset %d\n", charset);
400 TRACE("charset %d => cp %d\n", charset, cp);
402 if(count == -1) count = strlen(str);
403 lenW = MultiByteToWideChar(cp, 0, str, count, NULL, 0);
404 strW = HeapAlloc(GetProcessHeap(), 0, (lenW + 1) * sizeof(WCHAR));
405 MultiByteToWideChar(cp, 0, str, count, strW, lenW);
407 TRACE("mapped %s -> %s\n", debugstr_an(str, count), debugstr_wn(strW, lenW));
408 if(plenW) *plenW = lenW;
414 /***********************************************************************
415 * CreateFontIndirectA (GDI32.@)
417 HFONT WINAPI CreateFontIndirectA( const LOGFONTA *plfA )
422 FONT_LogFontAToW( plfA, &lfW );
423 return CreateFontIndirectW( &lfW );
425 return CreateFontIndirectW( NULL );
429 /***********************************************************************
430 * CreateFontIndirectW (GDI32.@)
432 HFONT WINAPI CreateFontIndirectW( const LOGFONTW *plf )
439 if ((fontPtr = GDI_AllocObject( sizeof(FONTOBJ), FONT_MAGIC,
440 (HGDIOBJ *)&hFont, &font_funcs )))
442 static const WCHAR ItalicW[] = {' ','I','t','a','l','i','c','\0'};
443 static const WCHAR BoldW[] = {' ','B','o','l','d','\0'};
444 WCHAR *pFaceNameItalicSuffix, *pFaceNameBoldSuffix;
445 WCHAR* pFaceNameSuffix = NULL;
447 memcpy( &fontPtr->logfont, plf, sizeof(LOGFONTW) );
449 TRACE("(%ld %ld %ld %ld %x %d %x %d %d) %s %s %s %s => %p\n",
450 plf->lfHeight, plf->lfWidth,
451 plf->lfEscapement, plf->lfOrientation,
452 plf->lfPitchAndFamily,
453 plf->lfOutPrecision, plf->lfClipPrecision,
454 plf->lfQuality, plf->lfCharSet,
455 debugstr_w(plf->lfFaceName),
456 plf->lfWeight > 400 ? "Bold" : "",
457 plf->lfItalic ? "Italic" : "",
458 plf->lfUnderline ? "Underline" : "", hFont);
460 if (plf->lfEscapement != plf->lfOrientation) {
461 /* this should really depend on whether GM_ADVANCED is set */
462 fontPtr->logfont.lfOrientation = fontPtr->logfont.lfEscapement;
463 WARN("orientation angle %f set to "
464 "escapement angle %f for new font %p\n",
465 plf->lfOrientation/10., plf->lfEscapement/10., hFont);
468 pFaceNameItalicSuffix = strstrW(fontPtr->logfont.lfFaceName, ItalicW);
469 if (pFaceNameItalicSuffix) {
470 fontPtr->logfont.lfItalic = TRUE;
471 pFaceNameSuffix = pFaceNameItalicSuffix;
474 pFaceNameBoldSuffix = strstrW(fontPtr->logfont.lfFaceName, BoldW);
475 if (pFaceNameBoldSuffix) {
476 if (fontPtr->logfont.lfWeight < FW_BOLD) {
477 fontPtr->logfont.lfWeight = FW_BOLD;
479 if (!pFaceNameSuffix ||
480 (pFaceNameBoldSuffix < pFaceNameSuffix)) {
481 pFaceNameSuffix = pFaceNameBoldSuffix;
485 if (pFaceNameSuffix) *pFaceNameSuffix = 0;
487 GDI_ReleaseObj( hFont );
490 else WARN("(NULL) => NULL\n");
495 /*************************************************************************
496 * CreateFontA (GDI32.@)
498 HFONT WINAPI CreateFontA( INT height, INT width, INT esc,
499 INT orient, INT weight, DWORD italic,
500 DWORD underline, DWORD strikeout, DWORD charset,
501 DWORD outpres, DWORD clippres, DWORD quality,
502 DWORD pitch, LPCSTR name )
506 logfont.lfHeight = height;
507 logfont.lfWidth = width;
508 logfont.lfEscapement = esc;
509 logfont.lfOrientation = orient;
510 logfont.lfWeight = weight;
511 logfont.lfItalic = italic;
512 logfont.lfUnderline = underline;
513 logfont.lfStrikeOut = strikeout;
514 logfont.lfCharSet = charset;
515 logfont.lfOutPrecision = outpres;
516 logfont.lfClipPrecision = clippres;
517 logfont.lfQuality = quality;
518 logfont.lfPitchAndFamily = pitch;
521 lstrcpynA(logfont.lfFaceName,name,sizeof(logfont.lfFaceName));
523 logfont.lfFaceName[0] = '\0';
525 return CreateFontIndirectA( &logfont );
528 /*************************************************************************
529 * CreateFontW (GDI32.@)
531 HFONT WINAPI CreateFontW( INT height, INT width, INT esc,
532 INT orient, INT weight, DWORD italic,
533 DWORD underline, DWORD strikeout, DWORD charset,
534 DWORD outpres, DWORD clippres, DWORD quality,
535 DWORD pitch, LPCWSTR name )
539 logfont.lfHeight = height;
540 logfont.lfWidth = width;
541 logfont.lfEscapement = esc;
542 logfont.lfOrientation = orient;
543 logfont.lfWeight = weight;
544 logfont.lfItalic = italic;
545 logfont.lfUnderline = underline;
546 logfont.lfStrikeOut = strikeout;
547 logfont.lfCharSet = charset;
548 logfont.lfOutPrecision = outpres;
549 logfont.lfClipPrecision = clippres;
550 logfont.lfQuality = quality;
551 logfont.lfPitchAndFamily = pitch;
554 lstrcpynW(logfont.lfFaceName, name,
555 sizeof(logfont.lfFaceName) / sizeof(WCHAR));
557 logfont.lfFaceName[0] = '\0';
559 return CreateFontIndirectW( &logfont );
563 /***********************************************************************
566 * If the driver supports vector fonts we create a gdi font first and
567 * then call the driver to give it a chance to supply its own device
568 * font. If the driver wants to do this it returns TRUE and we can
569 * delete the gdi font, if the driver wants to use the gdi font it
570 * should return FALSE, to signal an error return GDI_ERROR. For
571 * drivers that don't support vector fonts they must supply their own
574 static HGDIOBJ FONT_SelectObject( HGDIOBJ handle, void *obj, HDC hdc )
577 DC *dc = DC_GetDCPtr( hdc );
581 if (dc->hFont != handle || dc->gdiFont == NULL)
583 if(GetDeviceCaps(dc->hSelf, TEXTCAPS) & TC_VA_ABLE)
584 dc->gdiFont = WineEngCreateFontInstance(dc, handle);
587 if (dc->funcs->pSelectFont) ret = dc->funcs->pSelectFont( dc->physDev, handle, dc->gdiFont );
589 if (ret && dc->gdiFont) dc->gdiFont = 0;
591 if (ret == HGDI_ERROR)
592 ret = 0; /* SelectObject returns 0 on error */
598 GDI_ReleaseObj( hdc );
603 /***********************************************************************
606 static INT FONT_GetObject16( HGDIOBJ handle, void *obj, INT count, LPVOID buffer )
611 FONT_LogFontWTo16( &font->logfont, &lf16 );
613 if (count > sizeof(LOGFONT16)) count = sizeof(LOGFONT16);
614 memcpy( buffer, &lf16, count );
618 /***********************************************************************
621 static INT FONT_GetObjectA( HGDIOBJ handle, void *obj, INT count, LPVOID buffer )
628 FONT_LogFontWToA( &font->logfont, &lfA );
630 if (count > sizeof(lfA)) count = sizeof(lfA);
631 memcpy( buffer, &lfA, count );
635 /***********************************************************************
638 static INT FONT_GetObjectW( HGDIOBJ handle, void *obj, INT count, LPVOID buffer )
642 return sizeof(LOGFONTW);
643 if (count > sizeof(LOGFONTW)) count = sizeof(LOGFONTW);
644 memcpy( buffer, &font->logfont, count );
649 /***********************************************************************
652 static BOOL FONT_DeleteObject( HGDIOBJ handle, void *obj )
654 WineEngDestroyFontInstance( handle );
655 return GDI_FreeObject( handle, obj );
659 /***********************************************************************
660 * FONT_EnumInstance16
662 * Called by the device driver layer to pass font info
663 * down to the application.
665 * Note: plf is really an ENUMLOGFONTEXW, and ptm is a NEWTEXTMETRICEXW.
666 * We have to use other types because of the FONTENUMPROCW definition.
668 static INT CALLBACK FONT_EnumInstance16( const LOGFONTW *plf, const TEXTMETRICW *ptm,
669 DWORD fType, LPARAM lp )
671 fontEnum16 *pfe = (fontEnum16*)lp;
675 if( pfe->lpLogFontParam->lfCharSet == DEFAULT_CHARSET ||
676 pfe->lpLogFontParam->lfCharSet == plf->lfCharSet )
681 FONT_EnumLogFontExWTo16((const ENUMLOGFONTEXW *)plf, pfe->lpLogFont);
682 FONT_NewTextMetricExWTo16((const NEWTEXTMETRICEXW *)ptm, pfe->lpTextMetric);
683 pfe->dwFlags |= ENUM_CALLED;
684 GDI_ReleaseObj( pfe->hdc ); /* release the GDI lock */
686 args[6] = SELECTOROF(pfe->segLogFont);
687 args[5] = OFFSETOF(pfe->segLogFont);
688 args[4] = SELECTOROF(pfe->segTextMetric);
689 args[3] = OFFSETOF(pfe->segTextMetric);
691 args[1] = HIWORD(pfe->lpData);
692 args[0] = LOWORD(pfe->lpData);
693 WOWCallback16Ex( (DWORD)pfe->lpEnumFunc, WCB16_PASCAL, sizeof(args), args, &result );
694 ret = LOWORD(result);
696 /* get the lock again and make sure the DC is still valid */
697 dc = DC_GetDCPtr( pfe->hdc );
698 if (!dc || dc != pfe->dc || dc->physDev != pfe->physDev)
700 if (dc) GDI_ReleaseObj( pfe->hdc );
701 pfe->hdc = 0; /* make sure we don't try to release it later on */
708 /***********************************************************************
711 * Note: plf is really an ENUMLOGFONTEXW, and ptm is a NEWTEXTMETRICEXW.
712 * We have to use other types because of the FONTENUMPROCW definition.
714 static INT CALLBACK FONT_EnumInstance( const LOGFONTW *plf, const TEXTMETRICW *ptm,
715 DWORD fType, LPARAM lp )
717 fontEnum32 *pfe = (fontEnum32*)lp;
721 /* lfCharSet is at the same offset in both LOGFONTA and LOGFONTW */
722 if((pfe->lpLogFontParam->lfCharSet == DEFAULT_CHARSET ||
723 pfe->lpLogFontParam->lfCharSet == plf->lfCharSet) &&
724 (!(fType & RASTER_FONTTYPE) || GetDeviceCaps(pfe->hdc, TEXTCAPS) & TC_RA_ABLE) )
726 /* convert font metrics */
727 ENUMLOGFONTEXA logfont;
728 NEWTEXTMETRICEXA tmA;
730 pfe->dwFlags |= ENUM_CALLED;
731 if (!(pfe->dwFlags & ENUM_UNICODE))
733 FONT_EnumLogFontExWToA( (const ENUMLOGFONTEXW *)plf, &logfont);
734 FONT_NewTextMetricExWToA( (const NEWTEXTMETRICEXW *)ptm, &tmA );
735 plf = (LOGFONTW *)&logfont.elfLogFont;
736 ptm = (TEXTMETRICW *)&tmA;
738 GDI_ReleaseObj( pfe->hdc ); /* release the GDI lock */
740 ret = pfe->lpEnumFunc( plf, ptm, fType, pfe->lpData );
742 /* get the lock again and make sure the DC is still valid */
743 dc = DC_GetDCPtr( pfe->hdc );
744 if (!dc || dc != pfe->dc || dc->physDev != pfe->physDev)
746 if (dc) GDI_ReleaseObj( pfe->hdc );
747 pfe->hdc = 0; /* make sure we don't try to release it later on */
754 /***********************************************************************
755 * EnumFontFamiliesEx (GDI.613)
757 INT16 WINAPI EnumFontFamiliesEx16( HDC16 hDC, LPLOGFONT16 plf,
758 FONTENUMPROC16 efproc, LPARAM lParam,
763 DC* dc = DC_GetDCPtr( HDC_32(hDC) );
764 NEWTEXTMETRICEX16 tm16;
765 ENUMLOGFONTEX16 lf16;
770 FONT_LogFont16ToW(plf, &lfW);
772 fe16.hdc = HDC_32(hDC);
774 fe16.physDev = dc->physDev;
775 fe16.lpLogFontParam = plf;
776 fe16.lpEnumFunc = efproc;
777 fe16.lpData = lParam;
778 fe16.lpTextMetric = &tm16;
779 fe16.lpLogFont = &lf16;
780 fe16.segTextMetric = MapLS( &tm16 );
781 fe16.segLogFont = MapLS( &lf16 );
784 enum_gdi_fonts = GetDeviceCaps(fe16.hdc, TEXTCAPS) & TC_VA_ABLE;
786 if (!dc->funcs->pEnumDeviceFonts && !enum_gdi_fonts)
793 ret = WineEngEnumFonts( &lfW, FONT_EnumInstance16, (LPARAM)&fe16 );
794 fe16.dwFlags &= ~ENUM_CALLED;
795 if (ret && dc->funcs->pEnumDeviceFonts) {
796 ret2 = dc->funcs->pEnumDeviceFonts( dc->physDev, &lfW, FONT_EnumInstance16, (LPARAM)&fe16 );
797 if(fe16.dwFlags & ENUM_CALLED) /* update ret iff a font gets enumed */
801 UnMapLS( fe16.segTextMetric );
802 UnMapLS( fe16.segLogFont );
803 if (fe16.hdc) GDI_ReleaseObj( fe16.hdc );
807 /***********************************************************************
808 * FONT_EnumFontFamiliesEx
810 static INT FONT_EnumFontFamiliesEx( HDC hDC, LPLOGFONTW plf,
811 FONTENUMPROCW efproc,
812 LPARAM lParam, DWORD dwUnicode)
815 DC *dc = DC_GetDCPtr( hDC );
821 TRACE("lfFaceName = %s lfCharset = %d\n", debugstr_w(plf->lfFaceName),
823 fe32.lpLogFontParam = plf;
824 fe32.lpEnumFunc = efproc;
825 fe32.lpData = lParam;
826 fe32.dwFlags = dwUnicode;
829 fe32.physDev = dc->physDev;
831 enum_gdi_fonts = GetDeviceCaps(hDC, TEXTCAPS) & TC_VA_ABLE;
833 if (!dc->funcs->pEnumDeviceFonts && !enum_gdi_fonts)
840 ret = WineEngEnumFonts( plf, FONT_EnumInstance, (LPARAM)&fe32 );
841 fe32.dwFlags &= ~ENUM_CALLED;
842 if (ret && dc->funcs->pEnumDeviceFonts) {
843 ret2 = dc->funcs->pEnumDeviceFonts( dc->physDev, plf, FONT_EnumInstance, (LPARAM)&fe32 );
844 if(fe32.dwFlags & ENUM_CALLED) /* update ret iff a font gets enumed */
848 if (fe32.hdc) GDI_ReleaseObj( fe32.hdc );
852 /***********************************************************************
853 * EnumFontFamiliesExW (GDI32.@)
855 INT WINAPI EnumFontFamiliesExW( HDC hDC, LPLOGFONTW plf,
856 FONTENUMPROCW efproc,
857 LPARAM lParam, DWORD dwFlags )
859 return FONT_EnumFontFamiliesEx( hDC, plf, efproc, lParam, ENUM_UNICODE );
862 /***********************************************************************
863 * EnumFontFamiliesExA (GDI32.@)
865 INT WINAPI EnumFontFamiliesExA( HDC hDC, LPLOGFONTA plf,
866 FONTENUMPROCA efproc,
867 LPARAM lParam, DWORD dwFlags)
870 FONT_LogFontAToW( plf, &lfW );
872 return FONT_EnumFontFamiliesEx( hDC, &lfW, (FONTENUMPROCW)efproc, lParam, 0);
875 /***********************************************************************
876 * EnumFontFamilies (GDI.330)
878 INT16 WINAPI EnumFontFamilies16( HDC16 hDC, LPCSTR lpFamily,
879 FONTENUMPROC16 efproc, LPARAM lpData )
883 lf.lfCharSet = DEFAULT_CHARSET;
884 if( lpFamily ) lstrcpynA( lf.lfFaceName, lpFamily, LF_FACESIZE );
885 else lf.lfFaceName[0] = '\0';
887 return EnumFontFamiliesEx16( hDC, &lf, efproc, lpData, 0 );
890 /***********************************************************************
891 * EnumFontFamiliesA (GDI32.@)
893 INT WINAPI EnumFontFamiliesA( HDC hDC, LPCSTR lpFamily,
894 FONTENUMPROCA efproc, LPARAM lpData )
898 lf.lfCharSet = DEFAULT_CHARSET;
899 if( lpFamily ) lstrcpynA( lf.lfFaceName, lpFamily, LF_FACESIZE );
900 else lf.lfFaceName[0] = lf.lfFaceName[1] = '\0';
902 return EnumFontFamiliesExA( hDC, &lf, efproc, lpData, 0 );
905 /***********************************************************************
906 * EnumFontFamiliesW (GDI32.@)
908 INT WINAPI EnumFontFamiliesW( HDC hDC, LPCWSTR lpFamily,
909 FONTENUMPROCW efproc, LPARAM lpData )
913 lf.lfCharSet = DEFAULT_CHARSET;
914 if( lpFamily ) lstrcpynW( lf.lfFaceName, lpFamily, LF_FACESIZE );
915 else lf.lfFaceName[0] = 0;
917 return EnumFontFamiliesExW( hDC, &lf, efproc, lpData, 0 );
920 /***********************************************************************
923 INT16 WINAPI EnumFonts16( HDC16 hDC, LPCSTR lpName, FONTENUMPROC16 efproc,
926 return EnumFontFamilies16( hDC, lpName, efproc, lpData );
929 /***********************************************************************
930 * EnumFontsA (GDI32.@)
932 INT WINAPI EnumFontsA( HDC hDC, LPCSTR lpName, FONTENUMPROCA efproc,
935 return EnumFontFamiliesA( hDC, lpName, efproc, lpData );
938 /***********************************************************************
939 * EnumFontsW (GDI32.@)
941 INT WINAPI EnumFontsW( HDC hDC, LPCWSTR lpName, FONTENUMPROCW efproc,
944 return EnumFontFamiliesW( hDC, lpName, efproc, lpData );
948 /***********************************************************************
949 * GetTextCharacterExtra (GDI32.@)
951 INT WINAPI GetTextCharacterExtra( HDC hdc )
954 DC *dc = DC_GetDCPtr( hdc );
955 if (!dc) return 0x80000000;
957 GDI_ReleaseObj( hdc );
962 /***********************************************************************
963 * SetTextCharacterExtra (GDI32.@)
965 INT WINAPI SetTextCharacterExtra( HDC hdc, INT extra )
968 DC * dc = DC_GetDCPtr( hdc );
969 if (!dc) return 0x80000000;
970 if (dc->funcs->pSetTextCharacterExtra)
971 prev = dc->funcs->pSetTextCharacterExtra( dc->physDev, extra );
974 prev = dc->charExtra;
975 dc->charExtra = extra;
977 GDI_ReleaseObj( hdc );
982 /***********************************************************************
983 * SetTextJustification (GDI32.@)
985 BOOL WINAPI SetTextJustification( HDC hdc, INT extra, INT breaks )
988 DC * dc = DC_GetDCPtr( hdc );
989 if (!dc) return FALSE;
990 if (dc->funcs->pSetTextJustification)
991 ret = dc->funcs->pSetTextJustification( dc->physDev, extra, breaks );
994 extra = abs((extra * dc->vportExtX + dc->wndExtX / 2) / dc->wndExtX);
995 if (!extra) breaks = 0;
998 dc->breakExtra = extra / breaks;
999 dc->breakRem = extra - (breaks * dc->breakExtra);
1007 GDI_ReleaseObj( hdc );
1012 /***********************************************************************
1013 * GetTextFaceA (GDI32.@)
1015 INT WINAPI GetTextFaceA( HDC hdc, INT count, LPSTR name )
1017 INT res = GetTextFaceW(hdc, 0, NULL);
1018 LPWSTR nameW = HeapAlloc( GetProcessHeap(), 0, res * 2 );
1019 GetTextFaceW( hdc, res, nameW );
1023 if (count && !WideCharToMultiByte( CP_ACP, 0, nameW, -1, name, count, NULL, NULL))
1028 res = WideCharToMultiByte( CP_ACP, 0, nameW, -1, NULL, 0, NULL, NULL);
1029 HeapFree( GetProcessHeap(), 0, nameW );
1033 /***********************************************************************
1034 * GetTextFaceW (GDI32.@)
1036 INT WINAPI GetTextFaceW( HDC hdc, INT count, LPWSTR name )
1041 DC * dc = DC_GetDCPtr( hdc );
1045 ret = WineEngGetTextFace(dc->gdiFont, count, name);
1046 else if ((font = (FONTOBJ *) GDI_GetObjPtr( dc->hFont, FONT_MAGIC )))
1050 lstrcpynW( name, font->logfont.lfFaceName, count );
1051 ret = strlenW(name);
1053 else ret = strlenW(font->logfont.lfFaceName) + 1;
1054 GDI_ReleaseObj( dc->hFont );
1056 GDI_ReleaseObj( hdc );
1061 /***********************************************************************
1062 * GetTextExtentPoint32A (GDI32.@)
1064 BOOL WINAPI GetTextExtentPoint32A( HDC hdc, LPCSTR str, INT count,
1069 LPWSTR p = FONT_mbtowc(hdc, str, count, &wlen, NULL);
1072 ret = GetTextExtentPoint32W( hdc, p, wlen, size );
1073 HeapFree( GetProcessHeap(), 0, p );
1076 TRACE("(%p %s %d %p): returning %ld x %ld\n",
1077 hdc, debugstr_an (str, count), count, size, size->cx, size->cy );
1082 /***********************************************************************
1083 * GetTextExtentPoint32W [GDI32.@]
1085 * Computes width/height for a string.
1087 * Computes width and height of the specified string.
1093 BOOL WINAPI GetTextExtentPoint32W(
1094 HDC hdc, /* [in] Handle of device context */
1095 LPCWSTR str, /* [in] Address of text string */
1096 INT count, /* [in] Number of characters in string */
1097 LPSIZE size) /* [out] Address of structure for string size */
1100 DC * dc = DC_GetDCPtr( hdc );
1101 if (!dc) return FALSE;
1104 ret = WineEngGetTextExtentPoint(dc->gdiFont, str, count, size);
1105 else if(dc->funcs->pGetTextExtentPoint)
1106 ret = dc->funcs->pGetTextExtentPoint( dc->physDev, str, count, size );
1110 size->cx = abs(INTERNAL_XDSTOWS(dc, size->cx));
1111 size->cy = abs(INTERNAL_YDSTOWS(dc, size->cy));
1112 size->cx += count * dc->charExtra + dc->breakRem;
1115 GDI_ReleaseObj( hdc );
1117 TRACE("(%p %s %d %p): returning %ld x %ld\n",
1118 hdc, debugstr_wn (str, count), count, size, size->cx, size->cy );
1122 /***********************************************************************
1123 * GetTextExtentPointI [GDI32.@]
1125 * Computes width and height of the array of glyph indices.
1131 BOOL WINAPI GetTextExtentPointI(
1132 HDC hdc, /* [in] Handle of device context */
1133 const WORD *indices, /* [in] Address of glyph index array */
1134 INT count, /* [in] Number of glyphs in array */
1135 LPSIZE size) /* [out] Address of structure for string size */
1138 DC * dc = DC_GetDCPtr( hdc );
1139 if (!dc) return FALSE;
1142 ret = WineEngGetTextExtentPointI(dc->gdiFont, indices, count, size);
1143 size->cx = abs(INTERNAL_XDSTOWS(dc, size->cx));
1144 size->cy = abs(INTERNAL_YDSTOWS(dc, size->cy));
1145 size->cx += count * dc->charExtra;
1147 else if(dc->funcs->pGetTextExtentPoint) {
1148 FIXME("calling GetTextExtentPoint\n");
1149 ret = dc->funcs->pGetTextExtentPoint( dc->physDev, (LPCWSTR)indices, count, size );
1152 GDI_ReleaseObj( hdc );
1154 TRACE("(%p %p %d %p): returning %ld x %ld\n",
1155 hdc, indices, count, size, size->cx, size->cy );
1160 /***********************************************************************
1161 * GetTextExtentPointA (GDI32.@)
1163 BOOL WINAPI GetTextExtentPointA( HDC hdc, LPCSTR str, INT count,
1166 TRACE("not bug compatible.\n");
1167 return GetTextExtentPoint32A( hdc, str, count, size );
1170 /***********************************************************************
1171 * GetTextExtentPointW (GDI32.@)
1173 BOOL WINAPI GetTextExtentPointW( HDC hdc, LPCWSTR str, INT count,
1176 TRACE("not bug compatible.\n");
1177 return GetTextExtentPoint32W( hdc, str, count, size );
1181 /***********************************************************************
1182 * GetTextExtentExPointA (GDI32.@)
1184 BOOL WINAPI GetTextExtentExPointA( HDC hdc, LPCSTR str, INT count,
1185 INT maxExt, LPINT lpnFit,
1186 LPINT alpDx, LPSIZE size )
1190 LPWSTR p = FONT_mbtowc( hdc, str, count, &wlen, NULL);
1191 ret = GetTextExtentExPointW( hdc, p, wlen, maxExt, lpnFit, alpDx, size);
1192 if (lpnFit) *lpnFit = WideCharToMultiByte(CP_ACP,0,p,*lpnFit,NULL,0,NULL,NULL);
1193 HeapFree( GetProcessHeap(), 0, p );
1198 /***********************************************************************
1199 * GetTextExtentExPointW (GDI32.@)
1201 * Return the size of the string as it would be if it was output properly by
1204 * This should include
1205 * - Intercharacter spacing
1206 * - justification spacing (not yet done)
1207 * - kerning? see below
1209 * Kerning. Since kerning would be carried out by the rendering code it should
1210 * be done by the driver. However they don't support it yet. Also I am not
1211 * yet persuaded that (certainly under Win95) any kerning is actually done.
1213 * str: According to MSDN this should be null-terminated. That is not true; a
1214 * null will not terminate it early.
1215 * size: Certainly under Win95 this appears buggy or weird if *lpnFit is less
1216 * than count. I have seen it be either the size of the full string or
1217 * 1 less than the size of the full string. I have not seen it bear any
1218 * resemblance to the portion that would fit.
1219 * lpnFit: What exactly is fitting? Stupidly, in my opinion, it includes the
1220 * trailing intercharacter spacing and any trailing justification.
1223 * Currently we do this by measuring each character etc. We should do it by
1224 * passing the request to the driver, perhaps by extending the
1225 * pGetTextExtentPoint function to take the alpDx argument. That would avoid
1226 * thinking about kerning issues and rounding issues in the justification.
1229 BOOL WINAPI GetTextExtentExPointW( HDC hdc, LPCWSTR str, INT count,
1230 INT maxExt, LPINT lpnFit,
1231 LPINT alpDx, LPSIZE size )
1233 int index, nFit, extent;
1237 TRACE("(%p, %s, %d)\n",hdc,debugstr_wn(str,count),maxExt);
1239 size->cx = size->cy = nFit = extent = 0;
1240 for(index = 0; index < count; index++)
1242 if(!GetTextExtentPoint32W( hdc, str, 1, &tSize )) goto done;
1243 /* GetTextExtentPoint includes intercharacter spacing. */
1244 /* FIXME - justification needs doing yet. Remember that the base
1245 * data will not be in logical coordinates.
1248 if( !lpnFit || extent <= maxExt )
1249 /* It is allowed to be equal. */
1252 if( alpDx ) alpDx[index] = extent;
1254 if( tSize.cy > size->cy ) size->cy = tSize.cy;
1258 if(lpnFit) *lpnFit = nFit;
1261 TRACE("returning %d %ld x %ld\n",nFit,size->cx,size->cy);
1267 /***********************************************************************
1268 * GetTextMetricsA (GDI32.@)
1270 BOOL WINAPI GetTextMetricsA( HDC hdc, TEXTMETRICA *metrics )
1274 if (!GetTextMetricsW( hdc, &tm32 )) return FALSE;
1275 FONT_TextMetricWToA( &tm32, metrics );
1279 /***********************************************************************
1280 * GetTextMetricsW (GDI32.@)
1282 BOOL WINAPI GetTextMetricsW( HDC hdc, TEXTMETRICW *metrics )
1285 DC * dc = DC_GetDCPtr( hdc );
1286 if (!dc) return FALSE;
1289 ret = WineEngGetTextMetrics(dc->gdiFont, metrics);
1290 else if (dc->funcs->pGetTextMetrics)
1291 ret = dc->funcs->pGetTextMetrics( dc->physDev, metrics );
1295 /* device layer returns values in device units
1296 * therefore we have to convert them to logical */
1298 #define WDPTOLP(x) ((x<0)? \
1299 (-abs(INTERNAL_XDSTOWS(dc, (x)))): \
1300 (abs(INTERNAL_XDSTOWS(dc, (x)))))
1301 #define HDPTOLP(y) ((y<0)? \
1302 (-abs(INTERNAL_YDSTOWS(dc, (y)))): \
1303 (abs(INTERNAL_YDSTOWS(dc, (y)))))
1305 metrics->tmHeight = HDPTOLP(metrics->tmHeight);
1306 metrics->tmAscent = HDPTOLP(metrics->tmAscent);
1307 metrics->tmDescent = HDPTOLP(metrics->tmDescent);
1308 metrics->tmInternalLeading = HDPTOLP(metrics->tmInternalLeading);
1309 metrics->tmExternalLeading = HDPTOLP(metrics->tmExternalLeading);
1310 metrics->tmAveCharWidth = WDPTOLP(metrics->tmAveCharWidth);
1311 metrics->tmMaxCharWidth = WDPTOLP(metrics->tmMaxCharWidth);
1312 metrics->tmOverhang = WDPTOLP(metrics->tmOverhang);
1316 TRACE("text metrics:\n"
1317 " Weight = %03li\t FirstChar = %i\t AveCharWidth = %li\n"
1318 " Italic = % 3i\t LastChar = %i\t\t MaxCharWidth = %li\n"
1319 " UnderLined = %01i\t DefaultChar = %i\t Overhang = %li\n"
1320 " StruckOut = %01i\t BreakChar = %i\t CharSet = %i\n"
1321 " PitchAndFamily = %02x\n"
1322 " --------------------\n"
1323 " InternalLeading = %li\n"
1327 metrics->tmWeight, metrics->tmFirstChar, metrics->tmAveCharWidth,
1328 metrics->tmItalic, metrics->tmLastChar, metrics->tmMaxCharWidth,
1329 metrics->tmUnderlined, metrics->tmDefaultChar, metrics->tmOverhang,
1330 metrics->tmStruckOut, metrics->tmBreakChar, metrics->tmCharSet,
1331 metrics->tmPitchAndFamily,
1332 metrics->tmInternalLeading,
1335 metrics->tmHeight );
1337 GDI_ReleaseObj( hdc );
1342 /***********************************************************************
1343 * GetOutlineTextMetrics [GDI.308] Gets metrics for TrueType fonts.
1346 * lpOTM should be LPOUTLINETEXTMETRIC
1349 * Success: Non-zero or size of required buffer
1352 UINT16 WINAPI GetOutlineTextMetrics16(
1353 HDC16 hdc, /* [in] Handle of device context */
1354 UINT16 cbData, /* [in] Size of metric data array */
1355 LPOUTLINETEXTMETRIC16 lpOTM) /* [out] Address of metric data array */
1357 FIXME("(%04x,%04x,%p): stub\n", hdc,cbData,lpOTM);
1362 /***********************************************************************
1363 * GetOutlineTextMetricsA (GDI32.@)
1364 * Gets metrics for TrueType fonts.
1367 * If the supplied buffer isn't big enough Windows partially fills it up to
1368 * its given length and returns that length.
1371 * Success: Non-zero or size of required buffer
1374 UINT WINAPI GetOutlineTextMetricsA(
1375 HDC hdc, /* [in] Handle of device context */
1376 UINT cbData, /* [in] Size of metric data array */
1377 LPOUTLINETEXTMETRICA lpOTM) /* [out] Address of metric data array */
1379 char buf[512], *ptr;
1381 OUTLINETEXTMETRICW *lpOTMW = (OUTLINETEXTMETRICW *)buf;
1382 OUTLINETEXTMETRICA *output = lpOTM;
1385 if((ret = GetOutlineTextMetricsW(hdc, 0, NULL)) == 0)
1387 if(ret > sizeof(buf))
1388 lpOTMW = HeapAlloc(GetProcessHeap(), 0, ret);
1389 GetOutlineTextMetricsW(hdc, ret, lpOTMW);
1391 needed = sizeof(OUTLINETEXTMETRICA);
1392 if(lpOTMW->otmpFamilyName)
1393 needed += WideCharToMultiByte(CP_ACP, 0,
1394 (WCHAR*)((char*)lpOTMW + (ptrdiff_t)lpOTMW->otmpFamilyName), -1,
1395 NULL, 0, NULL, NULL);
1396 if(lpOTMW->otmpFaceName)
1397 needed += WideCharToMultiByte(CP_ACP, 0,
1398 (WCHAR*)((char*)lpOTMW + (ptrdiff_t)lpOTMW->otmpFaceName), -1,
1399 NULL, 0, NULL, NULL);
1400 if(lpOTMW->otmpStyleName)
1401 needed += WideCharToMultiByte(CP_ACP, 0,
1402 (WCHAR*)((char*)lpOTMW + (ptrdiff_t)lpOTMW->otmpStyleName), -1,
1403 NULL, 0, NULL, NULL);
1404 if(lpOTMW->otmpFullName)
1405 needed += WideCharToMultiByte(CP_ACP, 0,
1406 (WCHAR*)((char*)lpOTMW + (ptrdiff_t)lpOTMW->otmpFullName), -1,
1407 NULL, 0, NULL, NULL);
1414 TRACE("needed = %d\n", needed);
1416 /* Since the supplied buffer isn't big enough, we'll alloc one
1417 that is and memcpy the first cbData bytes into the lpOTM at
1419 output = HeapAlloc(GetProcessHeap(), 0, needed);
1421 ret = output->otmSize = min(needed, cbData);
1422 FONT_TextMetricWToA( &lpOTMW->otmTextMetrics, &output->otmTextMetrics );
1423 output->otmFiller = 0;
1424 output->otmPanoseNumber = lpOTMW->otmPanoseNumber;
1425 output->otmfsSelection = lpOTMW->otmfsSelection;
1426 output->otmfsType = lpOTMW->otmfsType;
1427 output->otmsCharSlopeRise = lpOTMW->otmsCharSlopeRise;
1428 output->otmsCharSlopeRun = lpOTMW->otmsCharSlopeRun;
1429 output->otmItalicAngle = lpOTMW->otmItalicAngle;
1430 output->otmEMSquare = lpOTMW->otmEMSquare;
1431 output->otmAscent = lpOTMW->otmAscent;
1432 output->otmDescent = lpOTMW->otmDescent;
1433 output->otmLineGap = lpOTMW->otmLineGap;
1434 output->otmsCapEmHeight = lpOTMW->otmsCapEmHeight;
1435 output->otmsXHeight = lpOTMW->otmsXHeight;
1436 output->otmrcFontBox = lpOTMW->otmrcFontBox;
1437 output->otmMacAscent = lpOTMW->otmMacAscent;
1438 output->otmMacDescent = lpOTMW->otmMacDescent;
1439 output->otmMacLineGap = lpOTMW->otmMacLineGap;
1440 output->otmusMinimumPPEM = lpOTMW->otmusMinimumPPEM;
1441 output->otmptSubscriptSize = lpOTMW->otmptSubscriptSize;
1442 output->otmptSubscriptOffset = lpOTMW->otmptSubscriptOffset;
1443 output->otmptSuperscriptSize = lpOTMW->otmptSuperscriptSize;
1444 output->otmptSuperscriptOffset = lpOTMW->otmptSuperscriptOffset;
1445 output->otmsStrikeoutSize = lpOTMW->otmsStrikeoutSize;
1446 output->otmsStrikeoutPosition = lpOTMW->otmsStrikeoutPosition;
1447 output->otmsUnderscoreSize = lpOTMW->otmsUnderscoreSize;
1448 output->otmsUnderscorePosition = lpOTMW->otmsUnderscorePosition;
1451 ptr = (char*)(output + 1);
1452 left = needed - sizeof(*output);
1454 if(lpOTMW->otmpFamilyName) {
1455 output->otmpFamilyName = (LPSTR)(ptr - (char*)output);
1456 len = WideCharToMultiByte(CP_ACP, 0,
1457 (WCHAR*)((char*)lpOTMW + (ptrdiff_t)lpOTMW->otmpFamilyName), -1,
1458 ptr, left, NULL, NULL);
1462 output->otmpFamilyName = 0;
1464 if(lpOTMW->otmpFaceName) {
1465 output->otmpFaceName = (LPSTR)(ptr - (char*)output);
1466 len = WideCharToMultiByte(CP_ACP, 0,
1467 (WCHAR*)((char*)lpOTMW + (ptrdiff_t)lpOTMW->otmpFaceName), -1,
1468 ptr, left, NULL, NULL);
1472 output->otmpFaceName = 0;
1474 if(lpOTMW->otmpStyleName) {
1475 output->otmpStyleName = (LPSTR)(ptr - (char*)output);
1476 len = WideCharToMultiByte(CP_ACP, 0,
1477 (WCHAR*)((char*)lpOTMW + (ptrdiff_t)lpOTMW->otmpStyleName), -1,
1478 ptr, left, NULL, NULL);
1482 output->otmpStyleName = 0;
1484 if(lpOTMW->otmpFullName) {
1485 output->otmpFullName = (LPSTR)(ptr - (char*)output);
1486 len = WideCharToMultiByte(CP_ACP, 0,
1487 (WCHAR*)((char*)lpOTMW + (ptrdiff_t)lpOTMW->otmpFullName), -1,
1488 ptr, left, NULL, NULL);
1491 output->otmpFullName = 0;
1495 if(output != lpOTM) {
1496 memcpy(lpOTM, output, cbData);
1497 HeapFree(GetProcessHeap(), 0, output);
1501 if(lpOTMW != (OUTLINETEXTMETRICW *)buf)
1502 HeapFree(GetProcessHeap(), 0, lpOTMW);
1508 /***********************************************************************
1509 * GetOutlineTextMetricsW [GDI32.@]
1511 UINT WINAPI GetOutlineTextMetricsW(
1512 HDC hdc, /* [in] Handle of device context */
1513 UINT cbData, /* [in] Size of metric data array */
1514 LPOUTLINETEXTMETRICW lpOTM) /* [out] Address of metric data array */
1516 DC *dc = DC_GetDCPtr( hdc );
1517 OUTLINETEXTMETRICW *output = lpOTM;
1520 TRACE("(%p,%d,%p)\n", hdc, cbData, lpOTM);
1524 ret = WineEngGetOutlineTextMetrics(dc->gdiFont, cbData, output);
1527 output = HeapAlloc(GetProcessHeap(), 0, ret);
1528 WineEngGetOutlineTextMetrics(dc->gdiFont, ret, output);
1531 #define WDPTOLP(x) ((x<0)? \
1532 (-abs(INTERNAL_XDSTOWS(dc, (x)))): \
1533 (abs(INTERNAL_XDSTOWS(dc, (x)))))
1534 #define HDPTOLP(y) ((y<0)? \
1535 (-abs(INTERNAL_YDSTOWS(dc, (y)))): \
1536 (abs(INTERNAL_YDSTOWS(dc, (y)))))
1538 output->otmTextMetrics.tmHeight = HDPTOLP(output->otmTextMetrics.tmHeight);
1539 output->otmTextMetrics.tmAscent = HDPTOLP(output->otmTextMetrics.tmAscent);
1540 output->otmTextMetrics.tmDescent = HDPTOLP(output->otmTextMetrics.tmDescent);
1541 output->otmTextMetrics.tmInternalLeading = HDPTOLP(output->otmTextMetrics.tmInternalLeading);
1542 output->otmTextMetrics.tmExternalLeading = HDPTOLP(output->otmTextMetrics.tmExternalLeading);
1543 output->otmTextMetrics.tmAveCharWidth = WDPTOLP(output->otmTextMetrics.tmAveCharWidth);
1544 output->otmTextMetrics.tmMaxCharWidth = WDPTOLP(output->otmTextMetrics.tmMaxCharWidth);
1545 output->otmTextMetrics.tmOverhang = WDPTOLP(output->otmTextMetrics.tmOverhang);
1546 output->otmAscent = HDPTOLP(output->otmAscent);
1547 output->otmDescent = HDPTOLP(output->otmDescent);
1548 output->otmLineGap = HDPTOLP(output->otmLineGap);
1549 output->otmsCapEmHeight = HDPTOLP(output->otmsCapEmHeight);
1550 output->otmsXHeight = HDPTOLP(output->otmsXHeight);
1551 output->otmrcFontBox.top = HDPTOLP(output->otmrcFontBox.top);
1552 output->otmrcFontBox.bottom = HDPTOLP(output->otmrcFontBox.bottom);
1553 output->otmrcFontBox.left = WDPTOLP(output->otmrcFontBox.left);
1554 output->otmrcFontBox.right = WDPTOLP(output->otmrcFontBox.right);
1555 output->otmMacAscent = HDPTOLP(output->otmMacAscent);
1556 output->otmMacDescent = HDPTOLP(output->otmMacDescent);
1557 output->otmMacLineGap = HDPTOLP(output->otmMacLineGap);
1558 output->otmptSubscriptSize.x = WDPTOLP(output->otmptSubscriptSize.x);
1559 output->otmptSubscriptSize.y = HDPTOLP(output->otmptSubscriptSize.y);
1560 output->otmptSubscriptOffset.x = WDPTOLP(output->otmptSubscriptOffset.x);
1561 output->otmptSubscriptOffset.y = HDPTOLP(output->otmptSubscriptOffset.y);
1562 output->otmptSuperscriptSize.x = WDPTOLP(output->otmptSuperscriptSize.x);
1563 output->otmptSuperscriptSize.y = HDPTOLP(output->otmptSuperscriptSize.y);
1564 output->otmptSuperscriptOffset.x = WDPTOLP(output->otmptSuperscriptOffset.x);
1565 output->otmptSuperscriptOffset.y = HDPTOLP(output->otmptSuperscriptOffset.y);
1566 output->otmsStrikeoutSize = HDPTOLP(output->otmsStrikeoutSize);
1567 output->otmsStrikeoutPosition = HDPTOLP(output->otmsStrikeoutPosition);
1568 output->otmsUnderscoreSize = HDPTOLP(output->otmsUnderscoreSize);
1569 output->otmsUnderscorePosition = HDPTOLP(output->otmsUnderscorePosition);
1572 if(output != lpOTM) {
1573 memcpy(lpOTM, output, cbData);
1574 HeapFree(GetProcessHeap(), 0, output);
1580 else { /* This stuff was in GetOutlineTextMetricsA, I've moved it here
1581 but really this should just be a return 0. */
1583 ret = sizeof(*lpOTM);
1588 memset(lpOTM, 0, ret);
1589 lpOTM->otmSize = sizeof(*lpOTM);
1590 GetTextMetricsW(hdc, &lpOTM->otmTextMetrics);
1592 Further fill of the structure not implemented,
1593 Needs real values for the structure members
1598 GDI_ReleaseObj(hdc);
1603 /***********************************************************************
1604 * GetCharWidthW (GDI32.@)
1605 * GetCharWidth32W (GDI32.@)
1607 BOOL WINAPI GetCharWidth32W( HDC hdc, UINT firstChar, UINT lastChar,
1612 DC * dc = DC_GetDCPtr( hdc );
1613 if (!dc) return FALSE;
1616 ret = WineEngGetCharWidth( dc->gdiFont, firstChar, lastChar, buffer );
1617 else if (dc->funcs->pGetCharWidth)
1618 ret = dc->funcs->pGetCharWidth( dc->physDev, firstChar, lastChar, buffer);
1622 /* convert device units to logical */
1623 for( i = firstChar; i <= lastChar; i++, buffer++ )
1624 *buffer = INTERNAL_XDSTOWS(dc, *buffer);
1627 GDI_ReleaseObj( hdc );
1632 /***********************************************************************
1633 * GetCharWidthA (GDI32.@)
1634 * GetCharWidth32A (GDI32.@)
1636 BOOL WINAPI GetCharWidth32A( HDC hdc, UINT firstChar, UINT lastChar,
1639 INT i, wlen, count = (INT)(lastChar - firstChar + 1);
1644 if(count <= 0) return FALSE;
1646 str = HeapAlloc(GetProcessHeap(), 0, count);
1647 for(i = 0; i < count; i++)
1648 str[i] = (BYTE)(firstChar + i);
1650 wstr = FONT_mbtowc(hdc, str, count, &wlen, NULL);
1652 for(i = 0; i < wlen; i++)
1654 if(!GetCharWidth32W(hdc, wstr[i], wstr[i], buffer))
1662 HeapFree(GetProcessHeap(), 0, str);
1663 HeapFree(GetProcessHeap(), 0, wstr);
1669 /***********************************************************************
1670 * ExtTextOutA (GDI32.@)
1674 BOOL WINAPI ExtTextOutA( HDC hdc, INT x, INT y, UINT flags,
1675 const RECT *lprect, LPCSTR str, UINT count, const INT *lpDx )
1679 LPWSTR p = FONT_mbtowc(hdc, str, count, &wlen, &codepage);
1684 unsigned int i = 0, j = 0;
1686 lpDxW = HeapAlloc( GetProcessHeap(), 0, wlen*sizeof(INT));
1688 if(IsDBCSLeadByteEx(codepage, str[i])) {
1689 lpDxW[j++] = lpDx[i] + lpDx[i+1];
1692 lpDxW[j++] = lpDx[i];
1698 ret = ExtTextOutW( hdc, x, y, flags, lprect, p, wlen, lpDxW );
1700 HeapFree( GetProcessHeap(), 0, p );
1701 HeapFree( GetProcessHeap(), 0, lpDxW );
1706 /***********************************************************************
1707 * ExtTextOutW (GDI32.@)
1709 * Draws text using the currently selected font, background color, and text color.
1713 * x,y [I] coordinates of string
1715 * ETO_GRAYED - undocumented on MSDN
1716 * ETO_OPAQUE - use background color for fill the rectangle
1717 * ETO_CLIPPED - clipping text to the rectangle
1718 * ETO_GLYPH_INDEX - Buffer is of glyph locations in fonts rather
1719 * than encoded characters. Implies ETO_IGNORELANGUAGE
1720 * ETO_RTLREADING - Paragraph is basically a right-to-left paragraph.
1721 * Affects BiDi ordering
1722 * ETO_IGNORELANGUAGE - Undocumented in MSDN - instructs ExtTextOut not to do BiDi reordering
1723 * ETO_PDY - unimplemented
1724 * ETO_NUMERICSLATIN - unimplemented always assumed -
1725 * do not translate numbers into locale representations
1726 * ETO_NUMERICSLOCAL - unimplemented - Numerals in Arabic/Farsi context should assume local form
1727 * lprect [I] dimensions for clipping or/and opaquing
1728 * str [I] text string
1729 * count [I] number of symbols in string
1730 * lpDx [I] optional parameter with distance between drawing characters
1736 BOOL WINAPI ExtTextOutW( HDC hdc, INT x, INT y, UINT flags,
1737 const RECT *lprect, LPCWSTR str, UINT count, const INT *lpDx )
1740 LPWSTR reordered_str = (LPWSTR)str;
1741 const WORD *glyphs = NULL;
1742 UINT align = GetTextAlign( hdc );
1746 double cosEsc, sinEsc;
1747 INT *deltas = NULL, char_extra;
1750 BOOL done_extents = FALSE;
1751 INT width, xwidth, ywidth;
1753 DC * dc = DC_GetDCUpdate( hdc );
1755 if (!dc) return FALSE;
1757 if (flags & (ETO_NUMERICSLOCAL | ETO_NUMERICSLATIN | ETO_PDY))
1758 FIXME("flags ETO_NUMERICSLOCAL | ETO_NUMERICSLATIN | ETO_PDY unimplemented\n");
1760 if(PATH_IsPathOpen(dc->path))
1762 FIXME("called on an open path\n");
1763 GDI_ReleaseObj( hdc );
1767 if(!dc->funcs->pExtTextOut)
1769 GDI_ReleaseObj( hdc );
1773 type = GetObjectType(hdc);
1774 if(type == OBJ_METADC || type == OBJ_ENHMETADC)
1776 ret = dc->funcs->pExtTextOut(dc->physDev, x, y, flags, lprect, str, count, lpDx);
1777 GDI_ReleaseObj( hdc );
1781 if( !(flags & (ETO_GLYPH_INDEX | ETO_IGNORELANGUAGE)) && BidiAvail && count > 0 )
1783 reordered_str = HeapAlloc(GetProcessHeap(), 0, count*sizeof(WCHAR));
1785 BIDI_Reorder( str, count, GCP_REORDER,
1786 ((flags&ETO_RTLREADING)!=0 || (GetTextAlign(hdc)&TA_RTLREADING)!=0)?
1787 WINE_GCPW_FORCE_RTL:WINE_GCPW_FORCE_LTR,
1788 reordered_str, count, NULL );
1790 flags |= ETO_IGNORELANGUAGE;
1793 TRACE("%p, %d, %d, %08x, %p, %s, %d, %p)\n", hdc, x, y, flags,
1794 lprect, debugstr_wn(str, count), count, lpDx);
1796 if(flags & ETO_GLYPH_INDEX)
1797 glyphs = (const WORD*)reordered_str;
1798 else if(dc->gdiFont)
1800 glyphs = HeapAlloc(GetProcessHeap(), 0, count * sizeof(WCHAR));
1801 GetGlyphIndicesW(hdc, reordered_str, count, (WORD*)glyphs, 0);
1802 flags |= ETO_GLYPH_INDEX;
1806 TRACE("rect: %ld,%ld - %ld,%ld\n", lprect->left, lprect->top, lprect->right,
1808 TRACE("align = %x bkmode = %x mapmode = %x\n", align, GetBkMode(hdc), GetMapMode(hdc));
1810 if(align & TA_UPDATECP)
1812 GetCurrentPositionEx( hdc, &pt );
1817 GetTextMetricsW(hdc, &tm);
1818 GetObjectW(GetCurrentObject(hdc, OBJ_FONT), sizeof(lf), &lf);
1820 if(!(tm.tmPitchAndFamily & TMPF_VECTOR)) /* Non-scalable fonts shouldn't be rotated */
1821 lf.lfEscapement = 0;
1823 if(lf.lfEscapement != 0)
1825 cosEsc = cos(lf.lfEscapement * M_PI / 1800);
1826 sinEsc = sin(lf.lfEscapement * M_PI / 1800);
1834 if(flags & (ETO_CLIPPED | ETO_OPAQUE))
1838 if(flags & ETO_CLIPPED) goto done;
1839 if(flags & ETO_GLYPH_INDEX)
1840 GetTextExtentPointI(hdc, glyphs, count, &sz);
1842 GetTextExtentPointW(hdc, reordered_str, count, &sz);
1844 done_extents = TRUE;
1847 rc.right = x + sz.cx;
1848 rc.bottom = y + sz.cy;
1855 LPtoDP(hdc, (POINT*)&rc, 2);
1857 if(rc.left > rc.right) {INT tmp = rc.left; rc.left = rc.right; rc.right = tmp;}
1858 if(rc.top > rc.bottom) {INT tmp = rc.top; rc.top = rc.bottom; rc.bottom = tmp;}
1861 if(flags & ETO_OPAQUE)
1862 dc->funcs->pExtTextOut(dc->physDev, 0, 0, ETO_OPAQUE, &rc, NULL, 0, NULL);
1869 LPtoDP(hdc, &pt, 1);
1873 char_extra = GetTextCharacterExtra(hdc);
1875 if(char_extra || dc->breakExtra || lpDx)
1879 deltas = HeapAlloc(GetProcessHeap(), 0, count * sizeof(INT));
1880 for(i = 0; i < count; i++)
1883 deltas[i] = lpDx[i] + char_extra;
1886 if(flags & ETO_GLYPH_INDEX)
1887 GetTextExtentPointI(hdc, glyphs + i, 1, &tmpsz);
1889 GetTextExtentPointW(hdc, reordered_str + i, 1, &tmpsz);
1891 deltas[i] = tmpsz.cx;
1894 if (dc->breakExtra && reordered_str[i] == tm.tmBreakChar)
1896 deltas[i] = deltas[i] + dc->breakExtra;
1898 deltas[i] = INTERNAL_XWSTODS(dc, deltas[i]);
1906 if(flags & ETO_GLYPH_INDEX)
1907 GetTextExtentPointI(hdc, glyphs, count, &sz);
1909 GetTextExtentPointW(hdc, reordered_str, count, &sz);
1910 done_extents = TRUE;
1912 width = INTERNAL_XWSTODS(dc, sz.cx);
1914 xwidth = width * cosEsc;
1915 ywidth = width * sinEsc;
1917 tm.tmAscent = abs(INTERNAL_YWSTODS(dc, tm.tmAscent));
1918 tm.tmDescent = abs(INTERNAL_YWSTODS(dc, tm.tmDescent));
1919 switch( align & (TA_LEFT | TA_RIGHT | TA_CENTER) )
1922 if (align & TA_UPDATECP)
1926 DPtoLP(hdc, &pt, 1);
1927 MoveToEx(hdc, pt.x, pt.y, NULL);
1939 if (align & TA_UPDATECP)
1943 DPtoLP(hdc, &pt, 1);
1944 MoveToEx(hdc, pt.x, pt.y, NULL);
1949 switch( align & (TA_TOP | TA_BOTTOM | TA_BASELINE) )
1952 y += tm.tmAscent * cosEsc;
1953 x += tm.tmAscent * sinEsc;
1957 y -= tm.tmDescent * cosEsc;
1958 x -= tm.tmDescent * sinEsc;
1965 if(GetBkMode(hdc) != TRANSPARENT)
1967 if(!((flags & ETO_CLIPPED) && (flags & ETO_OPAQUE)))
1969 if(!(flags & ETO_OPAQUE) || x < rc.left || x + width >= rc.right ||
1970 y - tm.tmAscent < rc.top || y + tm.tmDescent >= rc.bottom)
1974 rc.right = x + width;
1975 rc.top = y - tm.tmAscent;
1976 rc.bottom = y + tm.tmDescent;
1977 dc->funcs->pExtTextOut(dc->physDev, 0, 0, ETO_OPAQUE, &rc, NULL, 0, NULL);
1982 ret = dc->funcs->pExtTextOut(dc->physDev, x, y, (flags & ~ETO_OPAQUE), &rc,
1983 (flags & ETO_GLYPH_INDEX) ? glyphs: reordered_str, count, deltas);
1985 if (lf.lfUnderline || lf.lfStrikeOut)
1987 int underlinePos, strikeoutPos;
1988 int underlineWidth, strikeoutWidth;
1989 UINT nMetricsSize = GetOutlineTextMetricsW(hdc, 0, NULL);
1990 OUTLINETEXTMETRICW* otm = NULL;
1995 GetTextMetricsW(hdc, &tm);
1997 underlineWidth = tm.tmAscent / 20 + 1;
1998 strikeoutPos = tm.tmAscent / 2;
1999 strikeoutWidth = underlineWidth;
2003 otm = HeapAlloc(GetProcessHeap(), 0, nMetricsSize);
2004 if (!otm) goto done;
2006 GetOutlineTextMetricsW(hdc, nMetricsSize, otm);
2007 underlinePos = otm->otmsUnderscorePosition;
2008 underlineWidth = otm->otmsUnderscoreSize;
2009 strikeoutPos = otm->otmsStrikeoutPosition;
2010 strikeoutWidth = otm->otmsStrikeoutSize;
2015 POINT pts[2], oldpt;
2016 HPEN hpen = CreatePen(PS_SOLID, underlineWidth, dc->textColor);
2017 hpen = SelectObject(hdc, hpen);
2020 pts[1].x = x + xwidth;
2021 pts[1].y = y - ywidth;
2022 DPtoLP(hdc, pts, 2);
2023 MoveToEx(hdc, pts[0].x - underlinePos * sinEsc, pts[0].y - underlinePos * cosEsc, &oldpt);
2024 LineTo(hdc, pts[1].x - underlinePos * sinEsc, pts[1].y - underlinePos * cosEsc);
2025 MoveToEx(hdc, oldpt.x, oldpt.y, NULL);
2026 DeleteObject(SelectObject(hdc, hpen));
2031 POINT pts[2], oldpt;
2032 HPEN hpen = CreatePen(PS_SOLID, strikeoutWidth, dc->textColor);
2033 hpen = SelectObject(hdc, hpen);
2036 pts[1].x = x + xwidth;
2037 pts[1].y = y - ywidth;
2038 DPtoLP(hdc, pts, 2);
2039 MoveToEx(hdc, pts[0].x - strikeoutPos * sinEsc, pts[0].y - strikeoutPos * cosEsc, &oldpt);
2040 LineTo(hdc, pts[1].x - strikeoutPos * sinEsc, pts[1].y - strikeoutPos * cosEsc);
2041 MoveToEx(hdc, oldpt.x, oldpt.y, NULL);
2042 DeleteObject(SelectObject(hdc, hpen));
2047 HeapFree(GetProcessHeap(), 0, deltas);
2048 if(glyphs && glyphs != reordered_str)
2049 HeapFree(GetProcessHeap(), 0, (WORD*)glyphs);
2050 if(reordered_str != str)
2051 HeapFree(GetProcessHeap(), 0, reordered_str);
2053 GDI_ReleaseObj( hdc );
2058 /***********************************************************************
2059 * TextOutA (GDI32.@)
2061 BOOL WINAPI TextOutA( HDC hdc, INT x, INT y, LPCSTR str, INT count )
2063 return ExtTextOutA( hdc, x, y, 0, NULL, str, count, NULL );
2067 /***********************************************************************
2068 * TextOutW (GDI32.@)
2070 BOOL WINAPI TextOutW(HDC hdc, INT x, INT y, LPCWSTR str, INT count)
2072 return ExtTextOutW( hdc, x, y, 0, NULL, str, count, NULL );
2076 /***********************************************************************
2077 * PolyTextOutA (GDI32.@)
2079 * Draw several Strings
2081 BOOL WINAPI PolyTextOutA ( HDC hdc, /* [in] Handle to device context */
2082 PPOLYTEXTA pptxt, /* [in] Array of strings */
2083 INT cStrings ) /* [in] Number of strings in array */
2085 for (; cStrings>0; cStrings--, pptxt++)
2086 if (!ExtTextOutA( hdc, pptxt->x, pptxt->y, pptxt->uiFlags, &pptxt->rcl, pptxt->lpstr, pptxt->n, pptxt->pdx ))
2093 /***********************************************************************
2094 * PolyTextOutW (GDI32.@)
2096 * Draw several Strings
2098 BOOL WINAPI PolyTextOutW ( HDC hdc, /* [in] Handle to device context */
2099 PPOLYTEXTW pptxt, /* [in] Array of strings */
2100 INT cStrings ) /* [in] Number of strings in array */
2102 for (; cStrings>0; cStrings--, pptxt++)
2103 if (!ExtTextOutW( hdc, pptxt->x, pptxt->y, pptxt->uiFlags, &pptxt->rcl, pptxt->lpstr, pptxt->n, pptxt->pdx ))
2109 /* FIXME: all following APIs ******************************************/
2112 /***********************************************************************
2113 * SetMapperFlags (GDI32.@)
2115 DWORD WINAPI SetMapperFlags( HDC hDC, DWORD dwFlag )
2117 DC *dc = DC_GetDCPtr( hDC );
2120 if(dc->funcs->pSetMapperFlags)
2121 ret = dc->funcs->pSetMapperFlags( dc->physDev, dwFlag );
2123 FIXME("(%p, 0x%08lx): stub - harmless\n", hDC, dwFlag);
2124 GDI_ReleaseObj( hDC );
2128 /***********************************************************************
2129 * GetAspectRatioFilterEx (GDI.486)
2131 BOOL16 WINAPI GetAspectRatioFilterEx16( HDC16 hdc, LPSIZE16 pAspectRatio )
2133 FIXME("(%04x, %p): -- Empty Stub !\n", hdc, pAspectRatio);
2137 /***********************************************************************
2138 * GetAspectRatioFilterEx (GDI32.@)
2140 BOOL WINAPI GetAspectRatioFilterEx( HDC hdc, LPSIZE pAspectRatio )
2142 FIXME("(%p, %p): -- Empty Stub !\n", hdc, pAspectRatio);
2147 /***********************************************************************
2148 * GetCharABCWidthsA (GDI32.@)
2150 BOOL WINAPI GetCharABCWidthsA(HDC hdc, UINT firstChar, UINT lastChar,
2153 INT i, wlen, count = (INT)(lastChar - firstChar + 1);
2158 if(count <= 0) return FALSE;
2160 str = HeapAlloc(GetProcessHeap(), 0, count);
2161 for(i = 0; i < count; i++)
2162 str[i] = (BYTE)(firstChar + i);
2164 wstr = FONT_mbtowc(hdc, str, count, &wlen, NULL);
2166 for(i = 0; i < wlen; i++)
2168 if(!GetCharABCWidthsW(hdc, wstr[i], wstr[i], abc))
2176 HeapFree(GetProcessHeap(), 0, str);
2177 HeapFree(GetProcessHeap(), 0, wstr);
2183 /******************************************************************************
2184 * GetCharABCWidthsW [GDI32.@]
2186 * Retrieves widths of characters in range.
2189 * hdc [I] Handle of device context
2190 * firstChar [I] First character in range to query
2191 * lastChar [I] Last character in range to query
2192 * abc [O] Address of character-width structure
2195 * Only works with TrueType fonts
2201 BOOL WINAPI GetCharABCWidthsW( HDC hdc, UINT firstChar, UINT lastChar,
2204 DC *dc = DC_GetDCPtr(hdc);
2209 ret = WineEngGetCharABCWidths( dc->gdiFont, firstChar, lastChar, abc );
2215 /* convert device units to logical */
2216 for( i = firstChar; i <= lastChar; i++, abc++ ) {
2217 abc->abcA = INTERNAL_XDSTOWS(dc, abc->abcA);
2218 abc->abcB = INTERNAL_XDSTOWS(dc, abc->abcB);
2219 abc->abcC = INTERNAL_XDSTOWS(dc, abc->abcC);
2224 GDI_ReleaseObj(hdc);
2229 /***********************************************************************
2230 * GetGlyphOutlineA (GDI32.@)
2232 DWORD WINAPI GetGlyphOutlineA( HDC hdc, UINT uChar, UINT fuFormat,
2233 LPGLYPHMETRICS lpgm, DWORD cbBuffer,
2234 LPVOID lpBuffer, const MAT2 *lpmat2 )
2240 if(!(fuFormat & GGO_GLYPH_INDEX)) {
2243 if(uChar > 0xff) { /* but, 2 bytes character only */
2245 mbchs[0] = (uChar & 0xff00) >> 8;
2246 mbchs[1] = (uChar & 0xff);
2249 mbchs[0] = (uChar & 0xff);
2251 p = FONT_mbtowc(hdc, mbchs, len, NULL, NULL);
2255 ret = GetGlyphOutlineW(hdc, c, fuFormat, lpgm, cbBuffer, lpBuffer,
2257 HeapFree(GetProcessHeap(), 0, p);
2261 /***********************************************************************
2262 * GetGlyphOutlineW (GDI32.@)
2264 DWORD WINAPI GetGlyphOutlineW( HDC hdc, UINT uChar, UINT fuFormat,
2265 LPGLYPHMETRICS lpgm, DWORD cbBuffer,
2266 LPVOID lpBuffer, const MAT2 *lpmat2 )
2268 DC *dc = DC_GetDCPtr(hdc);
2271 TRACE("(%p, %04x, %04x, %p, %ld, %p, %p)\n",
2272 hdc, uChar, fuFormat, lpgm, cbBuffer, lpBuffer, lpmat2 );
2274 if(!dc) return GDI_ERROR;
2277 ret = WineEngGetGlyphOutline(dc->gdiFont, uChar, fuFormat, lpgm,
2278 cbBuffer, lpBuffer, lpmat2);
2282 GDI_ReleaseObj(hdc);
2287 /***********************************************************************
2288 * CreateScalableFontResourceA (GDI32.@)
2290 BOOL WINAPI CreateScalableFontResourceA( DWORD fHidden,
2291 LPCSTR lpszResourceFile,
2292 LPCSTR lpszFontFile,
2293 LPCSTR lpszCurrentPath )
2297 /* fHidden=1 - only visible for the calling app, read-only, not
2298 * enumbered with EnumFonts/EnumFontFamilies
2299 * lpszCurrentPath can be NULL
2301 FIXME("(%ld,%s,%s,%s): stub\n",
2302 fHidden, debugstr_a(lpszResourceFile), debugstr_a(lpszFontFile),
2303 debugstr_a(lpszCurrentPath) );
2305 /* If the output file already exists, return the ERROR_FILE_EXISTS error as specified in MSDN */
2306 if ((f = CreateFileA(lpszResourceFile, 0, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0)) != INVALID_HANDLE_VALUE) {
2308 SetLastError(ERROR_FILE_EXISTS);
2311 return FALSE; /* create failed */
2314 /***********************************************************************
2315 * CreateScalableFontResourceW (GDI32.@)
2317 BOOL WINAPI CreateScalableFontResourceW( DWORD fHidden,
2318 LPCWSTR lpszResourceFile,
2319 LPCWSTR lpszFontFile,
2320 LPCWSTR lpszCurrentPath )
2322 FIXME("(%ld,%p,%p,%p): stub\n",
2323 fHidden, lpszResourceFile, lpszFontFile, lpszCurrentPath );
2324 return FALSE; /* create failed */
2328 /*************************************************************************
2329 * GetRasterizerCaps (GDI32.@)
2331 BOOL WINAPI GetRasterizerCaps( LPRASTERIZER_STATUS lprs, UINT cbNumBytes)
2333 lprs->nSize = sizeof(RASTERIZER_STATUS);
2334 lprs->wFlags = TT_AVAILABLE|TT_ENABLED;
2335 lprs->nLanguageID = 0;
2340 /*************************************************************************
2341 * GetKerningPairsA (GDI32.@)
2343 DWORD WINAPI GetKerningPairsA( HDC hDC, DWORD cPairs,
2344 LPKERNINGPAIR lpKerningPairs )
2346 return GetKerningPairsW( hDC, cPairs, lpKerningPairs );
2350 /*************************************************************************
2351 * GetKerningPairsW (GDI32.@)
2353 DWORD WINAPI GetKerningPairsW( HDC hDC, DWORD cPairs,
2354 LPKERNINGPAIR lpKerningPairs )
2357 FIXME("(%p,%ld,%p): almost empty stub!\n", hDC, cPairs, lpKerningPairs);
2358 for (i = 0; i < cPairs; i++)
2359 lpKerningPairs[i].iKernAmount = 0;
2363 /*************************************************************************
2364 * TranslateCharsetInfo [GDI32.@]
2366 * Fills a CHARSETINFO structure for a character set, code page, or
2367 * font. This allows making the correspondance between different labelings
2368 * (character set, Windows, ANSI, and OEM codepages, and Unicode ranges)
2369 * of the same encoding.
2371 * Only one codepage will be set in lpCs->fs. If TCI_SRCFONTSIG is used,
2372 * only one codepage should be set in *lpSrc.
2375 * TRUE on success, FALSE on failure.
2378 BOOL WINAPI TranslateCharsetInfo(
2379 LPDWORD lpSrc, /* [in]
2380 if flags == TCI_SRCFONTSIG: pointer to fsCsb of a FONTSIGNATURE
2381 if flags == TCI_SRCCHARSET: a character set value
2382 if flags == TCI_SRCCODEPAGE: a code page value
2384 LPCHARSETINFO lpCs, /* [out] structure to receive charset information */
2385 DWORD flags /* [in] determines interpretation of lpSrc */)
2389 case TCI_SRCFONTSIG:
2390 while (!(*lpSrc>>index & 0x0001) && index<MAXTCIINDEX) index++;
2392 case TCI_SRCCODEPAGE:
2393 while ((UINT) (lpSrc) != FONT_tci[index].ciACP && index < MAXTCIINDEX) index++;
2395 case TCI_SRCCHARSET:
2396 while ((UINT) (lpSrc) != FONT_tci[index].ciCharset && index < MAXTCIINDEX) index++;
2401 if (index >= MAXTCIINDEX || FONT_tci[index].ciCharset == DEFAULT_CHARSET) return FALSE;
2402 memcpy(lpCs, &FONT_tci[index], sizeof(CHARSETINFO));
2406 /*************************************************************************
2407 * GetFontLanguageInfo (GDI32.@)
2409 DWORD WINAPI GetFontLanguageInfo(HDC hdc)
2411 FONTSIGNATURE fontsig;
2412 static const DWORD GCP_DBCS_MASK=0x003F0000,
2413 GCP_DIACRITIC_MASK=0x00000000,
2414 FLI_GLYPHS_MASK=0x00000000,
2415 GCP_GLYPHSHAPE_MASK=0x00000040,
2416 GCP_KASHIDA_MASK=0x00000000,
2417 GCP_LIGATE_MASK=0x00000000,
2418 GCP_USEKERNING_MASK=0x00000000,
2419 GCP_REORDER_MASK=0x00000060;
2423 GetTextCharsetInfo( hdc, &fontsig, 0 );
2424 /* We detect each flag we return using a bitmask on the Codepage Bitfields */
2426 if( (fontsig.fsCsb[0]&GCP_DBCS_MASK)!=0 )
2429 if( (fontsig.fsCsb[0]&GCP_DIACRITIC_MASK)!=0 )
2430 result|=GCP_DIACRITIC;
2432 if( (fontsig.fsCsb[0]&FLI_GLYPHS_MASK)!=0 )
2435 if( (fontsig.fsCsb[0]&GCP_GLYPHSHAPE_MASK)!=0 )
2436 result|=GCP_GLYPHSHAPE;
2438 if( (fontsig.fsCsb[0]&GCP_KASHIDA_MASK)!=0 )
2439 result|=GCP_KASHIDA;
2441 if( (fontsig.fsCsb[0]&GCP_LIGATE_MASK)!=0 )
2444 if( (fontsig.fsCsb[0]&GCP_USEKERNING_MASK)!=0 )
2445 result|=GCP_USEKERNING;
2447 /* this might need a test for a HEBREW- or ARABIC_CHARSET as well */
2448 if( GetTextAlign( hdc) & TA_RTLREADING )
2449 if( (fontsig.fsCsb[0]&GCP_REORDER_MASK)!=0 )
2450 result|=GCP_REORDER;
2456 /*************************************************************************
2457 * GetFontData [GDI32.@]
2459 * Retrieve data for TrueType font.
2463 * success: Number of bytes returned
2464 * failure: GDI_ERROR
2468 * Calls SetLastError()
2471 DWORD WINAPI GetFontData(HDC hdc, DWORD table, DWORD offset,
2472 LPVOID buffer, DWORD length)
2474 DC *dc = DC_GetDCPtr(hdc);
2475 DWORD ret = GDI_ERROR;
2477 if(!dc) return GDI_ERROR;
2480 ret = WineEngGetFontData(dc->gdiFont, table, offset, buffer, length);
2482 GDI_ReleaseObj(hdc);
2486 /*************************************************************************
2487 * GetGlyphIndicesA [GDI32.@]
2489 DWORD WINAPI GetGlyphIndicesA(HDC hdc, LPCSTR lpstr, INT count,
2490 LPWORD pgi, DWORD flags)
2496 TRACE("(%p, %s, %d, %p, 0x%lx)\n",
2497 hdc, debugstr_an(lpstr, count), count, pgi, flags);
2499 lpstrW = FONT_mbtowc(hdc, lpstr, count, &countW, NULL);
2500 ret = GetGlyphIndicesW(hdc, lpstrW, countW, pgi, flags);
2501 HeapFree(GetProcessHeap(), 0, lpstrW);
2506 /*************************************************************************
2507 * GetGlyphIndicesW [GDI32.@]
2509 DWORD WINAPI GetGlyphIndicesW(HDC hdc, LPCWSTR lpstr, INT count,
2510 LPWORD pgi, DWORD flags)
2512 DC *dc = DC_GetDCPtr(hdc);
2513 DWORD ret = GDI_ERROR;
2515 TRACE("(%p, %s, %d, %p, 0x%lx)\n",
2516 hdc, debugstr_wn(lpstr, count), count, pgi, flags);
2518 if(!dc) return GDI_ERROR;
2521 ret = WineEngGetGlyphIndices(dc->gdiFont, lpstr, count, pgi, flags);
2523 GDI_ReleaseObj(hdc);
2527 /*************************************************************************
2528 * GetCharacterPlacementA [GDI32.@]
2531 * the web browser control of ie4 calls this with dwFlags=0
2534 GetCharacterPlacementA(HDC hdc, LPCSTR lpString, INT uCount,
2535 INT nMaxExtent, GCP_RESULTSA *lpResults,
2540 GCP_RESULTSW resultsW;
2544 TRACE("%s, %d, %d, 0x%08lx\n",
2545 debugstr_an(lpString, uCount), uCount, nMaxExtent, dwFlags);
2547 /* both structs are equal in size */
2548 memcpy(&resultsW, lpResults, sizeof(resultsW));
2550 lpStringW = FONT_mbtowc(hdc, lpString, uCount, &uCountW, &font_cp);
2551 if(lpResults->lpOutString)
2552 resultsW.lpOutString = HeapAlloc(GetProcessHeap(), 0, sizeof(WCHAR)*uCountW);
2554 ret = GetCharacterPlacementW(hdc, lpStringW, uCountW, nMaxExtent, &resultsW, dwFlags);
2556 if(lpResults->lpOutString) {
2557 WideCharToMultiByte(font_cp, 0, resultsW.lpOutString, uCountW,
2558 lpResults->lpOutString, uCount, NULL, NULL );
2561 HeapFree(GetProcessHeap(), 0, lpStringW);
2562 HeapFree(GetProcessHeap(), 0, resultsW.lpOutString);
2567 /*************************************************************************
2568 * GetCharacterPlacementW [GDI32.@]
2570 * Retrieve information about a string. This includes the width, reordering,
2571 * Glyphing and so on.
2575 * The width and height of the string if successful, 0 if failed.
2579 * All flags except GCP_REORDER are not yet implemented.
2580 * Reordering is not 100% complient to the Windows BiDi method.
2581 * Caret positioning is not yet implemented for BiDi.
2582 * Classes are not yet implemented.
2586 GetCharacterPlacementW(
2587 HDC hdc, /* [in] Device context for which the rendering is to be done */
2588 LPCWSTR lpString, /* [in] The string for which information is to be returned */
2589 INT uCount, /* [in] Number of WORDS in string. */
2590 INT nMaxExtent, /* [in] Maximum extent the string is to take (in HDC logical units) */
2591 GCP_RESULTSW *lpResults,/* [in/out] A pointer to a GCP_RESULTSW struct */
2592 DWORD dwFlags /* [in] Flags specifying how to process the string */
2599 TRACE("%s, %d, %d, 0x%08lx\n",
2600 debugstr_wn(lpString, uCount), uCount, nMaxExtent, dwFlags);
2602 TRACE("lStructSize=%ld, lpOutString=%p, lpOrder=%p, lpDx=%p, lpCaretPos=%p\n"
2603 "lpClass=%p, lpGlyphs=%p, nGlyphs=%u, nMaxFit=%d\n",
2604 lpResults->lStructSize, lpResults->lpOutString, lpResults->lpOrder,
2605 lpResults->lpDx, lpResults->lpCaretPos, lpResults->lpClass,
2606 lpResults->lpGlyphs, lpResults->nGlyphs, lpResults->nMaxFit);
2608 if(dwFlags&(~GCP_REORDER)) FIXME("flags 0x%08lx ignored\n", dwFlags);
2609 if(lpResults->lpClass) FIXME("classes not implemented\n");
2610 if (lpResults->lpCaretPos && (dwFlags & GCP_REORDER))
2611 FIXME("Caret positions for complex scripts not implemented\n");
2613 nSet = (UINT)uCount;
2614 if(nSet > lpResults->nGlyphs)
2615 nSet = lpResults->nGlyphs;
2617 /* return number of initialized fields */
2618 lpResults->nGlyphs = nSet;
2620 if((dwFlags&GCP_REORDER)==0 || !BidiAvail)
2622 /* Treat the case where no special handling was requested in a fastpath way */
2623 /* copy will do if the GCP_REORDER flag is not set */
2624 if(lpResults->lpOutString)
2625 memcpy( lpResults->lpOutString, lpString, nSet * sizeof(WCHAR));
2627 if(lpResults->lpOrder)
2629 for(i = 0; i < nSet; i++)
2630 lpResults->lpOrder[i] = i;
2634 BIDI_Reorder( lpString, uCount, dwFlags, WINE_GCPW_FORCE_LTR, lpResults->lpOutString,
2635 nSet, lpResults->lpOrder );
2638 /* FIXME: Will use the placement chars */
2639 if (lpResults->lpDx)
2642 for (i = 0; i < nSet; i++)
2644 if (GetCharWidth32W(hdc, lpString[i], lpString[i], &c))
2645 lpResults->lpDx[i]= c;
2649 if (lpResults->lpCaretPos && !(dwFlags & GCP_REORDER))
2653 lpResults->lpCaretPos[0] = 0;
2654 for (i = 1; i < nSet; i++)
2655 if (GetTextExtentPoint32W(hdc, &(lpString[i - 1]), 1, &size))
2656 lpResults->lpCaretPos[i] = (pos += size.cx);
2659 if(lpResults->lpGlyphs)
2660 GetGlyphIndicesW(hdc, lpString, nSet, lpResults->lpGlyphs, 0);
2662 if (GetTextExtentPoint32W(hdc, lpString, uCount, &size))
2663 ret = MAKELONG(size.cx, size.cy);
2668 /*************************************************************************
2669 * GetCharABCWidthsFloatA [GDI32.@]
2671 BOOL WINAPI GetCharABCWidthsFloatA(HDC hdc, UINT iFirstChar, UINT iLastChar,
2674 FIXME_(gdi)("GetCharABCWidthsFloatA, stub\n");
2678 /*************************************************************************
2679 * GetCharABCWidthsFloatW [GDI32.@]
2681 BOOL WINAPI GetCharABCWidthsFloatW(HDC hdc, UINT iFirstChar,
2682 UINT iLastChar, LPABCFLOAT lpABCF)
2684 FIXME_(gdi)("GetCharABCWidthsFloatW, stub\n");
2688 /*************************************************************************
2689 * GetCharWidthFloatA [GDI32.@]
2691 BOOL WINAPI GetCharWidthFloatA(HDC hdc, UINT iFirstChar,
2692 UINT iLastChar, PFLOAT pxBuffer)
2694 FIXME_(gdi)("GetCharWidthFloatA, stub\n");
2698 /*************************************************************************
2699 * GetCharWidthFloatW [GDI32.@]
2701 BOOL WINAPI GetCharWidthFloatW(HDC hdc, UINT iFirstChar,
2702 UINT iLastChar, PFLOAT pxBuffer)
2704 FIXME_(gdi)("GetCharWidthFloatW, stub\n");
2709 /***********************************************************************
2711 * Font Resource API *
2713 ***********************************************************************/
2715 /***********************************************************************
2716 * AddFontResourceA (GDI32.@)
2718 INT WINAPI AddFontResourceA( LPCSTR str )
2720 return AddFontResourceExA( str, 0, NULL);
2723 /***********************************************************************
2724 * AddFontResourceW (GDI32.@)
2726 INT WINAPI AddFontResourceW( LPCWSTR str )
2728 return AddFontResourceExW(str, 0, NULL);
2732 /***********************************************************************
2733 * AddFontResourceExA (GDI32.@)
2735 INT WINAPI AddFontResourceExA( LPCSTR str, DWORD fl, PVOID pdv )
2737 DWORD len = MultiByteToWideChar(CP_ACP, 0, str, -1, NULL, 0);
2738 LPWSTR strW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
2741 MultiByteToWideChar(CP_ACP, 0, str, -1, strW, len);
2742 ret = AddFontResourceExW(strW, fl, pdv);
2743 HeapFree(GetProcessHeap(), 0, strW);
2747 /***********************************************************************
2748 * AddFontResourceExW (GDI32.@)
2750 INT WINAPI AddFontResourceExW( LPCWSTR str, DWORD fl, PVOID pdv )
2752 return WineEngAddFontResourceEx(str, fl, pdv);
2755 /***********************************************************************
2756 * RemoveFontResourceA (GDI32.@)
2758 BOOL WINAPI RemoveFontResourceA( LPCSTR str )
2760 return RemoveFontResourceExA(str, 0, 0);
2763 /***********************************************************************
2764 * RemoveFontResourceW (GDI32.@)
2766 BOOL WINAPI RemoveFontResourceW( LPCWSTR str )
2768 return RemoveFontResourceExW(str, 0, 0);
2771 /***********************************************************************
2772 * RemoveFontResourceExA (GDI32.@)
2774 BOOL WINAPI RemoveFontResourceExA( LPCSTR str, DWORD fl, PVOID pdv )
2776 DWORD len = MultiByteToWideChar(CP_ACP, 0, str, -1, NULL, 0);
2777 LPWSTR strW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
2780 MultiByteToWideChar(CP_ACP, 0, str, -1, strW, len);
2781 ret = RemoveFontResourceExW(strW, fl, pdv);
2782 HeapFree(GetProcessHeap(), 0, strW);
2786 /***********************************************************************
2787 * RemoveFontResourceExW (GDI32.@)
2789 BOOL WINAPI RemoveFontResourceExW( LPCWSTR str, DWORD fl, PVOID pdv )
2791 return WineEngRemoveFontResourceEx(str, fl, pdv);
2794 /***********************************************************************
2795 * GetTextCharset (GDI32.@)
2797 UINT WINAPI GetTextCharset(HDC hdc)
2799 /* MSDN docs say this is equivalent */
2800 return GetTextCharsetInfo(hdc, NULL, 0);
2803 /***********************************************************************
2804 * GetTextCharsetInfo (GDI32.@)
2806 UINT WINAPI GetTextCharsetInfo(HDC hdc, LPFONTSIGNATURE fs, DWORD flags)
2808 UINT ret = DEFAULT_CHARSET;
2809 DC *dc = DC_GetDCPtr(hdc);
2814 ret = WineEngGetTextCharsetInfo(dc->gdiFont, fs, flags);
2816 GDI_ReleaseObj(hdc);
2819 if (ret == DEFAULT_CHARSET && fs)
2820 memset(fs, 0, sizeof(FONTSIGNATURE));
2824 /***********************************************************************
2825 * GdiGetCharDimensions (GDI32.@)
2827 * Gets the average width of the characters in the English alphabet.
2830 * hdc [I] Handle to the device context to measure on.
2831 * lptm [O] Pointer to memory to store the text metrics into.
2832 * height [O] On exit, the maximum height of characters in the English alphabet.
2835 * The average width of characters in the English alphabet.
2838 * This function is used by the dialog manager to get the size of a dialog
2839 * unit. It should also be used by other pieces of code that need to know
2840 * the size of a dialog unit in logical units without having access to the
2841 * window handle of the dialog.
2842 * Windows caches the font metrics from this function, but we don't and
2843 * there doesn't appear to be an immediate advantage to do so.
2846 * GetTextExtentPointW, GetTextMetricsW, MapDialogRect.
2848 LONG WINAPI GdiGetCharDimensions(HDC hdc, LPTEXTMETRICW lptm, LONG *height)
2851 static const WCHAR alphabet[] = {
2852 'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q',
2853 'r','s','t','u','v','w','x','y','z','A','B','C','D','E','F','G','H',
2854 'I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z',0};
2856 if(lptm && !GetTextMetricsW(hdc, lptm)) return 0;
2858 if(!GetTextExtentPointW(hdc, alphabet, 52, &sz)) return 0;
2860 if (height) *height = sz.cy;
2861 return (sz.cx / 26 + 1) / 2;
2864 BOOL WINAPI EnableEUDC(BOOL fEnableEUDC)
2866 FIXME("(%d): stub\n", fEnableEUDC);