4 * Copyright 1993 Alexandre Julliard
18 #define ENUM_UNICODE 0x00000001
22 LPLOGFONT16 lpLogFontParam;
23 FONTENUMPROCEX16 lpEnumFunc;
26 LPNEWTEXTMETRICEX16 lpTextMetric;
27 LPENUMLOGFONTEX16 lpLogFont;
34 LPLOGFONT32W lpLogFontParam;
35 FONTENUMPROC32W lpEnumFunc;
38 LPNEWTEXTMETRICEX32W lpTextMetric;
39 LPENUMLOGFONTEX32W lpLogFont;
43 /***********************************************************************
44 * LOGFONT conversion functions.
46 static void __logfont32to16( INT16* plf16, const INT32* plf32 )
49 for( i = 0; i < 5; i++ ) *plf16++ = *plf32++;
50 *((INT32*)plf16)++ = *plf32++;
51 *((INT32*)plf16) = *plf32;
54 static void __logfont16to32( INT32* plf32, const INT16* plf16 )
57 for( i = 0; i < 5; i++ ) *plf32++ = *plf16++;
58 *plf32++ = *((INT32*)plf16)++;
59 *plf32 = *((INT32*)plf16);
62 void FONT_LogFont32ATo16( const LOGFONT32A* font32, LPLOGFONT16 font16 )
64 __logfont32to16( (INT16*)font16, (const INT32*)font32 );
65 lstrcpyn32A( font16->lfFaceName, font32->lfFaceName, LF_FACESIZE );
68 void FONT_LogFont32WTo16( const LOGFONT32W* font32, LPLOGFONT16 font16 )
70 __logfont32to16( (INT16*)font16, (const INT32*)font32 );
71 lstrcpynWtoA( font16->lfFaceName, font32->lfFaceName, LF_FACESIZE );
74 void FONT_LogFont16To32A( const LPLOGFONT16 font16, LPLOGFONT32A font32 )
76 __logfont16to32( (INT32*)font32, (const INT16*)font16 );
77 lstrcpyn32A( font32->lfFaceName, font16->lfFaceName, LF_FACESIZE );
80 void FONT_LogFont16To32W( const LPLOGFONT16 font16, LPLOGFONT32W font32 )
82 __logfont16to32( (INT32*)font32, (const INT16*)font16 );
83 lstrcpynAtoW( font32->lfFaceName, font16->lfFaceName, LF_FACESIZE );
86 /***********************************************************************
87 * TEXTMETRIC conversion functions.
89 void FONT_TextMetric32Ato16(const LPTEXTMETRIC32A ptm32, LPTEXTMETRIC16 ptm16 )
91 ptm16->tmHeight = ptm32->tmHeight;
92 ptm16->tmAscent = ptm32->tmAscent;
93 ptm16->tmDescent = ptm32->tmDescent;
94 ptm16->tmInternalLeading = ptm32->tmInternalLeading;
95 ptm16->tmExternalLeading = ptm32->tmExternalLeading;
96 ptm16->tmAveCharWidth = ptm32->tmAveCharWidth;
97 ptm16->tmMaxCharWidth = ptm32->tmMaxCharWidth;
98 ptm16->tmWeight = ptm32->tmWeight;
99 ptm16->tmOverhang = ptm32->tmOverhang;
100 ptm16->tmDigitizedAspectX = ptm32->tmDigitizedAspectX;
101 ptm16->tmDigitizedAspectY = ptm32->tmDigitizedAspectY;
102 ptm16->tmFirstChar = ptm32->tmFirstChar;
103 ptm16->tmLastChar = ptm32->tmLastChar;
104 ptm16->tmDefaultChar = ptm32->tmDefaultChar;
105 ptm16->tmBreakChar = ptm32->tmBreakChar;
106 ptm16->tmItalic = ptm32->tmItalic;
107 ptm16->tmUnderlined = ptm32->tmUnderlined;
108 ptm16->tmStruckOut = ptm32->tmStruckOut;
109 ptm16->tmPitchAndFamily = ptm32->tmPitchAndFamily;
110 ptm16->tmCharSet = ptm32->tmCharSet;
113 void FONT_TextMetric32Wto16(const LPTEXTMETRIC32W ptm32, LPTEXTMETRIC16 ptm16 )
115 ptm16->tmHeight = ptm32->tmHeight;
116 ptm16->tmAscent = ptm32->tmAscent;
117 ptm16->tmDescent = ptm32->tmDescent;
118 ptm16->tmInternalLeading = ptm32->tmInternalLeading;
119 ptm16->tmExternalLeading = ptm32->tmExternalLeading;
120 ptm16->tmAveCharWidth = ptm32->tmAveCharWidth;
121 ptm16->tmMaxCharWidth = ptm32->tmMaxCharWidth;
122 ptm16->tmWeight = ptm32->tmWeight;
123 ptm16->tmOverhang = ptm32->tmOverhang;
124 ptm16->tmDigitizedAspectX = ptm32->tmDigitizedAspectX;
125 ptm16->tmDigitizedAspectY = ptm32->tmDigitizedAspectY;
126 ptm16->tmFirstChar = ptm32->tmFirstChar;
127 ptm16->tmLastChar = ptm32->tmLastChar;
128 ptm16->tmDefaultChar = ptm32->tmDefaultChar;
129 ptm16->tmBreakChar = ptm32->tmBreakChar;
130 ptm16->tmItalic = ptm32->tmItalic;
131 ptm16->tmUnderlined = ptm32->tmUnderlined;
132 ptm16->tmStruckOut = ptm32->tmStruckOut;
133 ptm16->tmPitchAndFamily = ptm32->tmPitchAndFamily;
134 ptm16->tmCharSet = ptm32->tmCharSet;
137 void FONT_TextMetric16to32A(const LPTEXTMETRIC16 ptm16, LPTEXTMETRIC32A ptm32 )
139 ptm32->tmHeight = ptm16->tmHeight;
140 ptm32->tmAscent = ptm16->tmAscent;
141 ptm32->tmDescent = ptm16->tmDescent;
142 ptm32->tmInternalLeading = ptm16->tmInternalLeading;
143 ptm32->tmExternalLeading = ptm16->tmExternalLeading;
144 ptm32->tmAveCharWidth = ptm16->tmAveCharWidth;
145 ptm32->tmMaxCharWidth = ptm16->tmMaxCharWidth;
146 ptm32->tmWeight = ptm16->tmWeight;
147 ptm32->tmOverhang = ptm16->tmOverhang;
148 ptm32->tmDigitizedAspectX = ptm16->tmDigitizedAspectX;
149 ptm32->tmDigitizedAspectY = ptm16->tmDigitizedAspectY;
150 ptm32->tmFirstChar = ptm16->tmFirstChar;
151 ptm32->tmLastChar = ptm16->tmLastChar;
152 ptm32->tmDefaultChar = ptm16->tmDefaultChar;
153 ptm32->tmBreakChar = ptm16->tmBreakChar;
154 ptm32->tmItalic = ptm16->tmItalic;
155 ptm32->tmUnderlined = ptm16->tmUnderlined;
156 ptm32->tmStruckOut = ptm16->tmStruckOut;
157 ptm32->tmPitchAndFamily = ptm16->tmPitchAndFamily;
158 ptm32->tmCharSet = ptm16->tmCharSet;
161 void FONT_TextMetric16to32W(const LPTEXTMETRIC16 ptm16, LPTEXTMETRIC32W ptm32 )
163 ptm32->tmHeight = ptm16->tmHeight;
164 ptm32->tmAscent = ptm16->tmAscent;
165 ptm32->tmDescent = ptm16->tmDescent;
166 ptm32->tmInternalLeading = ptm16->tmInternalLeading;
167 ptm32->tmExternalLeading = ptm16->tmExternalLeading;
168 ptm32->tmAveCharWidth = ptm16->tmAveCharWidth;
169 ptm32->tmMaxCharWidth = ptm16->tmMaxCharWidth;
170 ptm32->tmWeight = ptm16->tmWeight;
171 ptm32->tmOverhang = ptm16->tmOverhang;
172 ptm32->tmDigitizedAspectX = ptm16->tmDigitizedAspectX;
173 ptm32->tmDigitizedAspectY = ptm16->tmDigitizedAspectY;
174 ptm32->tmFirstChar = ptm16->tmFirstChar;
175 ptm32->tmLastChar = ptm16->tmLastChar;
176 ptm32->tmDefaultChar = ptm16->tmDefaultChar;
177 ptm32->tmBreakChar = ptm16->tmBreakChar;
178 ptm32->tmItalic = ptm16->tmItalic;
179 ptm32->tmUnderlined = ptm16->tmUnderlined;
180 ptm32->tmStruckOut = ptm16->tmStruckOut;
181 ptm32->tmPitchAndFamily = ptm16->tmPitchAndFamily;
182 ptm32->tmCharSet = ptm16->tmCharSet;
185 void FONT_TextMetric32Ato32W(const LPTEXTMETRIC32A ptm32A, LPTEXTMETRIC32W ptm32W )
187 ptm32W->tmHeight = ptm32A->tmHeight;
188 ptm32W->tmAscent = ptm32A->tmAscent;
189 ptm32W->tmDescent = ptm32A->tmDescent;
190 ptm32W->tmInternalLeading = ptm32A->tmInternalLeading;
191 ptm32W->tmExternalLeading = ptm32A->tmExternalLeading;
192 ptm32W->tmAveCharWidth = ptm32A->tmAveCharWidth;
193 ptm32W->tmMaxCharWidth = ptm32A->tmMaxCharWidth;
194 ptm32W->tmWeight = ptm32A->tmWeight;
195 ptm32W->tmOverhang = ptm32A->tmOverhang;
196 ptm32W->tmDigitizedAspectX = ptm32A->tmDigitizedAspectX;
197 ptm32W->tmDigitizedAspectY = ptm32A->tmDigitizedAspectY;
198 ptm32W->tmFirstChar = ptm32A->tmFirstChar;
199 ptm32W->tmLastChar = ptm32A->tmLastChar;
200 ptm32W->tmDefaultChar = ptm32A->tmDefaultChar;
201 ptm32W->tmBreakChar = ptm32A->tmBreakChar;
202 ptm32W->tmItalic = ptm32A->tmItalic;
203 ptm32W->tmUnderlined = ptm32A->tmUnderlined;
204 ptm32W->tmStruckOut = ptm32A->tmStruckOut;
205 ptm32W->tmPitchAndFamily = ptm32A->tmPitchAndFamily;
206 ptm32W->tmCharSet = ptm32A->tmCharSet;
209 /***********************************************************************
210 * CreateFontIndirect16 (GDI.57)
212 HFONT16 WINAPI CreateFontIndirect16( const LOGFONT16 *font )
218 hFont = GDI_AllocObject( sizeof(FONTOBJ), FONT_MAGIC );
222 fontPtr = (FONTOBJ *) GDI_HEAP_LOCK( hFont );
223 memcpy( &fontPtr->logfont, font, sizeof(LOGFONT16) );
225 TRACE(font,"(%i %i) '%s' %s %s => %04x\n",
226 font->lfHeight, font->lfWidth,
227 font->lfFaceName ? font->lfFaceName : "NULL",
228 font->lfWeight > 400 ? "Bold" : "",
229 font->lfItalic ? "Italic" : "",
231 GDI_HEAP_UNLOCK( hFont );
234 else fprintf(stderr,"CreateFontIndirect(NULL) => NULL\n");
239 /***********************************************************************
240 * CreateFontIndirect32A (GDI32.44)
242 HFONT32 WINAPI CreateFontIndirect32A( const LOGFONT32A *font )
246 FONT_LogFont32ATo16( font, &font16 );
247 return CreateFontIndirect16( &font16 );
250 /***********************************************************************
251 * CreateFontIndirect32W (GDI32.45)
253 HFONT32 WINAPI CreateFontIndirect32W( const LOGFONT32W *font )
257 FONT_LogFont32WTo16( font, &font16 );
258 return CreateFontIndirect16( &font16 );
261 /***********************************************************************
262 * CreateFont16 (GDI.56)
264 HFONT16 WINAPI CreateFont16(INT16 height, INT16 width, INT16 esc, INT16 orient,
265 INT16 weight, BYTE italic, BYTE underline,
266 BYTE strikeout, BYTE charset, BYTE outpres,
267 BYTE clippres, BYTE quality, BYTE pitch,
270 LOGFONT16 logfont = { height, width, esc, orient, weight, italic, underline,
271 strikeout, charset, outpres, clippres, quality, pitch, };
273 TRACE(font,"('%s',%d,%d)\n",
274 (name ? name : "(null)") , height, width);
276 lstrcpyn32A(logfont.lfFaceName,name,sizeof(logfont.lfFaceName));
278 logfont.lfFaceName[0] = '\0';
279 return CreateFontIndirect16( &logfont );
282 /*************************************************************************
283 * CreateFont32A (GDI32.43)
285 HFONT32 WINAPI CreateFont32A( INT32 height, INT32 width, INT32 esc,
286 INT32 orient, INT32 weight, DWORD italic,
287 DWORD underline, DWORD strikeout, DWORD charset,
288 DWORD outpres, DWORD clippres, DWORD quality,
289 DWORD pitch, LPCSTR name )
291 return (HFONT32)CreateFont16( height, width, esc, orient, weight, italic,
292 underline, strikeout, charset, outpres,
293 clippres, quality, pitch, name );
296 /*************************************************************************
297 * CreateFont32W (GDI32.46)
299 HFONT32 WINAPI CreateFont32W( INT32 height, INT32 width, INT32 esc,
300 INT32 orient, INT32 weight, DWORD italic,
301 DWORD underline, DWORD strikeout, DWORD charset,
302 DWORD outpres, DWORD clippres, DWORD quality,
303 DWORD pitch, LPCWSTR name )
305 LPSTR namea = HEAP_strdupWtoA( GetProcessHeap(), 0, name );
306 HFONT32 ret = (HFONT32)CreateFont16( height, width, esc, orient, weight,
307 italic, underline, strikeout, charset,
308 outpres, clippres, quality, pitch,
310 if (namea) HeapFree( GetProcessHeap(), 0, namea );
315 /***********************************************************************
318 INT16 FONT_GetObject16( FONTOBJ * font, INT16 count, LPSTR buffer )
320 if (count > sizeof(LOGFONT16)) count = sizeof(LOGFONT16);
321 memcpy( buffer, &font->logfont, count );
325 /***********************************************************************
328 INT32 FONT_GetObject32A( FONTOBJ *font, INT32 count, LPSTR buffer )
332 FONT_LogFont16To32A( &font->logfont, &fnt32 );
334 if (count > sizeof(fnt32)) count = sizeof(fnt32);
335 memcpy( buffer, &fnt32, count );
340 /***********************************************************************
341 * FONT_EnumInstance16
343 * Called by the device driver layer to pass font info
344 * down to the application.
346 static INT32 FONT_EnumInstance16( LPENUMLOGFONT16 plf,
347 LPNEWTEXTMETRIC16 ptm, UINT16 fType, LPARAM lp )
349 #define pfe ((fontEnum16*)lp)
350 if( pfe->lpLogFontParam->lfCharSet == DEFAULT_CHARSET ||
351 pfe->lpLogFontParam->lfCharSet == plf->elfLogFont.lfCharSet )
353 memcpy( pfe->lpLogFont, plf, sizeof(ENUMLOGFONT16) );
354 memcpy( pfe->lpTextMetric, ptm, sizeof(NEWTEXTMETRIC16) );
356 return pfe->lpEnumFunc( pfe->segLogFont, pfe->segTextMetric, fType, (LPARAM)(pfe->lpData) );
362 /***********************************************************************
363 * FONT_EnumInstance32
365 static INT32 FONT_EnumInstance32( LPENUMLOGFONT16 plf,
366 LPNEWTEXTMETRIC16 ptm, UINT16 fType, LPARAM lp )
368 /* lfCharSet is at the same offset in both LOGFONT32A and LOGFONT32W */
370 #define pfe ((fontEnum32*)lp)
371 if( pfe->lpLogFontParam->lfCharSet == DEFAULT_CHARSET ||
372 pfe->lpLogFontParam->lfCharSet == plf->elfLogFont.lfCharSet )
374 /* convert font metrics */
376 if( pfe->dwFlags & ENUM_UNICODE )
378 FONT_LogFont16To32W( &plf->elfLogFont, (LPLOGFONT32W)(pfe->lpLogFont) );
379 FONT_TextMetric16to32W( (LPTEXTMETRIC16)ptm, (LPTEXTMETRIC32W)(pfe->lpTextMetric) );
383 FONT_LogFont16To32A( &plf->elfLogFont, (LPLOGFONT32A)pfe->lpLogFont );
384 FONT_TextMetric16to32A( (LPTEXTMETRIC16)ptm, (LPTEXTMETRIC32A)pfe->lpTextMetric );
387 return pfe->lpEnumFunc( (LPENUMLOGFONT32W)pfe->lpLogFont,
388 (LPNEWTEXTMETRIC32W)pfe->lpTextMetric, fType, pfe->lpData );
394 /***********************************************************************
395 * EnumFontFamiliesEx16 (GDI.613)
397 INT16 WINAPI EnumFontFamiliesEx16( HDC16 hDC, LPLOGFONT16 plf,
398 FONTENUMPROCEX16 efproc, LPARAM lParam,
402 DC* dc = (DC*) GDI_GetObjPtr( hDC, DC_MAGIC );
404 if( dc && dc->funcs->pEnumDeviceFonts )
406 LPNEWTEXTMETRICEX16 lptm16 = SEGPTR_ALLOC( sizeof(NEWTEXTMETRICEX16) );
409 LPENUMLOGFONTEX16 lplf16 = SEGPTR_ALLOC( sizeof(ENUMLOGFONTEX16) );
412 fontEnum16 fe16 = { plf, efproc, lParam, lptm16, lplf16,
413 SEGPTR_GET(lptm16), SEGPTR_GET(lplf16) };
415 retVal = dc->funcs->pEnumDeviceFonts( dc, plf, FONT_EnumInstance16, (LPARAM)&fe16 );
425 /***********************************************************************
426 * FONT_EnumFontFamiliesEx32
428 static INT32 FONT_EnumFontFamiliesEx32( HDC32 hDC, LPLOGFONT32W plf, FONTENUMPROC32W efproc,
429 LPARAM lParam, DWORD dwUnicode)
431 DC* dc = (DC*) GDI_GetObjPtr( hDC, DC_MAGIC );
433 if( dc && dc->funcs->pEnumDeviceFonts )
436 NEWTEXTMETRICEX32W tm32w;
437 ENUMLOGFONTEX32W lf32w;
438 fontEnum32 fe32 = { plf, efproc, lParam, &tm32w, &lf32w, dwUnicode };
440 /* the only difference between LOGFONT32A and LOGFONT32W is in the lfFaceName */
442 if( plf->lfFaceName[0] )
445 lstrcpynWtoA( lf16.lfFaceName, plf->lfFaceName, LF_FACESIZE );
447 lstrcpyn32A( lf16.lfFaceName, (LPCSTR)plf->lfFaceName, LF_FACESIZE );
449 else lf16.lfFaceName[0] = '\0';
450 lf16.lfCharSet = plf->lfCharSet;
452 return dc->funcs->pEnumDeviceFonts( dc, &lf16, FONT_EnumInstance32, (LPARAM)&fe32 );
457 /***********************************************************************
458 * EnumFontFamiliesEx32W (GDI32.82)
460 INT32 WINAPI EnumFontFamiliesEx32W( HDC32 hDC, LPLOGFONT32W plf,
461 FONTENUMPROCEX32W efproc,
462 LPARAM lParam, DWORD dwFlags )
464 return FONT_EnumFontFamiliesEx32( hDC, plf, (FONTENUMPROC32W)efproc,
465 lParam, ENUM_UNICODE );
468 /***********************************************************************
469 * EnumFontFamiliesEx32A (GDI32.81)
471 INT32 WINAPI EnumFontFamiliesEx32A( HDC32 hDC, LPLOGFONT32A plf,
472 FONTENUMPROCEX32A efproc,
473 LPARAM lParam, DWORD dwFlags)
475 return FONT_EnumFontFamiliesEx32( hDC, (LPLOGFONT32W)plf,
476 (FONTENUMPROC32W)efproc, lParam, 0);
479 /***********************************************************************
480 * EnumFontFamilies16 (GDI.330)
482 INT16 WINAPI EnumFontFamilies16( HDC16 hDC, LPCSTR lpFamily,
483 FONTENUMPROC16 efproc, LPARAM lpData )
487 lf.lfCharSet = DEFAULT_CHARSET;
488 if( lpFamily ) lstrcpyn32A( lf.lfFaceName, lpFamily, LF_FACESIZE );
489 else lf.lfFaceName[0] = '\0';
491 return EnumFontFamiliesEx16( hDC, &lf, (FONTENUMPROCEX16)efproc, lpData, 0 );
494 /***********************************************************************
495 * EnumFontFamilies32A (GDI32.80)
497 INT32 WINAPI EnumFontFamilies32A( HDC32 hDC, LPCSTR lpFamily,
498 FONTENUMPROC32A efproc, LPARAM lpData )
502 lf.lfCharSet = DEFAULT_CHARSET;
503 if( lpFamily ) lstrcpyn32A( lf.lfFaceName, lpFamily, LF_FACESIZE );
504 else lf.lfFaceName[0] = lf.lfFaceName[1] = '\0';
506 return FONT_EnumFontFamiliesEx32( hDC, (LPLOGFONT32W)&lf,
507 (FONTENUMPROC32W)efproc, lpData, 0 );
510 /***********************************************************************
511 * EnumFontFamilies32W (GDI32.83)
513 INT32 WINAPI EnumFontFamilies32W( HDC32 hDC, LPCWSTR lpFamily,
514 FONTENUMPROC32W efproc, LPARAM lpData )
518 lf.lfCharSet = DEFAULT_CHARSET;
519 if( lpFamily ) lstrcpyn32W( lf.lfFaceName, lpFamily, LF_FACESIZE );
520 else lf.lfFaceName[0] = 0;
522 return FONT_EnumFontFamiliesEx32( hDC, &lf, efproc, lpData, ENUM_UNICODE );
525 /***********************************************************************
526 * EnumFonts16 (GDI.70)
528 INT16 WINAPI EnumFonts16( HDC16 hDC, LPCSTR lpName, FONTENUMPROC16 efproc,
531 return EnumFontFamilies16( hDC, lpName, (FONTENUMPROCEX16)efproc, lpData );
534 /***********************************************************************
535 * EnumFonts32A (GDI32.84)
537 INT32 WINAPI EnumFonts32A( HDC32 hDC, LPCSTR lpName, FONTENUMPROC32A efproc,
540 return EnumFontFamilies32A( hDC, lpName, efproc, lpData );
543 /***********************************************************************
544 * EnumFonts32W (GDI32.85)
546 INT32 WINAPI EnumFonts32W( HDC32 hDC, LPCWSTR lpName, FONTENUMPROC32W efproc,
549 return EnumFontFamilies32W( hDC, lpName, efproc, lpData );
553 /***********************************************************************
554 * GetTextCharacterExtra16 (GDI.89)
556 INT16 WINAPI GetTextCharacterExtra16( HDC16 hdc )
558 DC * dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC );
560 return abs( (dc->w.charExtra * dc->wndExtX + dc->vportExtX / 2)
565 /***********************************************************************
566 * GetTextCharacterExtra32 (GDI32.225)
568 INT32 WINAPI GetTextCharacterExtra32( HDC32 hdc )
570 DC * dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC );
572 return abs( (dc->w.charExtra * dc->wndExtX + dc->vportExtX / 2)
577 /***********************************************************************
578 * SetTextCharacterExtra16 (GDI.8)
580 INT16 WINAPI SetTextCharacterExtra16( HDC16 hdc, INT16 extra )
582 return (INT16)SetTextCharacterExtra32( hdc, extra );
586 /***********************************************************************
587 * SetTextCharacterExtra32 (GDI32.337)
589 INT32 WINAPI SetTextCharacterExtra32( HDC32 hdc, INT32 extra )
592 DC * dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC );
594 extra = (extra * dc->vportExtX + dc->wndExtX / 2) / dc->wndExtX;
595 prev = dc->w.charExtra;
596 dc->w.charExtra = abs(extra);
597 return (prev * dc->wndExtX + dc->vportExtX / 2) / dc->vportExtX;
601 /***********************************************************************
602 * SetTextJustification16 (GDI.10)
604 INT16 WINAPI SetTextJustification16( HDC16 hdc, INT16 extra, INT16 breaks )
606 return SetTextJustification32( hdc, extra, breaks );
610 /***********************************************************************
611 * SetTextJustification32 (GDI32.339)
613 BOOL32 WINAPI SetTextJustification32( HDC32 hdc, INT32 extra, INT32 breaks )
615 DC * dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC );
618 extra = abs((extra * dc->vportExtX + dc->wndExtX / 2) / dc->wndExtX);
619 if (!extra) breaks = 0;
620 dc->w.breakTotalExtra = extra;
621 dc->w.breakCount = breaks;
624 dc->w.breakExtra = extra / breaks;
625 dc->w.breakRem = extra - (dc->w.breakCount * dc->w.breakExtra);
629 dc->w.breakExtra = 0;
636 /***********************************************************************
637 * GetTextFace16 (GDI.92)
639 INT16 WINAPI GetTextFace16( HDC16 hdc, INT16 count, LPSTR name )
641 return GetTextFace32A(hdc,count,name);
644 /***********************************************************************
645 * GetTextFace32A (GDI32.234)
647 INT32 WINAPI GetTextFace32A( HDC32 hdc, INT32 count, LPSTR name )
651 DC * dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC );
653 if (!(font = (FONTOBJ *) GDI_GetObjPtr( dc->w.hFont, FONT_MAGIC )))
655 lstrcpyn32A( name, font->logfont.lfFaceName, count );
656 GDI_HEAP_UNLOCK( dc->w.hFont );
660 /***********************************************************************
661 * GetTextFace32W (GDI32.235)
663 INT32 WINAPI GetTextFace32W( HDC32 hdc, INT32 count, LPWSTR name )
665 LPSTR nameA = HeapAlloc( GetProcessHeap(), 0, count );
666 INT32 res = GetTextFace32A(hdc,count,nameA);
667 lstrcpyAtoW( name, nameA );
668 HeapFree( GetProcessHeap(), 0, nameA );
673 /***********************************************************************
674 * GetTextExtent (GDI.91)
676 DWORD WINAPI GetTextExtent( HDC16 hdc, LPCSTR str, INT16 count )
679 if (!GetTextExtentPoint16( hdc, str, count, &size )) return 0;
680 return MAKELONG( size.cx, size.cy );
684 /***********************************************************************
685 * GetTextExtentPoint16 (GDI.471)
687 * FIXME: Should this have a bug for compatibility?
688 * Original Windows versions of GetTextExtentPoint{A,W} have documented
691 BOOL16 WINAPI GetTextExtentPoint16( HDC16 hdc, LPCSTR str, INT16 count,
695 BOOL32 ret = GetTextExtentPoint32A( hdc, str, count, &size32 );
696 CONV_SIZE32TO16( &size32, size );
701 /***********************************************************************
702 * GetTextExtentPoint32A (GDI32.230)
704 BOOL32 WINAPI GetTextExtentPoint32A( HDC32 hdc, LPCSTR str, INT32 count,
707 DC * dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC );
710 if (!(dc = (DC *)GDI_GetObjPtr( hdc, METAFILE_DC_MAGIC )))
714 if (!dc->funcs->pGetTextExtentPoint ||
715 !dc->funcs->pGetTextExtentPoint( dc, str, count, size ))
718 TRACE(font,"(%08x %s %d %p): returning %d,%d\n",
719 hdc, debugstr_an (str, count), count,
720 size, size->cx, size->cy );
725 /***********************************************************************
726 * GetTextExtentPoint32W (GDI32.231)
728 BOOL32 WINAPI GetTextExtentPoint32W( HDC32 hdc, LPCWSTR str, INT32 count,
731 LPSTR p = HEAP_strdupWtoA( GetProcessHeap(), 0, str );
732 BOOL32 ret = GetTextExtentPoint32A( hdc, p, count, size );
733 HeapFree( GetProcessHeap(), 0, p );
738 /***********************************************************************
739 * GetTextExtentPoint32ABuggy (GDI32.232)
741 BOOL32 WINAPI GetTextExtentPoint32ABuggy( HDC32 hdc, LPCSTR str, INT32 count,
744 TRACE(font, "not bug compatible.\n");
745 return GetTextExtentPoint32A( hdc, str, count, size );
748 /***********************************************************************
749 * GetTextExtentPoint32WBuggy (GDI32.233)
751 BOOL32 WINAPI GetTextExtentPoint32WBuggy( HDC32 hdc, LPCWSTR str, INT32 count,
754 TRACE(font, "not bug compatible.\n");
755 return GetTextExtentPoint32W( hdc, str, count, size );
759 /***********************************************************************
760 * GetTextExtentExPoint32A (GDI32.228)
762 BOOL32 WINAPI GetTextExtentExPoint32A( HDC32 hdc, LPCSTR str, INT32 count,
763 INT32 maxExt, LPINT32 lpnFit,
764 LPINT32 alpDx, LPSIZE32 size )
766 int index, nFit, extent;
768 DC * dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC );
772 if (!(dc = (DC *)GDI_GetObjPtr( hdc, METAFILE_DC_MAGIC )))
775 if (!dc->funcs->pGetTextExtentPoint) return FALSE;
777 size->cx = size->cy = nFit = extent = 0;
778 for(index = 0; index < count; index++)
780 if(!dc->funcs->pGetTextExtentPoint( dc, str, 1, &tSize )) return FALSE;
781 if( extent+tSize.cx < maxExt )
786 if( alpDx ) alpDx[index] = extent;
787 if( tSize.cy > size->cy ) size->cy = tSize.cy;
794 TRACE(font,"(%08x '%.*s' %d) returning %d %d %d\n",
795 hdc,count,str,maxExt,nFit, size->cx,size->cy);
800 /***********************************************************************
801 * GetTextExtentExPoint32W (GDI32.229)
804 BOOL32 WINAPI GetTextExtentExPoint32W( HDC32 hdc, LPCWSTR str, INT32 count,
805 INT32 maxExt, LPINT32 lpnFit,
806 LPINT32 alpDx, LPSIZE32 size )
808 LPSTR p = HEAP_strdupWtoA( GetProcessHeap(), 0, str );
809 BOOL32 ret = GetTextExtentExPoint32A( hdc, p, count, maxExt,
810 lpnFit, alpDx, size);
811 HeapFree( GetProcessHeap(), 0, p );
815 /***********************************************************************
816 * GetTextMetrics16 (GDI.93)
818 BOOL16 WINAPI GetTextMetrics16( HDC16 hdc, TEXTMETRIC16 *metrics )
822 if (!GetTextMetrics32A( (HDC32)hdc, &tm32 )) return FALSE;
823 FONT_TextMetric32Ato16( &tm32, metrics );
828 /***********************************************************************
829 * GetTextMetrics32A (GDI32.236)
831 BOOL32 WINAPI GetTextMetrics32A( HDC32 hdc, TEXTMETRIC32A *metrics )
833 DC * dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC );
836 if (!(dc = (DC *)GDI_GetObjPtr( hdc, METAFILE_DC_MAGIC )))
840 if (!dc->funcs->pGetTextMetrics ||
841 !dc->funcs->pGetTextMetrics( dc, metrics ))
844 /* device layer returns values in device units
845 * therefore we have to convert them to logical */
847 #define WDPTOLP(x) ((x<0)? \
848 (-abs((x)*dc->wndExtX/dc->vportExtX)): \
849 (abs((x)*dc->wndExtX/dc->vportExtX)))
850 #define HDPTOLP(y) ((y<0)? \
851 (-abs((y)*dc->wndExtY/dc->vportExtY)): \
852 (abs((y)*dc->wndExtY/dc->vportExtY)))
854 metrics->tmHeight = HDPTOLP(metrics->tmHeight);
855 metrics->tmAscent = HDPTOLP(metrics->tmAscent);
856 metrics->tmDescent = HDPTOLP(metrics->tmDescent);
857 metrics->tmInternalLeading = HDPTOLP(metrics->tmInternalLeading);
858 metrics->tmExternalLeading = HDPTOLP(metrics->tmExternalLeading);
859 metrics->tmAveCharWidth = WDPTOLP(metrics->tmAveCharWidth);
860 metrics->tmMaxCharWidth = WDPTOLP(metrics->tmMaxCharWidth);
861 metrics->tmOverhang = WDPTOLP(metrics->tmOverhang);
863 TRACE(font,"text metrics:
864 Weight = %03i\t FirstChar = %03i\t AveCharWidth = %i
865 Italic = % 3i\t LastChar = %03i\t\t MaxCharWidth = %i
866 UnderLined = %01i\t DefaultChar = %03i\t Overhang = %i
867 StruckOut = %01i\t BreakChar = %03i\t CharSet = %i
868 PitchAndFamily = %02x
874 metrics->tmWeight, metrics->tmFirstChar, metrics->tmAveCharWidth,
875 metrics->tmItalic, metrics->tmLastChar, metrics->tmMaxCharWidth,
876 metrics->tmUnderlined, metrics->tmDefaultChar, metrics->tmOverhang,
877 metrics->tmStruckOut, metrics->tmBreakChar, metrics->tmCharSet,
878 metrics->tmPitchAndFamily,
879 metrics->tmInternalLeading,
887 /***********************************************************************
888 * GetTextMetrics32W (GDI32.237)
890 BOOL32 WINAPI GetTextMetrics32W( HDC32 hdc, TEXTMETRIC32W *metrics )
893 if (!GetTextMetrics32A( (HDC16)hdc, &tm )) return FALSE;
894 FONT_TextMetric32Ato32W( &tm, metrics );
899 /***********************************************************************
900 * GetCharWidth16 (GDI.350)
902 BOOL16 WINAPI GetCharWidth16( HDC16 hdc, UINT16 firstChar, UINT16 lastChar,
905 BOOL32 retVal = FALSE;
907 if( firstChar != lastChar )
909 LPINT32 buf32 = (LPINT32)HeapAlloc(GetProcessHeap(), 0,
910 sizeof(INT32)*(1 + (lastChar - firstChar)));
913 LPINT32 obuf32 = buf32;
916 retVal = GetCharWidth32A(hdc, firstChar, lastChar, buf32);
919 for (i = firstChar; i <= lastChar; i++)
920 *buffer++ = *buf32++;
922 HeapFree(GetProcessHeap(), 0, obuf32);
925 else /* happens quite often to warrant a special treatment */
928 retVal = GetCharWidth32A(hdc, firstChar, lastChar, &chWidth );
935 /***********************************************************************
936 * GetCharWidth32A (GDI32.155)
938 BOOL32 WINAPI GetCharWidth32A( HDC32 hdc, UINT32 firstChar, UINT32 lastChar,
942 DC * dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC );
945 if (!(dc = (DC *)GDI_GetObjPtr( hdc, METAFILE_DC_MAGIC )))
949 if (!dc->funcs->pGetCharWidth ||
950 !dc->funcs->pGetCharWidth( dc, firstChar, lastChar, buffer))
953 /* convert device units to logical */
955 extra = dc->vportExtX >> 1;
956 for( i = firstChar; i <= lastChar; i++, buffer++ )
957 *buffer = (*buffer * dc->wndExtX + extra) / dc->vportExtX;
963 /***********************************************************************
964 * GetCharWidth32W (GDI32.158)
966 BOOL32 WINAPI GetCharWidth32W( HDC32 hdc, UINT32 firstChar, UINT32 lastChar,
969 return GetCharWidth32A( hdc, firstChar, lastChar, buffer );
974 /* FIXME: all following APIs *******************************************
977 * SetMapperFlags16 (GDI.349)
979 DWORD WINAPI SetMapperFlags16( HDC16 hDC, DWORD dwFlag )
981 return SetMapperFlags32( hDC, dwFlag );
985 /***********************************************************************
986 * SetMapperFlags32 (GDI32.322)
988 DWORD WINAPI SetMapperFlags32( HDC32 hDC, DWORD dwFlag )
990 FIXME(font, "(%04x, %08lX) -- Empty Stub !\n",
995 /***********************************************************************
996 * GetAspectRatioFilterEx16 (GDI.486)
998 BOOL16 GetAspectRatioFilterEx16( HDC16 hdc, LPVOID pAspectRatio )
1000 FIXME(font, "(%04x, %p): -- Empty Stub !\n",
1006 /***********************************************************************
1007 * GetCharABCWidths16 (GDI.307)
1009 BOOL16 WINAPI GetCharABCWidths16( HDC16 hdc, UINT16 firstChar, UINT16 lastChar,
1013 if (!GetCharABCWidths32A( hdc, firstChar, lastChar, &abc32 )) return FALSE;
1014 abc->abcA = abc32.abcA;
1015 abc->abcB = abc32.abcB;
1016 abc->abcC = abc32.abcC;
1021 /***********************************************************************
1022 * GetCharABCWidths32A (GDI32.149)
1024 BOOL32 WINAPI GetCharABCWidths32A(HDC32 hdc, UINT32 firstChar, UINT32 lastChar,
1027 /* No TrueType fonts in Wine so far */
1028 fprintf( stdnimp, "STUB: GetCharABCWidths(%04x,%04x,%04x,%p)\n",
1029 hdc, firstChar, lastChar, abc );
1034 /***********************************************************************
1035 * GetCharABCWidths32W (GDI32.152)
1037 BOOL32 WINAPI GetCharABCWidths32W(HDC32 hdc, UINT32 firstChar, UINT32 lastChar,
1040 return GetCharABCWidths32A( hdc, firstChar, lastChar, abc );
1044 /***********************************************************************
1045 * GetGlyphOutline16 (GDI.309)
1047 DWORD WINAPI GetGlyphOutline16( HDC16 hdc, UINT16 uChar, UINT16 fuFormat,
1048 LPGLYPHMETRICS16 lpgm, DWORD cbBuffer,
1049 LPVOID lpBuffer, const MAT2 *lpmat2 )
1051 fprintf( stdnimp,"GetGlyphOutLine16(%04x, '%c', %04x, %p, %ld, %p, %p) // - empty stub!\n",
1052 hdc, uChar, fuFormat, lpgm, cbBuffer, lpBuffer, lpmat2 );
1053 return (DWORD)-1; /* failure */
1057 /***********************************************************************
1058 * GetGlyphOutline32A (GDI32.186)
1060 DWORD WINAPI GetGlyphOutline32A( HDC32 hdc, UINT32 uChar, UINT32 fuFormat,
1061 LPGLYPHMETRICS32 lpgm, DWORD cbBuffer,
1062 LPVOID lpBuffer, const MAT2 *lpmat2 )
1064 fprintf( stdnimp,"GetGlyphOutLine32A(%04x, '%c', %04x, %p, %ld, %p, %p) // - empty stub!\n",
1065 hdc, uChar, fuFormat, lpgm, cbBuffer, lpBuffer, lpmat2 );
1066 return (DWORD)-1; /* failure */
1069 /***********************************************************************
1070 * GetGlyphOutline32W (GDI32.187)
1072 DWORD WINAPI GetGlyphOutline32W( HDC32 hdc, UINT32 uChar, UINT32 fuFormat,
1073 LPGLYPHMETRICS32 lpgm, DWORD cbBuffer,
1074 LPVOID lpBuffer, const MAT2 *lpmat2 )
1076 fprintf( stdnimp,"GetGlyphOutLine32W(%04x, '%c', %04x, %p, %ld, %p, %p) // - empty stub!\n",
1077 hdc, uChar, fuFormat, lpgm, cbBuffer, lpBuffer, lpmat2 );
1078 return (DWORD)-1; /* failure */
1081 /***********************************************************************
1082 * CreateScalableFontResource16 (GDI.310)
1084 BOOL16 WINAPI CreateScalableFontResource16( UINT16 fHidden,
1085 LPCSTR lpszResourceFile,
1086 LPCSTR fontFile, LPCSTR path )
1088 return CreateScalableFontResource32A( fHidden, lpszResourceFile,
1092 /***********************************************************************
1093 * CreateScalableFontResource32A (GDI32.62)
1095 BOOL32 WINAPI CreateScalableFontResource32A( DWORD fHidden,
1096 LPCSTR lpszResourceFile,
1097 LPCSTR lpszFontFile,
1098 LPCSTR lpszCurrentPath )
1100 /* fHidden=1 - only visible for the calling app, read-only, not
1101 * enumbered with EnumFonts/EnumFontFamilies
1102 * lpszCurrentPath can be NULL
1104 fprintf(stdnimp,"CreateScalableFontResource(%ld,%s,%s,%s) // empty stub\n",
1105 fHidden, lpszResourceFile, lpszFontFile, lpszCurrentPath );
1106 return FALSE; /* create failed */
1109 /***********************************************************************
1110 * CreateScalableFontResource32W (GDI32.63)
1112 BOOL32 WINAPI CreateScalableFontResource32W( DWORD fHidden,
1113 LPCWSTR lpszResourceFile,
1114 LPCWSTR lpszFontFile,
1115 LPCWSTR lpszCurrentPath )
1117 fprintf(stdnimp,"CreateScalableFontResource32W(%ld,%p,%p,%p) // empty stub\n",
1118 fHidden, lpszResourceFile, lpszFontFile, lpszCurrentPath );
1119 return FALSE; /* create failed */
1123 /*************************************************************************
1124 * GetRasterizerCaps16 (GDI.313)
1126 BOOL16 WINAPI GetRasterizerCaps16( LPRASTERIZER_STATUS lprs, UINT16 cbNumBytes)
1128 return GetRasterizerCaps32( lprs, cbNumBytes );
1132 /*************************************************************************
1133 * GetRasterizerCaps32 (GDI32.216)
1135 BOOL32 WINAPI GetRasterizerCaps32( LPRASTERIZER_STATUS lprs, UINT32 cbNumBytes)
1137 lprs->nSize = sizeof(RASTERIZER_STATUS);
1138 lprs->wFlags = TT_AVAILABLE|TT_ENABLED;
1139 lprs->nLanguageID = 0;
1144 /*************************************************************************
1145 * GetKerningPairs16 (GDI.332)
1147 INT16 WINAPI GetKerningPairs16( HDC16 hDC, INT16 cPairs,
1148 LPKERNINGPAIR16 lpKerningPairs )
1150 /* At this time kerning is ignored (set to 0) */
1152 fprintf(stdnimp,"GetKerningPairs16: almost empty stub!\n");
1153 for (i = 0; i < cPairs; i++) lpKerningPairs[i].iKernAmount = 0;
1159 /*************************************************************************
1160 * GetKerningPairs32A (GDI32.192)
1162 DWORD WINAPI GetKerningPairs32A( HDC32 hDC, DWORD cPairs,
1163 LPKERNINGPAIR32 lpKerningPairs )
1166 fprintf(stdnimp,"GetKerningPairs32: almost empty stub!\n");
1167 for (i = 0; i < cPairs; i++) lpKerningPairs[i].iKernAmount = 0;
1172 /*************************************************************************
1173 * GetKerningPairs32W (GDI32.193)
1175 DWORD WINAPI GetKerningPairs32W( HDC32 hDC, DWORD cPairs,
1176 LPKERNINGPAIR32 lpKerningPairs )
1178 return GetKerningPairs32A( hDC, cPairs, lpKerningPairs );
1181 BOOL32 WINAPI TranslateCharSetInfo(LPDWORD lpSrc,LPCHARSETINFO lpCs,DWORD dwFlags) {
1182 fprintf(stderr,"TranslateCharSetInfo(%p,%p,0x%08lx), stub.\n",
1189 /*************************************************************************
1190 * GetFontLanguageInfo (GDI32.182)
1192 DWORD WINAPI GetFontLanguageInfo32(HDC32 hdc) {
1193 /* return value 0 is correct for most cases anyway */
1194 fprintf(stderr,"GetFontLanguageInfo:stub!\n");
1198 /*************************************************************************
1199 * GetFontLanguageInfo (GDI.616)
1201 DWORD WINAPI GetFontLanguageInfo16(HDC16 hdc) {
1202 /* return value 0 is correct for most cases anyway */
1203 fprintf(stderr,"GetFontLanguageInfo:stub!\n");