3 * COPYRIGHT: See COPYING in the top level directory
4 * PROJECT: ReactOS system libraries
5 * FILE: lib/gdi32/object/font.c
17 * For TranslateCharsetInfo
19 #define MAXTCIINDEX 32
20 static const CHARSETINFO FONT_tci
[MAXTCIINDEX
] = {
22 { ANSI_CHARSET
, 1252, {{0,0,0,0},{FS_LATIN1
,0}} },
23 { EASTEUROPE_CHARSET
, 1250, {{0,0,0,0},{FS_LATIN2
,0}} },
24 { RUSSIAN_CHARSET
, 1251, {{0,0,0,0},{FS_CYRILLIC
,0}} },
25 { GREEK_CHARSET
, 1253, {{0,0,0,0},{FS_GREEK
,0}} },
26 { TURKISH_CHARSET
, 1254, {{0,0,0,0},{FS_TURKISH
,0}} },
27 { HEBREW_CHARSET
, 1255, {{0,0,0,0},{FS_HEBREW
,0}} },
28 { ARABIC_CHARSET
, 1256, {{0,0,0,0},{FS_ARABIC
,0}} },
29 { BALTIC_CHARSET
, 1257, {{0,0,0,0},{FS_BALTIC
,0}} },
30 { VIETNAMESE_CHARSET
, 1258, {{0,0,0,0},{FS_VIETNAMESE
,0}} },
31 /* reserved by ANSI */
32 { DEFAULT_CHARSET
, 0, {{0,0,0,0},{FS_LATIN1
,0}} },
33 { DEFAULT_CHARSET
, 0, {{0,0,0,0},{FS_LATIN1
,0}} },
34 { DEFAULT_CHARSET
, 0, {{0,0,0,0},{FS_LATIN1
,0}} },
35 { DEFAULT_CHARSET
, 0, {{0,0,0,0},{FS_LATIN1
,0}} },
36 { DEFAULT_CHARSET
, 0, {{0,0,0,0},{FS_LATIN1
,0}} },
37 { DEFAULT_CHARSET
, 0, {{0,0,0,0},{FS_LATIN1
,0}} },
38 { DEFAULT_CHARSET
, 0, {{0,0,0,0},{FS_LATIN1
,0}} },
40 { THAI_CHARSET
, 874, {{0,0,0,0},{FS_THAI
,0}} },
41 { SHIFTJIS_CHARSET
, 932, {{0,0,0,0},{FS_JISJAPAN
,0}} },
42 { GB2312_CHARSET
, 936, {{0,0,0,0},{FS_CHINESESIMP
,0}} },
43 { HANGEUL_CHARSET
, 949, {{0,0,0,0},{FS_WANSUNG
,0}} },
44 { CHINESEBIG5_CHARSET
, 950, {{0,0,0,0},{FS_CHINESETRAD
,0}} },
45 { JOHAB_CHARSET
, 1361, {{0,0,0,0},{FS_JOHAB
,0}} },
46 /* reserved for alternate ANSI and OEM */
47 { DEFAULT_CHARSET
, 0, {{0,0,0,0},{FS_LATIN1
,0}} },
48 { DEFAULT_CHARSET
, 0, {{0,0,0,0},{FS_LATIN1
,0}} },
49 { DEFAULT_CHARSET
, 0, {{0,0,0,0},{FS_LATIN1
,0}} },
50 { DEFAULT_CHARSET
, 0, {{0,0,0,0},{FS_LATIN1
,0}} },
51 { DEFAULT_CHARSET
, 0, {{0,0,0,0},{FS_LATIN1
,0}} },
52 { DEFAULT_CHARSET
, 0, {{0,0,0,0},{FS_LATIN1
,0}} },
53 { DEFAULT_CHARSET
, 0, {{0,0,0,0},{FS_LATIN1
,0}} },
54 { DEFAULT_CHARSET
, 0, {{0,0,0,0},{FS_LATIN1
,0}} },
55 /* reserved for system */
56 { DEFAULT_CHARSET
, 0, {{0,0,0,0},{FS_LATIN1
,0}} },
57 { SYMBOL_CHARSET
, CP_SYMBOL
, {{0,0,0,0},{FS_SYMBOL
,0}} }
60 #define INITIAL_FAMILY_COUNT 64
62 /***********************************************************************
63 * TEXTMETRIC conversion functions.
65 static void FONT_TextMetricWToA(const TEXTMETRICW
*ptmW
, LPTEXTMETRICA ptmA
)
67 ptmA
->tmHeight
= ptmW
->tmHeight
;
68 ptmA
->tmAscent
= ptmW
->tmAscent
;
69 ptmA
->tmDescent
= ptmW
->tmDescent
;
70 ptmA
->tmInternalLeading
= ptmW
->tmInternalLeading
;
71 ptmA
->tmExternalLeading
= ptmW
->tmExternalLeading
;
72 ptmA
->tmAveCharWidth
= ptmW
->tmAveCharWidth
;
73 ptmA
->tmMaxCharWidth
= ptmW
->tmMaxCharWidth
;
74 ptmA
->tmWeight
= ptmW
->tmWeight
;
75 ptmA
->tmOverhang
= ptmW
->tmOverhang
;
76 ptmA
->tmDigitizedAspectX
= ptmW
->tmDigitizedAspectX
;
77 ptmA
->tmDigitizedAspectY
= ptmW
->tmDigitizedAspectY
;
78 ptmA
->tmFirstChar
= ptmW
->tmFirstChar
> 255 ? 255 : ptmW
->tmFirstChar
;
79 ptmA
->tmLastChar
= ptmW
->tmLastChar
> 255 ? 255 : ptmW
->tmLastChar
;
80 ptmA
->tmDefaultChar
= ptmW
->tmDefaultChar
> 255 ? 255 : ptmW
->tmDefaultChar
;
81 ptmA
->tmBreakChar
= ptmW
->tmBreakChar
> 255 ? 255 : ptmW
->tmBreakChar
;
82 ptmA
->tmItalic
= ptmW
->tmItalic
;
83 ptmA
->tmUnderlined
= ptmW
->tmUnderlined
;
84 ptmA
->tmStruckOut
= ptmW
->tmStruckOut
;
85 ptmA
->tmPitchAndFamily
= ptmW
->tmPitchAndFamily
;
86 ptmA
->tmCharSet
= ptmW
->tmCharSet
;
89 /***********************************************************************
92 * Returns a Unicode translation of str using the charset of the
93 * currently selected font in hdc. If count is -1 then str is assumed
94 * to be '\0' terminated, otherwise it contains the number of bytes to
95 * convert. If plenW is non-NULL, on return it will point to the
96 * number of WCHARs that have been written. If pCP is non-NULL, on
97 * return it will point to the codepage used in the conversion. The
98 * caller should free the returned LPWSTR from the process heap
101 static LPWSTR
FONT_mbtowc(HDC hdc
, LPCSTR str
, INT count
, INT
*plenW
, UINT
*pCP
)
103 UINT cp
= GdiGetCodePage( hdc
);
107 if(count
== -1) count
= strlen(str
);
108 lenW
= MultiByteToWideChar(cp
, 0, str
, count
, NULL
, 0);
109 strW
= HeapAlloc(GetProcessHeap(), 0, lenW
*sizeof(WCHAR
));
110 MultiByteToWideChar(cp
, 0, str
, count
, strW
, lenW
);
111 DPRINT1("mapped %s -> %S\n", str
, strW
);
112 if(plenW
) *plenW
= lenW
;
119 MetricsCharConvert(WCHAR w
, UCHAR
*b
)
121 UNICODE_STRING WString
;
135 RtlInitUnicodeString(&WString
, WBuf
);
138 RtlInitAnsiString(&AString
, ABuf
);
140 Status
= RtlUnicodeStringToAnsiString(&AString
, &WString
, FALSE
);
141 if (! NT_SUCCESS(Status
))
143 SetLastError(RtlNtStatusToDosError(Status
));
153 TextMetricW2A(TEXTMETRICA
*tma
, TEXTMETRICW
*tmw
)
155 UNICODE_STRING WString
;
162 tma
->tmHeight
= tmw
->tmHeight
;
163 tma
->tmAscent
= tmw
->tmAscent
;
164 tma
->tmDescent
= tmw
->tmDescent
;
165 tma
->tmInternalLeading
= tmw
->tmInternalLeading
;
166 tma
->tmExternalLeading
= tmw
->tmExternalLeading
;
167 tma
->tmAveCharWidth
= tmw
->tmAveCharWidth
;
168 tma
->tmMaxCharWidth
= tmw
->tmMaxCharWidth
;
169 tma
->tmWeight
= tmw
->tmWeight
;
170 tma
->tmOverhang
= tmw
->tmOverhang
;
171 tma
->tmDigitizedAspectX
= tmw
->tmDigitizedAspectX
;
172 tma
->tmDigitizedAspectY
= tmw
->tmDigitizedAspectY
;
174 /* The Unicode FirstChar/LastChar need not correspond to the ANSI
175 FirstChar/LastChar. For example, if the font contains glyphs for
176 letters A-Z and an accented version of the letter e, the Unicode
177 FirstChar would be A and the Unicode LastChar would be the accented
178 e. If you just translate those to ANSI, the range would become
179 letters A-E instead of A-Z.
180 We translate all possible ANSI chars to Unicode and find the first
181 and last translated character which fall into the Unicode FirstChar/
182 LastChar range and return the corresponding ANSI char. */
184 /* Setup an Ansi string containing all possible letters (note: skip '\0' at
185 the beginning since that would be interpreted as end-of-string, handle
186 '\0' special later */
187 for (Letter
= 1; Letter
< 256; Letter
++)
189 ABuf
[Letter
- 1] = (CHAR
) Letter
;
190 WBuf
[Letter
- 1] = L
' ';
194 RtlInitAnsiString(&AString
, ABuf
);
195 RtlInitUnicodeString(&WString
, WBuf
);
197 /* Find the corresponding Unicode characters */
198 Status
= RtlAnsiStringToUnicodeString(&WString
, &AString
, FALSE
);
199 if (! NT_SUCCESS(Status
))
201 SetLastError(RtlNtStatusToDosError(Status
));
205 /* Scan for the first ANSI character which maps to an Unicode character
207 tma
->tmFirstChar
= '\0';
208 if (L
'\0' != tmw
->tmFirstChar
)
210 for (Letter
= 1; Letter
< 256; Letter
++)
212 if (tmw
->tmFirstChar
<= WBuf
[Letter
- 1] &&
213 WBuf
[Letter
- 1] <= tmw
->tmLastChar
)
215 tma
->tmFirstChar
= (CHAR
) Letter
;
221 /* Scan for the last ANSI character which maps to an Unicode character
223 tma
->tmLastChar
= '\0';
224 if (L
'\0' != tmw
->tmLastChar
)
226 for (Letter
= 255; 0 < Letter
; Letter
--)
228 if (tmw
->tmFirstChar
<= WBuf
[Letter
- 1] &&
229 WBuf
[Letter
- 1] <= tmw
->tmLastChar
)
231 tma
->tmLastChar
= (CHAR
) Letter
;
237 if (! MetricsCharConvert(tmw
->tmDefaultChar
, &tma
->tmDefaultChar
) ||
238 ! MetricsCharConvert(tmw
->tmBreakChar
, &tma
->tmBreakChar
))
243 tma
->tmItalic
= tmw
->tmItalic
;
244 tma
->tmUnderlined
= tmw
->tmUnderlined
;
245 tma
->tmStruckOut
= tmw
->tmStruckOut
;
246 tma
->tmPitchAndFamily
= tmw
->tmPitchAndFamily
;
247 tma
->tmCharSet
= tmw
->tmCharSet
;
253 NewTextMetricW2A(NEWTEXTMETRICA
*tma
, NEWTEXTMETRICW
*tmw
)
255 if (! TextMetricW2A((TEXTMETRICA
*) tma
, (TEXTMETRICW
*) tmw
))
260 tma
->ntmFlags
= tmw
->ntmFlags
;
261 tma
->ntmSizeEM
= tmw
->ntmSizeEM
;
262 tma
->ntmCellHeight
= tmw
->ntmCellHeight
;
263 tma
->ntmAvgWidth
= tmw
->ntmAvgWidth
;
269 NewTextMetricExW2A(NEWTEXTMETRICEXA
*tma
, NEWTEXTMETRICEXW
*tmw
)
271 if (! NewTextMetricW2A(&tma
->ntmTm
, &tmw
->ntmTm
))
276 tma
->ntmFontSig
= tmw
->ntmFontSig
;
282 IntEnumFontFamilies(HDC Dc
, LPLOGFONTW LogFont
, PVOID EnumProc
, LPARAM lParam
,
287 PFONTFAMILYINFO Info
;
290 ENUMLOGFONTEXA EnumLogFontExA
;
291 NEWTEXTMETRICEXA NewTextMetricExA
;
293 Info
= RtlAllocateHeap(GetProcessHeap(), 0,
294 INITIAL_FAMILY_COUNT
* sizeof(FONTFAMILYINFO
));
299 FontFamilyCount
= NtGdiGetFontFamilyInfo(Dc
, LogFont
, Info
, INITIAL_FAMILY_COUNT
);
300 if (FontFamilyCount
< 0)
302 RtlFreeHeap(GetProcessHeap(), 0, Info
);
305 if (INITIAL_FAMILY_COUNT
< FontFamilyCount
)
307 FontFamilySize
= FontFamilyCount
;
308 RtlFreeHeap(GetProcessHeap(), 0, Info
);
309 Info
= RtlAllocateHeap(GetProcessHeap(), 0,
310 FontFamilyCount
* sizeof(FONTFAMILYINFO
));
315 FontFamilyCount
= NtGdiGetFontFamilyInfo(Dc
, LogFont
, Info
, FontFamilySize
);
316 if (FontFamilyCount
< 0 || FontFamilySize
< FontFamilyCount
)
318 RtlFreeHeap(GetProcessHeap(), 0, Info
);
323 for (i
= 0; i
< FontFamilyCount
; i
++)
327 Ret
= ((FONTENUMPROCW
) EnumProc
)(
328 &Info
[i
].EnumLogFontEx
,
329 &Info
[i
].NewTextMetricEx
,
330 Info
[i
].FontType
, lParam
);
333 { // Could use EnumLogFontExW2A here?
334 LogFontW2A(&EnumLogFontExA
.elfLogFont
, &Info
[i
].EnumLogFontEx
.elfLogFont
);
335 WideCharToMultiByte(CP_THREAD_ACP
, 0, Info
[i
].EnumLogFontEx
.elfFullName
, -1,
336 (LPSTR
)EnumLogFontExA
.elfFullName
, LF_FULLFACESIZE
, NULL
, NULL
);
337 WideCharToMultiByte(CP_THREAD_ACP
, 0, Info
[i
].EnumLogFontEx
.elfStyle
, -1,
338 (LPSTR
)EnumLogFontExA
.elfStyle
, LF_FACESIZE
, NULL
, NULL
);
339 WideCharToMultiByte(CP_THREAD_ACP
, 0, Info
[i
].EnumLogFontEx
.elfScript
, -1,
340 (LPSTR
)EnumLogFontExA
.elfScript
, LF_FACESIZE
, NULL
, NULL
);
341 NewTextMetricExW2A(&NewTextMetricExA
,
342 &Info
[i
].NewTextMetricEx
);
343 Ret
= ((FONTENUMPROCA
) EnumProc
)(
346 Info
[i
].FontType
, lParam
);
350 RtlFreeHeap(GetProcessHeap(), 0, Info
);
359 EnumFontFamiliesExW(HDC hdc
, LPLOGFONTW lpLogfont
, FONTENUMPROCW lpEnumFontFamExProc
,
360 LPARAM lParam
, DWORD dwFlags
)
362 return IntEnumFontFamilies(hdc
, lpLogfont
, lpEnumFontFamExProc
, lParam
, TRUE
);
370 EnumFontFamiliesW(HDC hdc
, LPCWSTR lpszFamily
, FONTENUMPROCW lpEnumFontFamProc
,
375 ZeroMemory(&LogFont
, sizeof(LOGFONTW
));
376 LogFont
.lfCharSet
= DEFAULT_CHARSET
;
377 if (NULL
!= lpszFamily
)
379 lstrcpynW(LogFont
.lfFaceName
, lpszFamily
, LF_FACESIZE
);
382 return IntEnumFontFamilies(hdc
, &LogFont
, lpEnumFontFamProc
, lParam
, TRUE
);
390 EnumFontFamiliesExA (HDC hdc
, LPLOGFONTA lpLogfont
, FONTENUMPROCA lpEnumFontFamExProc
,
391 LPARAM lParam
, DWORD dwFlags
)
393 LOGFONTW LogFontW
, *pLogFontW
;
397 LogFontA2W(&LogFontW
,lpLogfont
);
398 pLogFontW
= &LogFontW
;
400 else pLogFontW
= NULL
;
402 /* no need to convert LogFontW back to lpLogFont b/c it's an [in] parameter only */
403 return IntEnumFontFamilies(hdc
, pLogFontW
, lpEnumFontFamExProc
, lParam
, FALSE
);
411 EnumFontFamiliesA(HDC hdc
, LPCSTR lpszFamily
, FONTENUMPROCA lpEnumFontFamProc
,
416 ZeroMemory(&LogFont
, sizeof(LOGFONTW
));
417 LogFont
.lfCharSet
= DEFAULT_CHARSET
;
418 if (NULL
!= lpszFamily
)
420 MultiByteToWideChar(CP_THREAD_ACP
, 0, lpszFamily
, -1, LogFont
.lfFaceName
, LF_FACESIZE
);
423 return IntEnumFontFamilies(hdc
, &LogFont
, lpEnumFontFamProc
, lParam
, FALSE
);
431 GetCharacterPlacementW(
436 GCP_RESULTSW
*lpResults
,
443 DPRINT("GetCharacterPlacementW\n");
445 if(dwFlags
&(~GCP_REORDER
)) DPRINT("flags 0x%08lx ignored\n", dwFlags
);
446 if(lpResults
->lpClass
) DPRINT("classes not implemented\n");
447 if (lpResults
->lpCaretPos
&& (dwFlags
& GCP_REORDER
))
448 DPRINT("Caret positions for complex scripts not implemented\n");
451 if(nSet
> lpResults
->nGlyphs
)
452 nSet
= lpResults
->nGlyphs
;
454 /* return number of initialized fields */
455 lpResults
->nGlyphs
= nSet
;
457 /*if((dwFlags&GCP_REORDER)==0 || !BidiAvail)
459 /* Treat the case where no special handling was requested in a fastpath way */
460 /* copy will do if the GCP_REORDER flag is not set */
461 if(lpResults
->lpOutString
)
462 lstrcpynW( lpResults
->lpOutString
, lpString
, nSet
);
464 if(lpResults
->lpGlyphs
)
465 lstrcpynW( lpResults
->lpGlyphs
, lpString
, nSet
);
467 if(lpResults
->lpOrder
)
469 for(i
= 0; i
< nSet
; i
++)
470 lpResults
->lpOrder
[i
] = i
;
474 BIDI_Reorder( lpString, uCount, dwFlags, WINE_GCPW_FORCE_LTR, lpResults->lpOutString,
475 nSet, lpResults->lpOrder );
478 /* FIXME: Will use the placement chars */
482 for (i
= 0; i
< nSet
; i
++)
484 if (GetCharWidth32W(hdc
, lpString
[i
], lpString
[i
], &c
))
485 lpResults
->lpDx
[i
]= c
;
489 if (lpResults
->lpCaretPos
&& !(dwFlags
& GCP_REORDER
))
493 lpResults
->lpCaretPos
[0] = 0;
494 for (i
= 1; i
< nSet
; i
++)
495 if (GetTextExtentPoint32W(hdc
, &(lpString
[i
- 1]), 1, &size
))
496 lpResults
->lpCaretPos
[i
] = (pos
+= size
.cx
);
499 /*if(lpResults->lpGlyphs)
500 NtGdiGetGlyphIndicesW(hdc, lpString, nSet, lpResults->lpGlyphs, 0);*/
502 if (GetTextExtentPoint32W(hdc
, lpString
, uCount
, &size
))
503 ret
= MAKELONG(size
.cx
, size
.cy
);
514 GetCharABCWidthsFloatW(HDC hdc
,
519 DPRINT("GetCharABCWidthsFloatW\n");
520 if ((!abcF
) || (FirstChar
> LastChar
))
522 SetLastError(ERROR_INVALID_PARAMETER
);
525 return NtGdiGetCharABCWidthsW( hdc
,
527 (ULONG
)(LastChar
- FirstChar
+ 1),
539 GetCharWidthFloatW(HDC hdc
,
544 DPRINT("GetCharWidthsFloatW\n");
545 if ((!pxBuffer
) || (iFirstChar
> iLastChar
))
547 SetLastError(ERROR_INVALID_PARAMETER
);
550 return NtGdiGetCharWidthW( hdc
,
552 (ULONG
)(iLastChar
- iFirstChar
+ 1),
564 GetCharWidthW(HDC hdc
,
569 DPRINT("GetCharWidthsW\n");
570 if ((!lpBuffer
) || (iFirstChar
> iLastChar
))
572 SetLastError(ERROR_INVALID_PARAMETER
);
575 return NtGdiGetCharWidthW( hdc
,
577 (ULONG
)(iLastChar
- iFirstChar
+ 1),
589 GetCharWidth32W(HDC hdc
,
594 DPRINT("GetCharWidths32W\n");
595 if ((!lpBuffer
) || (iFirstChar
> iLastChar
))
597 SetLastError(ERROR_INVALID_PARAMETER
);
600 return NtGdiGetCharWidthW( hdc
,
602 (ULONG
)(iLastChar
- iFirstChar
+ 1),
604 GCW_NOFLOAT
|GCW_WIN32
,
615 GetCharABCWidthsW(HDC hdc
,
620 DPRINT("GetCharABCWidthsW\n");
621 if ((!lpabc
) || (FirstChar
> LastChar
))
623 SetLastError(ERROR_INVALID_PARAMETER
);
626 return NtGdiGetCharABCWidthsW( hdc
,
628 (ULONG
)(LastChar
- FirstChar
+ 1),
646 INT i
, wlen
, count
= (INT
)(iLastChar
- iFirstChar
+ 1);
651 DPRINT("GetCharWidthsA\n");
652 if(count
<= 0) return FALSE
;
654 str
= HeapAlloc(GetProcessHeap(), 0, count
+1);
658 for(i
= 0; i
< count
; i
++)
659 str
[i
] = (BYTE
)(iFirstChar
+ i
);
662 wstr
= FONT_mbtowc(hdc
, str
, count
+1, &wlen
, NULL
);
665 HeapFree(GetProcessHeap(), 0, str
);
669 ret
= NtGdiGetCharWidthW( hdc
,
676 HeapFree(GetProcessHeap(), 0, str
);
677 HeapFree(GetProcessHeap(), 0, wstr
);
694 INT i
, wlen
, count
= (INT
)(iLastChar
- iFirstChar
+ 1);
699 DPRINT("GetCharWidths32A\n");
700 if(count
<= 0) return FALSE
;
702 str
= HeapAlloc(GetProcessHeap(), 0, count
+1);
705 for(i
= 0; i
< count
; i
++)
706 str
[i
] = (BYTE
)(iFirstChar
+ i
);
709 wstr
= FONT_mbtowc(hdc
, str
, count
+1, &wlen
, NULL
);
712 HeapFree(GetProcessHeap(), 0, str
);
716 ret
= NtGdiGetCharWidthW( hdc
,
720 GCW_NOFLOAT
|GCW_WIN32
,
723 HeapFree(GetProcessHeap(), 0, str
);
724 HeapFree(GetProcessHeap(), 0, wstr
);
741 INT i
, wlen
, count
= (INT
)(iLastChar
- iFirstChar
+ 1);
746 DPRINT("GetCharWidthsFloatA\n");
747 if(count
<= 0) return FALSE
;
749 str
= HeapAlloc(GetProcessHeap(), 0, count
+1);
752 for(i
= 0; i
< count
; i
++)
753 str
[i
] = (BYTE
)(iFirstChar
+ i
);
756 wstr
= FONT_mbtowc(hdc
, str
, count
+1, &wlen
, NULL
);
759 HeapFree(GetProcessHeap(), 0, str
);
762 ret
= NtGdiGetCharWidthW( hdc
, wstr
[0], (ULONG
) count
, (PWCHAR
) wstr
, 0, (PVOID
) pxBuffer
);
764 HeapFree(GetProcessHeap(), 0, str
);
765 HeapFree(GetProcessHeap(), 0, wstr
);
782 INT i
, wlen
, count
= (INT
)(uLastChar
- uFirstChar
+ 1);
787 DPRINT("GetCharABCWidthsA\n");
788 if(count
<= 0) return FALSE
;
790 str
= HeapAlloc(GetProcessHeap(), 0, count
+1);
793 for(i
= 0; i
< count
; i
++)
794 str
[i
] = (BYTE
)(uFirstChar
+ i
);
797 wstr
= FONT_mbtowc(hdc
, str
, count
+1, &wlen
, NULL
);
800 HeapFree(GetProcessHeap(), 0, str
);
804 ret
= NtGdiGetCharABCWidthsW( hdc
,
811 HeapFree(GetProcessHeap(), 0, str
);
812 HeapFree(GetProcessHeap(), 0, wstr
);
822 GetCharABCWidthsFloatA(
829 INT i
, wlen
, count
= (INT
)(iLastChar
- iFirstChar
+ 1);
834 DPRINT("GetCharABCWidthsFloatA\n");
835 if (count
<= 0) return FALSE
;
837 str
= HeapAlloc(GetProcessHeap(), 0, count
+1);
841 for(i
= 0; i
< count
; i
++)
842 str
[i
] = (BYTE
)(iFirstChar
+ i
);
845 wstr
= FONT_mbtowc( hdc
, str
, count
+1, &wlen
, NULL
);
848 HeapFree( GetProcessHeap(), 0, str
);
851 ret
= NtGdiGetCharABCWidthsW( hdc
,wstr
[0],(ULONG
)count
, (PWCHAR
)wstr
, 0, (PVOID
)lpABCF
);
853 HeapFree( GetProcessHeap(), 0, str
);
854 HeapFree( GetProcessHeap(), 0, wstr
);
864 GetCharABCWidthsI(HDC hdc
,
870 DPRINT("GetCharABCWidthsI\n");
871 return NtGdiGetCharABCWidthsW( hdc
,
875 GCABCW_NOFLOAT
|GCABCW_INDICES
,
884 GetCharWidthI(HDC hdc
,
891 DPRINT("GetCharWidthsI\n");
892 if (!lpBuffer
|| (!pgi
&& (giFirst
== MAXUSHORT
))) // Cannot be at max.
894 SetLastError(ERROR_INVALID_PARAMETER
);
897 if (!cgi
) return TRUE
;
898 return NtGdiGetCharWidthW( hdc
,
902 GCW_INDICES
|GCW_NOFLOAT
|GCW_WIN32
,
915 return GetDCDWord(hDc
, GdiGetFontLanguageInfo
, GCP_ERROR
);
935 lpstrW
= FONT_mbtowc(hdc
, lpstr
, count
, &countW
, NULL
);
936 Ret
= NtGdiGetGlyphIndicesW(hdc
, lpstrW
, countW
, pgi
, flags
);
937 HeapFree(GetProcessHeap(), 0, lpstrW
);
960 DPRINT1("GetGlyphOutlineA uChar %x\n", uChar
);
961 if(!(uFormat
& GGO_GLYPH_INDEX
)) {
964 if(uChar
> 0xff) { /* but, 2 bytes character only */
966 mbchs
[0] = (uChar
& 0xff00) >> 8;
967 mbchs
[1] = (uChar
& 0xff);
970 mbchs
[0] = (uChar
& 0xff);
972 p
= FONT_mbtowc(hdc
, mbchs
, len
, NULL
, NULL
);
976 ret
= NtGdiGetGlyphOutline(hdc
, c
, uFormat
, lpgm
, cbBuffer
, lpvBuffer
, (CONST LPMAT2
)lpmat2
, TRUE
);
977 HeapFree(GetProcessHeap(), 0, p
);
997 DPRINT("GetGlyphOutlineW uChar %x\n", uChar
);
998 if (!lpgm
& !lpmat2
) return GDI_ERROR
;
999 if (!lpvBuffer
) cbBuffer
= 0;
1000 return NtGdiGetGlyphOutline ( hdc
, uChar
, uFormat
, lpgm
, cbBuffer
, lpvBuffer
, (CONST LPMAT2
)lpmat2
, TRUE
);
1009 GetOutlineTextMetricsA(
1012 LPOUTLINETEXTMETRICA lpOTM
1015 char buf
[512], *ptr
;
1017 OUTLINETEXTMETRICW
*lpOTMW
= (OUTLINETEXTMETRICW
*)buf
;
1018 OUTLINETEXTMETRICA
*output
= lpOTM
;
1021 if((ret
= GetOutlineTextMetricsW(hdc
, 0, NULL
)) == 0)
1023 if(ret
> sizeof(buf
))
1024 lpOTMW
= HeapAlloc(GetProcessHeap(), 0, ret
);
1025 GetOutlineTextMetricsW(hdc
, ret
, lpOTMW
);
1027 needed
= sizeof(OUTLINETEXTMETRICA
);
1028 if(lpOTMW
->otmpFamilyName
)
1029 needed
+= WideCharToMultiByte(CP_ACP
, 0,
1030 (WCHAR
*)((char*)lpOTMW
+ (int)lpOTMW
->otmpFamilyName
), -1,
1031 NULL
, 0, NULL
, NULL
);
1032 if(lpOTMW
->otmpFaceName
)
1033 needed
+= WideCharToMultiByte(CP_ACP
, 0,
1034 (WCHAR
*)((char*)lpOTMW
+ (int)lpOTMW
->otmpFaceName
), -1,
1035 NULL
, 0, NULL
, NULL
);
1036 if(lpOTMW
->otmpStyleName
)
1037 needed
+= WideCharToMultiByte(CP_ACP
, 0,
1038 (WCHAR
*)((char*)lpOTMW
+ (int)lpOTMW
->otmpStyleName
), -1,
1039 NULL
, 0, NULL
, NULL
);
1040 if(lpOTMW
->otmpFullName
)
1041 needed
+= WideCharToMultiByte(CP_ACP
, 0,
1042 (WCHAR
*)((char*)lpOTMW
+ (int)lpOTMW
->otmpFullName
), -1,
1043 NULL
, 0, NULL
, NULL
);
1050 DPRINT("needed = %d\n", needed
);
1052 /* Since the supplied buffer isn't big enough, we'll alloc one
1053 that is and memcpy the first cbData bytes into the lpOTM at
1055 output
= HeapAlloc(GetProcessHeap(), 0, needed
);
1057 ret
= output
->otmSize
= min(needed
, cbData
);
1058 FONT_TextMetricWToA( &lpOTMW
->otmTextMetrics
, &output
->otmTextMetrics
);
1059 output
->otmFiller
= 0;
1060 output
->otmPanoseNumber
= lpOTMW
->otmPanoseNumber
;
1061 output
->otmfsSelection
= lpOTMW
->otmfsSelection
;
1062 output
->otmfsType
= lpOTMW
->otmfsType
;
1063 output
->otmsCharSlopeRise
= lpOTMW
->otmsCharSlopeRise
;
1064 output
->otmsCharSlopeRun
= lpOTMW
->otmsCharSlopeRun
;
1065 output
->otmItalicAngle
= lpOTMW
->otmItalicAngle
;
1066 output
->otmEMSquare
= lpOTMW
->otmEMSquare
;
1067 output
->otmAscent
= lpOTMW
->otmAscent
;
1068 output
->otmDescent
= lpOTMW
->otmDescent
;
1069 output
->otmLineGap
= lpOTMW
->otmLineGap
;
1070 output
->otmsCapEmHeight
= lpOTMW
->otmsCapEmHeight
;
1071 output
->otmsXHeight
= lpOTMW
->otmsXHeight
;
1072 output
->otmrcFontBox
= lpOTMW
->otmrcFontBox
;
1073 output
->otmMacAscent
= lpOTMW
->otmMacAscent
;
1074 output
->otmMacDescent
= lpOTMW
->otmMacDescent
;
1075 output
->otmMacLineGap
= lpOTMW
->otmMacLineGap
;
1076 output
->otmusMinimumPPEM
= lpOTMW
->otmusMinimumPPEM
;
1077 output
->otmptSubscriptSize
= lpOTMW
->otmptSubscriptSize
;
1078 output
->otmptSubscriptOffset
= lpOTMW
->otmptSubscriptOffset
;
1079 output
->otmptSuperscriptSize
= lpOTMW
->otmptSuperscriptSize
;
1080 output
->otmptSuperscriptOffset
= lpOTMW
->otmptSuperscriptOffset
;
1081 output
->otmsStrikeoutSize
= lpOTMW
->otmsStrikeoutSize
;
1082 output
->otmsStrikeoutPosition
= lpOTMW
->otmsStrikeoutPosition
;
1083 output
->otmsUnderscoreSize
= lpOTMW
->otmsUnderscoreSize
;
1084 output
->otmsUnderscorePosition
= lpOTMW
->otmsUnderscorePosition
;
1087 ptr
= (char*)(output
+ 1);
1088 left
= needed
- sizeof(*output
);
1090 if(lpOTMW
->otmpFamilyName
) {
1091 output
->otmpFamilyName
= (LPSTR
)(ptr
- (char*)output
);
1092 len
= WideCharToMultiByte(CP_ACP
, 0,
1093 (WCHAR
*)((char*)lpOTMW
+ (int)lpOTMW
->otmpFamilyName
), -1,
1094 ptr
, left
, NULL
, NULL
);
1098 output
->otmpFamilyName
= 0;
1100 if(lpOTMW
->otmpFaceName
) {
1101 output
->otmpFaceName
= (LPSTR
)(ptr
- (char*)output
);
1102 len
= WideCharToMultiByte(CP_ACP
, 0,
1103 (WCHAR
*)((char*)lpOTMW
+ (int)lpOTMW
->otmpFaceName
), -1,
1104 ptr
, left
, NULL
, NULL
);
1108 output
->otmpFaceName
= 0;
1110 if(lpOTMW
->otmpStyleName
) {
1111 output
->otmpStyleName
= (LPSTR
)(ptr
- (char*)output
);
1112 len
= WideCharToMultiByte(CP_ACP
, 0,
1113 (WCHAR
*)((char*)lpOTMW
+ (int)lpOTMW
->otmpStyleName
), -1,
1114 ptr
, left
, NULL
, NULL
);
1118 output
->otmpStyleName
= 0;
1120 if(lpOTMW
->otmpFullName
) {
1121 output
->otmpFullName
= (LPSTR
)(ptr
- (char*)output
);
1122 len
= WideCharToMultiByte(CP_ACP
, 0,
1123 (WCHAR
*)((char*)lpOTMW
+ (int)lpOTMW
->otmpFullName
), -1,
1124 ptr
, left
, NULL
, NULL
);
1127 output
->otmpFullName
= 0;
1131 if(output
!= lpOTM
) {
1132 memcpy(lpOTM
, output
, cbData
);
1133 HeapFree(GetProcessHeap(), 0, output
);
1135 /* check if the string offsets really fit into the provided size */
1136 /* FIXME: should we check string length as well? */
1137 if ((UINT_PTR
)lpOTM
->otmpFamilyName
>= lpOTM
->otmSize
)
1138 lpOTM
->otmpFamilyName
= 0; /* doesn't fit */
1140 if ((UINT_PTR
)lpOTM
->otmpFaceName
>= lpOTM
->otmSize
)
1141 lpOTM
->otmpFaceName
= 0; /* doesn't fit */
1143 if ((UINT_PTR
)lpOTM
->otmpStyleName
>= lpOTM
->otmSize
)
1144 lpOTM
->otmpStyleName
= 0; /* doesn't fit */
1146 if ((UINT_PTR
)lpOTM
->otmpFullName
>= lpOTM
->otmSize
)
1147 lpOTM
->otmpFullName
= 0; /* doesn't fit */
1151 if(lpOTMW
!= (OUTLINETEXTMETRICW
*)buf
)
1152 HeapFree(GetProcessHeap(), 0, lpOTMW
);
1163 GetOutlineTextMetricsW(
1166 LPOUTLINETEXTMETRICW lpOTM
1169 TMDIFF Tmd
; // Should not be zero.
1171 return NtGdiGetOutlineTextMetricsInternalW(hdc
, cbData
, lpOTM
, &Tmd
);
1179 GetKerningPairsW(HDC hdc
,
1181 LPKERNINGPAIR pkpDst
)
1183 if ((cPairs
!= 0) || (pkpDst
== 0))
1185 return NtGdiGetKerningPairs(hdc
,cPairs
,pkpDst
);
1189 SetLastError(ERROR_INVALID_PARAMETER
);
1199 GetKerningPairsA( HDC hDC
,
1201 LPKERNINGPAIR kern_pairA
)
1206 DWORD i
, total_kern_pairs
, kern_pairs_copied
= 0;
1207 KERNINGPAIR
*kern_pairW
;
1209 if (!cPairs
&& kern_pairA
)
1211 SetLastError(ERROR_INVALID_PARAMETER
);
1215 charset
= GetTextCharset(hDC
);
1216 if (!TranslateCharsetInfo(ULongToPtr(charset
), &csi
, TCI_SRCCHARSET
))
1218 DPRINT1("Can't find codepage for charset %d\n", charset
);
1221 /* GetCPInfo() will fail on CP_SYMBOL, and WideCharToMultiByte is supposed
1222 * to fail on an invalid character for CP_SYMBOL.
1224 cpi
.DefaultChar
[0] = 0;
1225 if (csi
.ciACP
!= CP_SYMBOL
&& !GetCPInfo(csi
.ciACP
, &cpi
))
1227 DPRINT1("Can't find codepage %u info\n", csi
.ciACP
);
1230 DPRINT("charset %d => codepage %u\n", charset
, csi
.ciACP
);
1232 total_kern_pairs
= NtGdiGetKerningPairs(hDC
, 0, NULL
);
1233 if (!total_kern_pairs
) return 0;
1235 if (!cPairs
&& !kern_pairA
) return total_kern_pairs
;
1237 kern_pairW
= HeapAlloc(GetProcessHeap(), 0, total_kern_pairs
* sizeof(*kern_pairW
));
1238 GetKerningPairsW(hDC
, total_kern_pairs
, kern_pairW
);
1240 for (i
= 0; i
< total_kern_pairs
; i
++)
1244 if (!WideCharToMultiByte(csi
.ciACP
, 0, &kern_pairW
[i
].wFirst
, 1, &first
, 1, NULL
, NULL
))
1247 if (!WideCharToMultiByte(csi
.ciACP
, 0, &kern_pairW
[i
].wSecond
, 1, &second
, 1, NULL
, NULL
))
1250 if (first
== cpi
.DefaultChar
[0] || second
== cpi
.DefaultChar
[0])
1255 if (kern_pairs_copied
>= cPairs
) break;
1257 kern_pairA
->wFirst
= (BYTE
)first
;
1258 kern_pairA
->wSecond
= (BYTE
)second
;
1259 kern_pairA
->iKernAmount
= kern_pairW
[i
].iKernAmount
;
1262 kern_pairs_copied
++;
1265 HeapFree(GetProcessHeap(), 0, kern_pairW
);
1267 return kern_pairs_copied
;
1277 CreateFontIndirectExA(const ENUMLOGFONTEXDVA
*elfexd
)
1281 ENUMLOGFONTEXDVW Logfont
;
1283 EnumLogFontExW2A( (LPENUMLOGFONTEXA
) elfexd
,
1284 &Logfont
.elfEnumLogfontEx
);
1286 RtlCopyMemory( &Logfont
.elfDesignVector
,
1287 (PVOID
) &elfexd
->elfDesignVector
,
1288 sizeof(DESIGNVECTOR
));
1290 return NtGdiHfontCreate( &Logfont
, 0, 0, 0, NULL
);
1301 CreateFontIndirectExW(const ENUMLOGFONTEXDVW
*elfexd
)
1303 /* Msdn: Note, this function ignores the elfDesignVector member in
1308 return NtGdiHfontCreate((PENUMLOGFONTEXDVW
) elfexd
, 0, 0, 0, NULL
);
1319 CreateFontIndirectA(
1320 CONST LOGFONTA
*lplf
1327 LogFontA2W(&tlf
, lplf
);
1328 return CreateFontIndirectW(&tlf
);
1339 CreateFontIndirectW(
1340 CONST LOGFONTW
*lplf
1345 ENUMLOGFONTEXDVW Logfont
;
1347 RtlCopyMemory( &Logfont
.elfEnumLogfontEx
.elfLogFont
, lplf
, sizeof(LOGFONTW
));
1348 // Need something other than just cleaning memory here.
1349 // Guess? Use caller data to determine the rest.
1350 RtlZeroMemory( &Logfont
.elfEnumLogfontEx
.elfFullName
,
1351 sizeof(Logfont
.elfEnumLogfontEx
.elfFullName
));
1352 RtlZeroMemory( &Logfont
.elfEnumLogfontEx
.elfStyle
,
1353 sizeof(Logfont
.elfEnumLogfontEx
.elfStyle
));
1354 RtlZeroMemory( &Logfont
.elfEnumLogfontEx
.elfScript
,
1355 sizeof(Logfont
.elfEnumLogfontEx
.elfScript
));
1357 Logfont
.elfDesignVector
.dvNumAxes
= 0; // No more than MM_MAX_NUMAXES
1359 RtlZeroMemory( &Logfont
.elfDesignVector
, sizeof(DESIGNVECTOR
));
1361 return CreateFontIndirectExW(&Logfont
);
1382 DWORD fdwOutputPrecision
,
1383 DWORD fdwClipPrecision
,
1385 DWORD fdwPitchAndFamily
,
1389 ANSI_STRING StringA
;
1390 UNICODE_STRING StringU
;
1393 RtlInitAnsiString(&StringA
, (LPSTR
)lpszFace
);
1394 RtlAnsiStringToUnicodeString(&StringU
, &StringA
, TRUE
);
1396 ret
= CreateFontW(nHeight
,
1411 RtlFreeUnicodeString(&StringU
);
1432 DWORD fdwOutputPrecision
,
1433 DWORD fdwClipPrecision
,
1435 DWORD fdwPitchAndFamily
,
1441 logfont
.lfHeight
= nHeight
;
1442 logfont
.lfWidth
= nWidth
;
1443 logfont
.lfEscapement
= nEscapement
;
1444 logfont
.lfOrientation
= nOrientation
;
1445 logfont
.lfWeight
= nWeight
;
1446 logfont
.lfItalic
= fnItalic
;
1447 logfont
.lfUnderline
= fdwUnderline
;
1448 logfont
.lfStrikeOut
= fdwStrikeOut
;
1449 logfont
.lfCharSet
= fdwCharSet
;
1450 logfont
.lfOutPrecision
= fdwOutputPrecision
;
1451 logfont
.lfClipPrecision
= fdwClipPrecision
;
1452 logfont
.lfQuality
= fdwQuality
;
1453 logfont
.lfPitchAndFamily
= fdwPitchAndFamily
;
1455 if (NULL
!= lpszFace
)
1457 int Size
= sizeof(logfont
.lfFaceName
) / sizeof(WCHAR
);
1458 wcsncpy((wchar_t *)logfont
.lfFaceName
, lpszFace
, Size
- 1);
1459 /* Be 101% sure to have '\0' at end of string */
1460 logfont
.lfFaceName
[Size
- 1] = '\0';
1464 logfont
.lfFaceName
[0] = L
'\0';
1467 return CreateFontIndirectW(&logfont
);
1476 CreateScalableFontResourceA(
1479 LPCSTR lpszFontFile
,
1480 LPCSTR lpszCurrentPath
1492 AddFontResourceExW ( LPCWSTR lpszFilename
, DWORD fl
, PVOID pvReserved
)
1494 if (fl
& ~(FR_PRIVATE
| FR_NOT_ENUM
))
1496 SetLastError( ERROR_INVALID_PARAMETER
);
1500 return GdiAddFontResourceW(lpszFilename
, fl
,0);
1509 AddFontResourceExA ( LPCSTR lpszFilename
, DWORD fl
, PVOID pvReserved
)
1515 if (fl
& ~(FR_PRIVATE
| FR_NOT_ENUM
))
1517 SetLastError( ERROR_INVALID_PARAMETER
);
1521 Status
= HEAP_strdupA2W ( &FilenameW
, lpszFilename
);
1522 if ( !NT_SUCCESS (Status
) )
1524 SetLastError (RtlNtStatusToDosError(Status
));
1528 rc
= GdiAddFontResourceW ( FilenameW
, fl
, 0 );
1529 HEAP_free ( FilenameW
);
1539 AddFontResourceA ( LPCSTR lpszFilename
)
1545 Status
= HEAP_strdupA2W ( &FilenameW
, lpszFilename
);
1546 if ( !NT_SUCCESS (Status
) )
1548 SetLastError (RtlNtStatusToDosError(Status
));
1552 rc
= GdiAddFontResourceW ( FilenameW
, 0, 0);
1554 HEAP_free ( FilenameW
);
1565 AddFontResourceW ( LPCWSTR lpszFilename
)
1567 return GdiAddFontResourceW ( lpszFilename
, 0, 0 );
1576 RemoveFontResourceW(LPCWSTR lpFileName
)
1578 return RemoveFontResourceExW(lpFileName
,0,0);
1587 RemoveFontResourceA(LPCSTR lpFileName
)
1589 return RemoveFontResourceExA(lpFileName
,0,0);
1597 RemoveFontResourceExA(LPCSTR lpFileName
,
1605 /* FIXME the flags */
1607 /* FIXME NtGdiRemoveFontResource handle flags and pdv */
1609 Status
= HEAP_strdupA2W ( &lpFileNameW
, lpFileName
);
1610 if (!NT_SUCCESS (Status
))
1611 SetLastError (RtlNtStatusToDosError(Status
));
1615 HEAP_free ( lpFileNameW
);
1626 RemoveFontResourceExW(LPCWSTR lpFileName
,
1630 /* FIXME the flags */
1632 /* FIXME NtGdiRemoveFontResource handle flags and pdv */
1637 /***********************************************************************
1638 * GdiGetCharDimensions
1640 * Gets the average width of the characters in the English alphabet.
1643 * hdc [I] Handle to the device context to measure on.
1644 * lptm [O] Pointer to memory to store the text metrics into.
1645 * height [O] On exit, the maximum height of characters in the English alphabet.
1648 * The average width of characters in the English alphabet.
1651 * This function is used by the dialog manager to get the size of a dialog
1652 * unit. It should also be used by other pieces of code that need to know
1653 * the size of a dialog unit in logical units without having access to the
1654 * window handle of the dialog.
1655 * Windows caches the font metrics from this function, but we don't and
1656 * there doesn't appear to be an immediate advantage to do so.
1659 * GetTextExtentPointW, GetTextMetricsW, MapDialogRect.
1661 * Despite most of MSDN insisting that the horizontal base unit is
1662 * tmAveCharWidth it isn't. Knowledge base article Q145994
1663 * "HOWTO: Calculate Dialog Units When Not Using the System Font",
1664 * says that we should take the average of the 52 English upper and lower
1672 GdiGetCharDimensions(HDC hdc
, LPTEXTMETRICW lptm
, LONG
*height
)
1676 static const WCHAR alphabet
[] = {
1677 'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q',
1678 'r','s','t','u','v','w','x','y','z','A','B','C','D','E','F','G','H',
1679 'I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z',0};
1681 if(!GetTextMetricsW(hdc
, &tm
)) return 0;
1683 if(!GetTextExtentPointW(hdc
, alphabet
, 52, &sz
)) return 0;
1685 if (lptm
) *lptm
= tm
;
1686 if (height
) *height
= tm
.tmHeight
;
1688 return (sz
.cx
/ 26 + 1) / 2;
1691 /*************************************************************************
1692 * TranslateCharsetInfo [GDI32.@]
1694 * Fills a CHARSETINFO structure for a character set, code page, or
1695 * font. This allows making the correspondance between different labelings
1696 * (character set, Windows, ANSI, and OEM codepages, and Unicode ranges)
1697 * of the same encoding.
1699 * Only one codepage will be set in lpCs->fs. If TCI_SRCFONTSIG is used,
1700 * only one codepage should be set in *lpSrc.
1703 * TRUE on success, FALSE on failure.
1711 TranslateCharsetInfo(
1712 LPDWORD lpSrc
, /* [in]
1713 if flags == TCI_SRCFONTSIG: pointer to fsCsb of a FONTSIGNATURE
1714 if flags == TCI_SRCCHARSET: a character set value
1715 if flags == TCI_SRCCODEPAGE: a code page value
1717 LPCHARSETINFO lpCs
, /* [out] structure to receive charset information */
1718 DWORD flags
/* [in] determines interpretation of lpSrc */)
1722 case TCI_SRCFONTSIG
:
1723 while (!(*lpSrc
>>index
& 0x0001) && index
<MAXTCIINDEX
) index
++;
1725 case TCI_SRCCODEPAGE
:
1726 while (PtrToUlong(lpSrc
) != FONT_tci
[index
].ciACP
&& index
< MAXTCIINDEX
) index
++;
1728 case TCI_SRCCHARSET
:
1729 while (PtrToUlong(lpSrc
) != FONT_tci
[index
].ciCharset
&& index
< MAXTCIINDEX
) index
++;
1734 if (index
>= MAXTCIINDEX
|| FONT_tci
[index
].ciCharset
== DEFAULT_CHARSET
) return FALSE
;
1735 memcpy(lpCs
, &FONT_tci
[index
], sizeof(CHARSETINFO
));
1750 DWORD Ret
= GDI_ERROR
;
1753 if (GDI_HANDLE_GET_TYPE(hDC
) != GDI_OBJECT_TYPE_DC
)
1755 if (GDI_HANDLE_GET_TYPE(hDC
) == GDI_OBJECT_TYPE_METADC
)
1756 return MFDRV_SetMapperFlags( hDC
, flags
);
1759 PLDC pLDC
= Dc_Attr
->pvLDC
;
1762 SetLastError(ERROR_INVALID_HANDLE
);
1765 if (pLDC
->iType
== LDC_EMFLDC
)
1767 return EMFDRV_SetMapperFlags( hDC
, flags
);
1772 if (!GdiGetHandleUserData((HGDIOBJ
) hDC
, GDI_OBJECT_TYPE_DC
, (PVOID
) &Dc_Attr
)) return GDI_ERROR
;
1774 if (NtCurrentTeb()->GdiTebBatch
.HDC
== hDC
)
1776 if (Dc_Attr
->ulDirty_
& DC_FONTTEXT_DIRTY
)
1779 Dc_Attr
->ulDirty_
&= ~(DC_MODE_DIRTY
|DC_FONTTEXT_DIRTY
);
1784 SetLastError(ERROR_INVALID_PARAMETER
);
1787 Ret
= Dc_Attr
->flFontMapper
;
1788 Dc_Attr
->flFontMapper
= flags
;
1802 FONTENUMPROCW FontFunc
,
1807 return NtGdiEnumFonts ( hDC
, lpFaceName
, FontFunc
, lParam
);
1809 return EnumFontFamiliesW( hDC
, lpFaceName
, FontFunc
, lParam
);
1821 FONTENUMPROCA FontFunc
,
1830 Status
= HEAP_strdupA2W ( &lpFaceNameW
, lpFaceName
);
1831 if (!NT_SUCCESS (Status
))
1832 SetLastError (RtlNtStatusToDosError(Status
));
1835 rc
= NtGdiEnumFonts ( hDC
, lpFaceNameW
, FontFunc
, lParam
);
1837 HEAP_free ( lpFaceNameW
);
1841 return EnumFontFamiliesA( hDC
, lpFaceName
, FontFunc
, lParam
);
1845 #define EfdFontFamilies 3
1849 NewEnumFontFamiliesExW(
1851 LPLOGFONTW lpLogfont
,
1852 FONTENUMPROCW lpEnumFontFamExProcW
,
1856 ULONG_PTR idEnum
, cbDataSize
, cbRetSize
;
1857 PENUMFONTDATAW pEfdw
;
1862 /* Open enumeration handle and find out how much memory we need */
1863 idEnum
= NtGdiEnumFontOpen(hDC
,
1867 (lpLogfont
&& lpLogfont
->lfFaceName
[0])? lpLogfont
->lfFaceName
: NULL
,
1868 lpLogfont
? lpLogfont
->lfCharSet
: DEFAULT_CHARSET
,
1874 if (cbDataSize
== 0)
1876 NtGdiEnumFontClose(idEnum
);
1880 /* Allocate memory */
1881 pBuffer
= HeapAlloc(GetProcessHeap(), 0, cbDataSize
);
1882 if (pBuffer
== NULL
)
1884 SetLastError(ERROR_NOT_ENOUGH_MEMORY
);
1885 NtGdiEnumFontClose(idEnum
);
1889 /* Do the enumeration */
1890 if (!NtGdiEnumFontChunk(hDC
, idEnum
, cbDataSize
, &cbRetSize
, (PVOID
)pBuffer
))
1892 HeapFree(GetProcessHeap(), 0, pBuffer
);
1893 NtGdiEnumFontClose(idEnum
);
1897 /* Get start and end address */
1898 pEfdw
= (PENUMFONTDATAW
)pBuffer
;
1899 pMax
= pBuffer
+ cbDataSize
;
1901 /* Iterate through the structures */
1902 while ((PBYTE
)pEfdw
< pMax
&& ret
)
1904 PNTMW_INTERNAL pNtmwi
= (PNTMW_INTERNAL
)((ULONG_PTR
)pEfdw
+ pEfdw
->ulNtmwiOffset
);
1906 ret
= lpEnumFontFamExProcW(&pEfdw
->elfexdv
.elfEnumLogfontEx
,
1911 pEfdw
= (PENUMFONTDATAW
)((ULONG_PTR
)pEfdw
+ pEfdw
->cbSize
);
1914 /* Release the memory and close handle */
1915 HeapFree(GetProcessHeap(), 0, pBuffer
);
1916 NtGdiEnumFontClose(idEnum
);