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 DPRINT("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 (VOID
*)&Info
[i
].EnumLogFontEx
,
329 (VOID
*)&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
)(
344 (VOID
*)&EnumLogFontExA
,
345 (VOID
*)&NewTextMetricExA
,
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 if (!*lpszFamily
) return 1;
380 lstrcpynW(LogFont
.lfFaceName
, lpszFamily
, LF_FACESIZE
);
383 return IntEnumFontFamilies(hdc
, &LogFont
, lpEnumFontFamProc
, lParam
, TRUE
);
391 EnumFontFamiliesExA (HDC hdc
, LPLOGFONTA lpLogfont
, FONTENUMPROCA lpEnumFontFamExProc
,
392 LPARAM lParam
, DWORD dwFlags
)
394 LOGFONTW LogFontW
, *pLogFontW
;
398 LogFontA2W(&LogFontW
,lpLogfont
);
399 pLogFontW
= &LogFontW
;
401 else pLogFontW
= NULL
;
403 /* no need to convert LogFontW back to lpLogFont b/c it's an [in] parameter only */
404 return IntEnumFontFamilies(hdc
, pLogFontW
, lpEnumFontFamExProc
, lParam
, FALSE
);
412 EnumFontFamiliesA(HDC hdc
, LPCSTR lpszFamily
, FONTENUMPROCA lpEnumFontFamProc
,
417 ZeroMemory(&LogFont
, sizeof(LOGFONTW
));
418 LogFont
.lfCharSet
= DEFAULT_CHARSET
;
419 if (NULL
!= lpszFamily
)
421 if (!*lpszFamily
) return 1;
422 MultiByteToWideChar(CP_THREAD_ACP
, 0, lpszFamily
, -1, LogFont
.lfFaceName
, LF_FACESIZE
);
425 return IntEnumFontFamilies(hdc
, &LogFont
, lpEnumFontFamProc
, lParam
, FALSE
);
433 GetCharacterPlacementW(
438 GCP_RESULTSW
*lpResults
,
445 DPRINT("GetCharacterPlacementW\n");
447 if(dwFlags
&(~GCP_REORDER
)) DPRINT("flags 0x%08lx ignored\n", dwFlags
);
448 if(lpResults
->lpClass
) DPRINT("classes not implemented\n");
449 if (lpResults
->lpCaretPos
&& (dwFlags
& GCP_REORDER
))
450 DPRINT("Caret positions for complex scripts not implemented\n");
453 if(nSet
> lpResults
->nGlyphs
)
454 nSet
= lpResults
->nGlyphs
;
456 /* return number of initialized fields */
457 lpResults
->nGlyphs
= nSet
;
459 /*if((dwFlags&GCP_REORDER)==0 || !BidiAvail)
461 /* Treat the case where no special handling was requested in a fastpath way */
462 /* copy will do if the GCP_REORDER flag is not set */
463 if(lpResults
->lpOutString
)
464 lstrcpynW( lpResults
->lpOutString
, lpString
, nSet
);
466 if(lpResults
->lpGlyphs
)
467 lstrcpynW( lpResults
->lpGlyphs
, lpString
, nSet
);
469 if(lpResults
->lpOrder
)
471 for(i
= 0; i
< nSet
; i
++)
472 lpResults
->lpOrder
[i
] = i
;
476 BIDI_Reorder( lpString, uCount, dwFlags, WINE_GCPW_FORCE_LTR, lpResults->lpOutString,
477 nSet, lpResults->lpOrder );
480 /* FIXME: Will use the placement chars */
484 for (i
= 0; i
< nSet
; i
++)
486 if (GetCharWidth32W(hdc
, lpString
[i
], lpString
[i
], &c
))
487 lpResults
->lpDx
[i
]= c
;
491 if (lpResults
->lpCaretPos
&& !(dwFlags
& GCP_REORDER
))
495 lpResults
->lpCaretPos
[0] = 0;
496 for (i
= 1; i
< nSet
; i
++)
497 if (GetTextExtentPoint32W(hdc
, &(lpString
[i
- 1]), 1, &size
))
498 lpResults
->lpCaretPos
[i
] = (pos
+= size
.cx
);
501 /*if(lpResults->lpGlyphs)
502 NtGdiGetGlyphIndicesW(hdc, lpString, nSet, lpResults->lpGlyphs, 0);*/
504 if (GetTextExtentPoint32W(hdc
, lpString
, uCount
, &size
))
505 ret
= MAKELONG(size
.cx
, size
.cy
);
516 GetCharABCWidthsFloatW(HDC hdc
,
521 DPRINT("GetCharABCWidthsFloatW\n");
522 if ((!abcF
) || (FirstChar
> LastChar
))
524 SetLastError(ERROR_INVALID_PARAMETER
);
527 return NtGdiGetCharABCWidthsW( hdc
,
529 (ULONG
)(LastChar
- FirstChar
+ 1),
541 GetCharWidthFloatW(HDC hdc
,
546 DPRINT("GetCharWidthsFloatW\n");
547 if ((!pxBuffer
) || (iFirstChar
> iLastChar
))
549 SetLastError(ERROR_INVALID_PARAMETER
);
552 return NtGdiGetCharWidthW( hdc
,
554 (ULONG
)(iLastChar
- iFirstChar
+ 1),
566 GetCharWidthW(HDC hdc
,
571 DPRINT("GetCharWidthsW\n");
572 if ((!lpBuffer
) || (iFirstChar
> iLastChar
))
574 SetLastError(ERROR_INVALID_PARAMETER
);
577 return NtGdiGetCharWidthW( hdc
,
579 (ULONG
)(iLastChar
- iFirstChar
+ 1),
591 GetCharWidth32W(HDC hdc
,
596 DPRINT("GetCharWidths32W\n");
597 if ((!lpBuffer
) || (iFirstChar
> iLastChar
))
599 SetLastError(ERROR_INVALID_PARAMETER
);
602 return NtGdiGetCharWidthW( hdc
,
604 (ULONG
)(iLastChar
- iFirstChar
+ 1),
606 GCW_NOFLOAT
|GCW_WIN32
,
617 GetCharABCWidthsW(HDC hdc
,
622 DPRINT("GetCharABCWidthsW\n");
623 if ((!lpabc
) || (FirstChar
> LastChar
))
625 SetLastError(ERROR_INVALID_PARAMETER
);
628 return NtGdiGetCharABCWidthsW( hdc
,
630 (ULONG
)(LastChar
- FirstChar
+ 1),
648 INT i
, wlen
, count
= (INT
)(iLastChar
- iFirstChar
+ 1);
653 DPRINT("GetCharWidthsA\n");
654 if(count
<= 0) return FALSE
;
656 str
= HeapAlloc(GetProcessHeap(), 0, count
+1);
660 for(i
= 0; i
< count
; i
++)
661 str
[i
] = (BYTE
)(iFirstChar
+ i
);
664 wstr
= FONT_mbtowc(hdc
, str
, count
+1, &wlen
, NULL
);
667 HeapFree(GetProcessHeap(), 0, str
);
671 ret
= NtGdiGetCharWidthW( hdc
,
678 HeapFree(GetProcessHeap(), 0, str
);
679 HeapFree(GetProcessHeap(), 0, wstr
);
696 INT i
, wlen
, count
= (INT
)(iLastChar
- iFirstChar
+ 1);
701 DPRINT("GetCharWidths32A\n");
702 if(count
<= 0) return FALSE
;
704 str
= HeapAlloc(GetProcessHeap(), 0, count
+1);
707 for(i
= 0; i
< count
; i
++)
708 str
[i
] = (BYTE
)(iFirstChar
+ i
);
711 wstr
= FONT_mbtowc(hdc
, str
, count
+1, &wlen
, NULL
);
714 HeapFree(GetProcessHeap(), 0, str
);
718 ret
= NtGdiGetCharWidthW( hdc
,
722 GCW_NOFLOAT
|GCW_WIN32
,
725 HeapFree(GetProcessHeap(), 0, str
);
726 HeapFree(GetProcessHeap(), 0, wstr
);
743 INT i
, wlen
, count
= (INT
)(iLastChar
- iFirstChar
+ 1);
748 DPRINT("GetCharWidthsFloatA\n");
749 if(count
<= 0) return FALSE
;
751 str
= HeapAlloc(GetProcessHeap(), 0, count
+1);
754 for(i
= 0; i
< count
; i
++)
755 str
[i
] = (BYTE
)(iFirstChar
+ i
);
758 wstr
= FONT_mbtowc(hdc
, str
, count
+1, &wlen
, NULL
);
761 HeapFree(GetProcessHeap(), 0, str
);
764 ret
= NtGdiGetCharWidthW( hdc
, wstr
[0], (ULONG
) count
, (PWCHAR
) wstr
, 0, (PVOID
) pxBuffer
);
766 HeapFree(GetProcessHeap(), 0, str
);
767 HeapFree(GetProcessHeap(), 0, wstr
);
784 INT i
, wlen
, count
= (INT
)(uLastChar
- uFirstChar
+ 1);
789 DPRINT("GetCharABCWidthsA\n");
790 if(count
<= 0) return FALSE
;
792 str
= HeapAlloc(GetProcessHeap(), 0, count
+1);
795 for(i
= 0; i
< count
; i
++)
796 str
[i
] = (BYTE
)(uFirstChar
+ i
);
799 wstr
= FONT_mbtowc(hdc
, str
, count
+1, &wlen
, NULL
);
802 HeapFree(GetProcessHeap(), 0, str
);
806 ret
= NtGdiGetCharABCWidthsW( hdc
,
813 HeapFree(GetProcessHeap(), 0, str
);
814 HeapFree(GetProcessHeap(), 0, wstr
);
824 GetCharABCWidthsFloatA(
831 INT i
, wlen
, count
= (INT
)(iLastChar
- iFirstChar
+ 1);
836 DPRINT("GetCharABCWidthsFloatA\n");
837 if (count
<= 0) return FALSE
;
839 str
= HeapAlloc(GetProcessHeap(), 0, count
+1);
843 for(i
= 0; i
< count
; i
++)
844 str
[i
] = (BYTE
)(iFirstChar
+ i
);
847 wstr
= FONT_mbtowc( hdc
, str
, count
+1, &wlen
, NULL
);
850 HeapFree( GetProcessHeap(), 0, str
);
853 ret
= NtGdiGetCharABCWidthsW( hdc
,wstr
[0],(ULONG
)count
, (PWCHAR
)wstr
, 0, (PVOID
)lpABCF
);
855 HeapFree( GetProcessHeap(), 0, str
);
856 HeapFree( GetProcessHeap(), 0, wstr
);
866 GetCharABCWidthsI(HDC hdc
,
872 DPRINT("GetCharABCWidthsI\n");
873 return NtGdiGetCharABCWidthsW( hdc
,
877 GCABCW_NOFLOAT
|GCABCW_INDICES
,
886 GetCharWidthI(HDC hdc
,
893 DPRINT("GetCharWidthsI\n");
894 if (!lpBuffer
|| (!pgi
&& (giFirst
== MAXUSHORT
))) // Cannot be at max.
896 SetLastError(ERROR_INVALID_PARAMETER
);
899 if (!cgi
) return TRUE
;
900 return NtGdiGetCharWidthW( hdc
,
904 GCW_INDICES
|GCW_NOFLOAT
|GCW_WIN32
,
917 return GetDCDWord(hDc
, GdiGetFontLanguageInfo
, GCP_ERROR
);
937 lpstrW
= FONT_mbtowc(hdc
, lpstr
, count
, &countW
, NULL
);
938 Ret
= NtGdiGetGlyphIndicesW(hdc
, lpstrW
, countW
, pgi
, flags
);
939 HeapFree(GetProcessHeap(), 0, lpstrW
);
962 DPRINT1("GetGlyphOutlineA uChar %x\n", uChar
);
963 if(!(uFormat
& GGO_GLYPH_INDEX
)) {
966 if(uChar
> 0xff) { /* but, 2 bytes character only */
968 mbchs
[0] = (uChar
& 0xff00) >> 8;
969 mbchs
[1] = (uChar
& 0xff);
972 mbchs
[0] = (uChar
& 0xff);
974 p
= FONT_mbtowc(hdc
, mbchs
, len
, NULL
, NULL
);
978 ret
= NtGdiGetGlyphOutline(hdc
, c
, uFormat
, lpgm
, cbBuffer
, lpvBuffer
, (CONST LPMAT2
)lpmat2
, TRUE
);
979 HeapFree(GetProcessHeap(), 0, p
);
999 DPRINT("GetGlyphOutlineW uChar %x\n", uChar
);
1000 if (!lpgm
& !lpmat2
) return GDI_ERROR
;
1001 if (!lpvBuffer
) cbBuffer
= 0;
1002 return NtGdiGetGlyphOutline ( hdc
, uChar
, uFormat
, lpgm
, cbBuffer
, lpvBuffer
, (CONST LPMAT2
)lpmat2
, TRUE
);
1011 GetOutlineTextMetricsA(
1014 LPOUTLINETEXTMETRICA lpOTM
1017 char buf
[512], *ptr
;
1019 OUTLINETEXTMETRICW
*lpOTMW
= (OUTLINETEXTMETRICW
*)buf
;
1020 OUTLINETEXTMETRICA
*output
= lpOTM
;
1023 if((ret
= GetOutlineTextMetricsW(hdc
, 0, NULL
)) == 0)
1025 if(ret
> sizeof(buf
))
1026 lpOTMW
= HeapAlloc(GetProcessHeap(), 0, ret
);
1027 GetOutlineTextMetricsW(hdc
, ret
, lpOTMW
);
1029 needed
= sizeof(OUTLINETEXTMETRICA
);
1030 if(lpOTMW
->otmpFamilyName
)
1031 needed
+= WideCharToMultiByte(CP_ACP
, 0,
1032 (WCHAR
*)((char*)lpOTMW
+ (int)lpOTMW
->otmpFamilyName
), -1,
1033 NULL
, 0, NULL
, NULL
);
1034 if(lpOTMW
->otmpFaceName
)
1035 needed
+= WideCharToMultiByte(CP_ACP
, 0,
1036 (WCHAR
*)((char*)lpOTMW
+ (int)lpOTMW
->otmpFaceName
), -1,
1037 NULL
, 0, NULL
, NULL
);
1038 if(lpOTMW
->otmpStyleName
)
1039 needed
+= WideCharToMultiByte(CP_ACP
, 0,
1040 (WCHAR
*)((char*)lpOTMW
+ (int)lpOTMW
->otmpStyleName
), -1,
1041 NULL
, 0, NULL
, NULL
);
1042 if(lpOTMW
->otmpFullName
)
1043 needed
+= WideCharToMultiByte(CP_ACP
, 0,
1044 (WCHAR
*)((char*)lpOTMW
+ (int)lpOTMW
->otmpFullName
), -1,
1045 NULL
, 0, NULL
, NULL
);
1052 DPRINT("needed = %d\n", needed
);
1054 /* Since the supplied buffer isn't big enough, we'll alloc one
1055 that is and memcpy the first cbData bytes into the lpOTM at
1057 output
= HeapAlloc(GetProcessHeap(), 0, needed
);
1059 ret
= output
->otmSize
= min(needed
, cbData
);
1060 FONT_TextMetricWToA( &lpOTMW
->otmTextMetrics
, &output
->otmTextMetrics
);
1061 output
->otmFiller
= 0;
1062 output
->otmPanoseNumber
= lpOTMW
->otmPanoseNumber
;
1063 output
->otmfsSelection
= lpOTMW
->otmfsSelection
;
1064 output
->otmfsType
= lpOTMW
->otmfsType
;
1065 output
->otmsCharSlopeRise
= lpOTMW
->otmsCharSlopeRise
;
1066 output
->otmsCharSlopeRun
= lpOTMW
->otmsCharSlopeRun
;
1067 output
->otmItalicAngle
= lpOTMW
->otmItalicAngle
;
1068 output
->otmEMSquare
= lpOTMW
->otmEMSquare
;
1069 output
->otmAscent
= lpOTMW
->otmAscent
;
1070 output
->otmDescent
= lpOTMW
->otmDescent
;
1071 output
->otmLineGap
= lpOTMW
->otmLineGap
;
1072 output
->otmsCapEmHeight
= lpOTMW
->otmsCapEmHeight
;
1073 output
->otmsXHeight
= lpOTMW
->otmsXHeight
;
1074 output
->otmrcFontBox
= lpOTMW
->otmrcFontBox
;
1075 output
->otmMacAscent
= lpOTMW
->otmMacAscent
;
1076 output
->otmMacDescent
= lpOTMW
->otmMacDescent
;
1077 output
->otmMacLineGap
= lpOTMW
->otmMacLineGap
;
1078 output
->otmusMinimumPPEM
= lpOTMW
->otmusMinimumPPEM
;
1079 output
->otmptSubscriptSize
= lpOTMW
->otmptSubscriptSize
;
1080 output
->otmptSubscriptOffset
= lpOTMW
->otmptSubscriptOffset
;
1081 output
->otmptSuperscriptSize
= lpOTMW
->otmptSuperscriptSize
;
1082 output
->otmptSuperscriptOffset
= lpOTMW
->otmptSuperscriptOffset
;
1083 output
->otmsStrikeoutSize
= lpOTMW
->otmsStrikeoutSize
;
1084 output
->otmsStrikeoutPosition
= lpOTMW
->otmsStrikeoutPosition
;
1085 output
->otmsUnderscoreSize
= lpOTMW
->otmsUnderscoreSize
;
1086 output
->otmsUnderscorePosition
= lpOTMW
->otmsUnderscorePosition
;
1089 ptr
= (char*)(output
+ 1);
1090 left
= needed
- sizeof(*output
);
1092 if(lpOTMW
->otmpFamilyName
) {
1093 output
->otmpFamilyName
= (LPSTR
)(ptr
- (char*)output
);
1094 len
= WideCharToMultiByte(CP_ACP
, 0,
1095 (WCHAR
*)((char*)lpOTMW
+ (int)lpOTMW
->otmpFamilyName
), -1,
1096 ptr
, left
, NULL
, NULL
);
1100 output
->otmpFamilyName
= 0;
1102 if(lpOTMW
->otmpFaceName
) {
1103 output
->otmpFaceName
= (LPSTR
)(ptr
- (char*)output
);
1104 len
= WideCharToMultiByte(CP_ACP
, 0,
1105 (WCHAR
*)((char*)lpOTMW
+ (int)lpOTMW
->otmpFaceName
), -1,
1106 ptr
, left
, NULL
, NULL
);
1110 output
->otmpFaceName
= 0;
1112 if(lpOTMW
->otmpStyleName
) {
1113 output
->otmpStyleName
= (LPSTR
)(ptr
- (char*)output
);
1114 len
= WideCharToMultiByte(CP_ACP
, 0,
1115 (WCHAR
*)((char*)lpOTMW
+ (int)lpOTMW
->otmpStyleName
), -1,
1116 ptr
, left
, NULL
, NULL
);
1120 output
->otmpStyleName
= 0;
1122 if(lpOTMW
->otmpFullName
) {
1123 output
->otmpFullName
= (LPSTR
)(ptr
- (char*)output
);
1124 len
= WideCharToMultiByte(CP_ACP
, 0,
1125 (WCHAR
*)((char*)lpOTMW
+ (int)lpOTMW
->otmpFullName
), -1,
1126 ptr
, left
, NULL
, NULL
);
1129 output
->otmpFullName
= 0;
1133 if(output
!= lpOTM
) {
1134 memcpy(lpOTM
, output
, cbData
);
1135 HeapFree(GetProcessHeap(), 0, output
);
1137 /* check if the string offsets really fit into the provided size */
1138 /* FIXME: should we check string length as well? */
1139 if ((UINT_PTR
)lpOTM
->otmpFamilyName
>= lpOTM
->otmSize
)
1140 lpOTM
->otmpFamilyName
= 0; /* doesn't fit */
1142 if ((UINT_PTR
)lpOTM
->otmpFaceName
>= lpOTM
->otmSize
)
1143 lpOTM
->otmpFaceName
= 0; /* doesn't fit */
1145 if ((UINT_PTR
)lpOTM
->otmpStyleName
>= lpOTM
->otmSize
)
1146 lpOTM
->otmpStyleName
= 0; /* doesn't fit */
1148 if ((UINT_PTR
)lpOTM
->otmpFullName
>= lpOTM
->otmSize
)
1149 lpOTM
->otmpFullName
= 0; /* doesn't fit */
1153 if(lpOTMW
!= (OUTLINETEXTMETRICW
*)buf
)
1154 HeapFree(GetProcessHeap(), 0, lpOTMW
);
1165 GetOutlineTextMetricsW(
1168 LPOUTLINETEXTMETRICW lpOTM
1171 TMDIFF Tmd
; // Should not be zero.
1173 return NtGdiGetOutlineTextMetricsInternalW(hdc
, cbData
, lpOTM
, &Tmd
);
1181 GetKerningPairsW(HDC hdc
,
1183 LPKERNINGPAIR pkpDst
)
1185 if ((cPairs
!= 0) || (pkpDst
== 0))
1187 return NtGdiGetKerningPairs(hdc
,cPairs
,pkpDst
);
1191 SetLastError(ERROR_INVALID_PARAMETER
);
1201 GetKerningPairsA( HDC hDC
,
1203 LPKERNINGPAIR kern_pairA
)
1208 DWORD i
, total_kern_pairs
, kern_pairs_copied
= 0;
1209 KERNINGPAIR
*kern_pairW
;
1211 if (!cPairs
&& kern_pairA
)
1213 SetLastError(ERROR_INVALID_PARAMETER
);
1217 charset
= GetTextCharset(hDC
);
1218 if (!TranslateCharsetInfo(ULongToPtr(charset
), &csi
, TCI_SRCCHARSET
))
1220 DPRINT1("Can't find codepage for charset %d\n", charset
);
1223 /* GetCPInfo() will fail on CP_SYMBOL, and WideCharToMultiByte is supposed
1224 * to fail on an invalid character for CP_SYMBOL.
1226 cpi
.DefaultChar
[0] = 0;
1227 if (csi
.ciACP
!= CP_SYMBOL
&& !GetCPInfo(csi
.ciACP
, &cpi
))
1229 DPRINT1("Can't find codepage %u info\n", csi
.ciACP
);
1232 DPRINT("charset %d => codepage %u\n", charset
, csi
.ciACP
);
1234 total_kern_pairs
= NtGdiGetKerningPairs(hDC
, 0, NULL
);
1235 if (!total_kern_pairs
) return 0;
1237 if (!cPairs
&& !kern_pairA
) return total_kern_pairs
;
1239 kern_pairW
= HeapAlloc(GetProcessHeap(), 0, total_kern_pairs
* sizeof(*kern_pairW
));
1240 GetKerningPairsW(hDC
, total_kern_pairs
, kern_pairW
);
1242 for (i
= 0; i
< total_kern_pairs
; i
++)
1246 if (!WideCharToMultiByte(csi
.ciACP
, 0, &kern_pairW
[i
].wFirst
, 1, &first
, 1, NULL
, NULL
))
1249 if (!WideCharToMultiByte(csi
.ciACP
, 0, &kern_pairW
[i
].wSecond
, 1, &second
, 1, NULL
, NULL
))
1252 if (first
== cpi
.DefaultChar
[0] || second
== cpi
.DefaultChar
[0])
1257 if (kern_pairs_copied
>= cPairs
) break;
1259 kern_pairA
->wFirst
= (BYTE
)first
;
1260 kern_pairA
->wSecond
= (BYTE
)second
;
1261 kern_pairA
->iKernAmount
= kern_pairW
[i
].iKernAmount
;
1264 kern_pairs_copied
++;
1267 HeapFree(GetProcessHeap(), 0, kern_pairW
);
1269 return kern_pairs_copied
;
1279 CreateFontIndirectExA(const ENUMLOGFONTEXDVA
*elfexd
)
1283 ENUMLOGFONTEXDVW Logfont
;
1285 EnumLogFontExW2A( (LPENUMLOGFONTEXA
) elfexd
,
1286 &Logfont
.elfEnumLogfontEx
);
1288 RtlCopyMemory( &Logfont
.elfDesignVector
,
1289 (PVOID
) &elfexd
->elfDesignVector
,
1290 sizeof(DESIGNVECTOR
));
1292 return NtGdiHfontCreate( &Logfont
, 0, 0, 0, NULL
);
1303 CreateFontIndirectExW(const ENUMLOGFONTEXDVW
*elfexd
)
1305 /* Msdn: Note, this function ignores the elfDesignVector member in
1310 return NtGdiHfontCreate((PENUMLOGFONTEXDVW
) elfexd
, 0, 0, 0, NULL
);
1321 CreateFontIndirectA(
1322 CONST LOGFONTA
*lplf
1329 LogFontA2W(&tlf
, lplf
);
1330 return CreateFontIndirectW(&tlf
);
1341 CreateFontIndirectW(
1342 CONST LOGFONTW
*lplf
1347 ENUMLOGFONTEXDVW Logfont
;
1349 RtlCopyMemory( &Logfont
.elfEnumLogfontEx
.elfLogFont
, lplf
, sizeof(LOGFONTW
));
1350 // Need something other than just cleaning memory here.
1351 // Guess? Use caller data to determine the rest.
1352 RtlZeroMemory( &Logfont
.elfEnumLogfontEx
.elfFullName
,
1353 sizeof(Logfont
.elfEnumLogfontEx
.elfFullName
));
1354 RtlZeroMemory( &Logfont
.elfEnumLogfontEx
.elfStyle
,
1355 sizeof(Logfont
.elfEnumLogfontEx
.elfStyle
));
1356 RtlZeroMemory( &Logfont
.elfEnumLogfontEx
.elfScript
,
1357 sizeof(Logfont
.elfEnumLogfontEx
.elfScript
));
1359 Logfont
.elfDesignVector
.dvNumAxes
= 0; // No more than MM_MAX_NUMAXES
1361 RtlZeroMemory( &Logfont
.elfDesignVector
, sizeof(DESIGNVECTOR
));
1363 return CreateFontIndirectExW(&Logfont
);
1384 DWORD fdwOutputPrecision
,
1385 DWORD fdwClipPrecision
,
1387 DWORD fdwPitchAndFamily
,
1391 ANSI_STRING StringA
;
1392 UNICODE_STRING StringU
;
1395 RtlInitAnsiString(&StringA
, (LPSTR
)lpszFace
);
1396 RtlAnsiStringToUnicodeString(&StringU
, &StringA
, TRUE
);
1398 ret
= CreateFontW(nHeight
,
1413 RtlFreeUnicodeString(&StringU
);
1434 DWORD fdwOutputPrecision
,
1435 DWORD fdwClipPrecision
,
1437 DWORD fdwPitchAndFamily
,
1443 logfont
.lfHeight
= nHeight
;
1444 logfont
.lfWidth
= nWidth
;
1445 logfont
.lfEscapement
= nEscapement
;
1446 logfont
.lfOrientation
= nOrientation
;
1447 logfont
.lfWeight
= nWeight
;
1448 logfont
.lfItalic
= fnItalic
;
1449 logfont
.lfUnderline
= fdwUnderline
;
1450 logfont
.lfStrikeOut
= fdwStrikeOut
;
1451 logfont
.lfCharSet
= fdwCharSet
;
1452 logfont
.lfOutPrecision
= fdwOutputPrecision
;
1453 logfont
.lfClipPrecision
= fdwClipPrecision
;
1454 logfont
.lfQuality
= fdwQuality
;
1455 logfont
.lfPitchAndFamily
= fdwPitchAndFamily
;
1457 if (NULL
!= lpszFace
)
1459 int Size
= sizeof(logfont
.lfFaceName
) / sizeof(WCHAR
);
1460 wcsncpy((wchar_t *)logfont
.lfFaceName
, lpszFace
, Size
- 1);
1461 /* Be 101% sure to have '\0' at end of string */
1462 logfont
.lfFaceName
[Size
- 1] = '\0';
1466 logfont
.lfFaceName
[0] = L
'\0';
1469 return CreateFontIndirectW(&logfont
);
1478 CreateScalableFontResourceA(
1481 LPCSTR lpszFontFile
,
1482 LPCSTR lpszCurrentPath
1494 AddFontResourceExW ( LPCWSTR lpszFilename
, DWORD fl
, PVOID pvReserved
)
1496 if (fl
& ~(FR_PRIVATE
| FR_NOT_ENUM
))
1498 SetLastError( ERROR_INVALID_PARAMETER
);
1502 return GdiAddFontResourceW(lpszFilename
, fl
,0);
1511 AddFontResourceExA ( LPCSTR lpszFilename
, DWORD fl
, PVOID pvReserved
)
1517 if (fl
& ~(FR_PRIVATE
| FR_NOT_ENUM
))
1519 SetLastError( ERROR_INVALID_PARAMETER
);
1523 Status
= HEAP_strdupA2W ( &FilenameW
, lpszFilename
);
1524 if ( !NT_SUCCESS (Status
) )
1526 SetLastError (RtlNtStatusToDosError(Status
));
1530 rc
= GdiAddFontResourceW ( FilenameW
, fl
, 0 );
1531 HEAP_free ( FilenameW
);
1541 AddFontResourceA ( LPCSTR lpszFilename
)
1547 Status
= HEAP_strdupA2W ( &FilenameW
, lpszFilename
);
1548 if ( !NT_SUCCESS (Status
) )
1550 SetLastError (RtlNtStatusToDosError(Status
));
1554 rc
= GdiAddFontResourceW ( FilenameW
, 0, 0);
1556 HEAP_free ( FilenameW
);
1567 AddFontResourceW ( LPCWSTR lpszFilename
)
1569 return GdiAddFontResourceW ( lpszFilename
, 0, 0 );
1578 RemoveFontResourceW(LPCWSTR lpFileName
)
1580 return RemoveFontResourceExW(lpFileName
,0,0);
1589 RemoveFontResourceA(LPCSTR lpFileName
)
1591 return RemoveFontResourceExA(lpFileName
,0,0);
1599 RemoveFontResourceExA(LPCSTR lpFileName
,
1607 /* FIXME the flags */
1609 /* FIXME NtGdiRemoveFontResource handle flags and pdv */
1611 Status
= HEAP_strdupA2W ( &lpFileNameW
, lpFileName
);
1612 if (!NT_SUCCESS (Status
))
1613 SetLastError (RtlNtStatusToDosError(Status
));
1617 HEAP_free ( lpFileNameW
);
1628 RemoveFontResourceExW(LPCWSTR lpFileName
,
1632 /* FIXME the flags */
1634 /* FIXME NtGdiRemoveFontResource handle flags and pdv */
1639 /***********************************************************************
1640 * GdiGetCharDimensions
1642 * Gets the average width of the characters in the English alphabet.
1645 * hdc [I] Handle to the device context to measure on.
1646 * lptm [O] Pointer to memory to store the text metrics into.
1647 * height [O] On exit, the maximum height of characters in the English alphabet.
1650 * The average width of characters in the English alphabet.
1653 * This function is used by the dialog manager to get the size of a dialog
1654 * unit. It should also be used by other pieces of code that need to know
1655 * the size of a dialog unit in logical units without having access to the
1656 * window handle of the dialog.
1657 * Windows caches the font metrics from this function, but we don't and
1658 * there doesn't appear to be an immediate advantage to do so.
1661 * GetTextExtentPointW, GetTextMetricsW, MapDialogRect.
1663 * Despite most of MSDN insisting that the horizontal base unit is
1664 * tmAveCharWidth it isn't. Knowledge base article Q145994
1665 * "HOWTO: Calculate Dialog Units When Not Using the System Font",
1666 * says that we should take the average of the 52 English upper and lower
1674 GdiGetCharDimensions(HDC hdc
, LPTEXTMETRICW lptm
, LONG
*height
)
1678 static const WCHAR alphabet
[] = {
1679 'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q',
1680 'r','s','t','u','v','w','x','y','z','A','B','C','D','E','F','G','H',
1681 'I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z',0};
1683 if(!GetTextMetricsW(hdc
, &tm
)) return 0;
1685 if(!GetTextExtentPointW(hdc
, alphabet
, 52, &sz
)) return 0;
1687 if (lptm
) *lptm
= tm
;
1688 if (height
) *height
= tm
.tmHeight
;
1690 return (sz
.cx
/ 26 + 1) / 2;
1693 /*************************************************************************
1694 * TranslateCharsetInfo [GDI32.@]
1696 * Fills a CHARSETINFO structure for a character set, code page, or
1697 * font. This allows making the correspondance between different labelings
1698 * (character set, Windows, ANSI, and OEM codepages, and Unicode ranges)
1699 * of the same encoding.
1701 * Only one codepage will be set in lpCs->fs. If TCI_SRCFONTSIG is used,
1702 * only one codepage should be set in *lpSrc.
1705 * TRUE on success, FALSE on failure.
1713 TranslateCharsetInfo(
1714 LPDWORD lpSrc
, /* [in]
1715 if flags == TCI_SRCFONTSIG: pointer to fsCsb of a FONTSIGNATURE
1716 if flags == TCI_SRCCHARSET: a character set value
1717 if flags == TCI_SRCCODEPAGE: a code page value
1719 LPCHARSETINFO lpCs
, /* [out] structure to receive charset information */
1720 DWORD flags
/* [in] determines interpretation of lpSrc */)
1724 case TCI_SRCFONTSIG
:
1725 while (!(*lpSrc
>>index
& 0x0001) && index
<MAXTCIINDEX
) index
++;
1727 case TCI_SRCCODEPAGE
:
1728 while (PtrToUlong(lpSrc
) != FONT_tci
[index
].ciACP
&& index
< MAXTCIINDEX
) index
++;
1730 case TCI_SRCCHARSET
:
1731 while (PtrToUlong(lpSrc
) != FONT_tci
[index
].ciCharset
&& index
< MAXTCIINDEX
) index
++;
1736 if (index
>= MAXTCIINDEX
|| FONT_tci
[index
].ciCharset
== DEFAULT_CHARSET
) return FALSE
;
1737 memcpy(lpCs
, &FONT_tci
[index
], sizeof(CHARSETINFO
));
1752 DWORD Ret
= GDI_ERROR
;
1755 if (GDI_HANDLE_GET_TYPE(hDC
) != GDI_OBJECT_TYPE_DC
)
1757 if (GDI_HANDLE_GET_TYPE(hDC
) == GDI_OBJECT_TYPE_METADC
)
1758 return MFDRV_SetMapperFlags( hDC
, flags
);
1761 PLDC pLDC
= Dc_Attr
->pvLDC
;
1764 SetLastError(ERROR_INVALID_HANDLE
);
1767 if (pLDC
->iType
== LDC_EMFLDC
)
1769 return EMFDRV_SetMapperFlags( hDC
, flags
);
1774 if (!GdiGetHandleUserData((HGDIOBJ
) hDC
, GDI_OBJECT_TYPE_DC
, (PVOID
) &Dc_Attr
)) return GDI_ERROR
;
1776 if (NtCurrentTeb()->GdiTebBatch
.HDC
== hDC
)
1778 if (Dc_Attr
->ulDirty_
& DC_FONTTEXT_DIRTY
)
1781 Dc_Attr
->ulDirty_
&= ~(DC_MODE_DIRTY
|DC_FONTTEXT_DIRTY
);
1786 SetLastError(ERROR_INVALID_PARAMETER
);
1789 Ret
= Dc_Attr
->flFontMapper
;
1790 Dc_Attr
->flFontMapper
= flags
;
1804 FONTENUMPROCW FontFunc
,
1809 return NtGdiEnumFonts ( hDC
, lpFaceName
, FontFunc
, lParam
);
1811 return EnumFontFamiliesW( hDC
, lpFaceName
, FontFunc
, lParam
);
1823 FONTENUMPROCA FontFunc
,
1832 Status
= HEAP_strdupA2W ( &lpFaceNameW
, lpFaceName
);
1833 if (!NT_SUCCESS (Status
))
1834 SetLastError (RtlNtStatusToDosError(Status
));
1837 rc
= NtGdiEnumFonts ( hDC
, lpFaceNameW
, FontFunc
, lParam
);
1839 HEAP_free ( lpFaceNameW
);
1843 return EnumFontFamiliesA( hDC
, lpFaceName
, FontFunc
, lParam
);
1847 #define EfdFontFamilies 3
1851 NewEnumFontFamiliesExW(
1853 LPLOGFONTW lpLogfont
,
1854 FONTENUMPROCW lpEnumFontFamExProcW
,
1858 ULONG_PTR idEnum
, cbDataSize
, cbRetSize
;
1859 PENUMFONTDATAW pEfdw
;
1864 /* Open enumeration handle and find out how much memory we need */
1865 idEnum
= NtGdiEnumFontOpen(hDC
,
1869 (lpLogfont
&& lpLogfont
->lfFaceName
[0])? lpLogfont
->lfFaceName
: NULL
,
1870 lpLogfont
? lpLogfont
->lfCharSet
: DEFAULT_CHARSET
,
1876 if (cbDataSize
== 0)
1878 NtGdiEnumFontClose(idEnum
);
1882 /* Allocate memory */
1883 pBuffer
= HeapAlloc(GetProcessHeap(), 0, cbDataSize
);
1884 if (pBuffer
== NULL
)
1886 SetLastError(ERROR_NOT_ENOUGH_MEMORY
);
1887 NtGdiEnumFontClose(idEnum
);
1891 /* Do the enumeration */
1892 if (!NtGdiEnumFontChunk(hDC
, idEnum
, cbDataSize
, &cbRetSize
, (PVOID
)pBuffer
))
1894 HeapFree(GetProcessHeap(), 0, pBuffer
);
1895 NtGdiEnumFontClose(idEnum
);
1899 /* Get start and end address */
1900 pEfdw
= (PENUMFONTDATAW
)pBuffer
;
1901 pMax
= pBuffer
+ cbDataSize
;
1903 /* Iterate through the structures */
1904 while ((PBYTE
)pEfdw
< pMax
&& ret
)
1906 PNTMW_INTERNAL pNtmwi
= (PNTMW_INTERNAL
)((ULONG_PTR
)pEfdw
+ pEfdw
->ulNtmwiOffset
);
1908 ret
= lpEnumFontFamExProcW((VOID
*)&pEfdw
->elfexdv
.elfEnumLogfontEx
,
1909 (VOID
*)&pNtmwi
->ntmw
,
1913 pEfdw
= (PENUMFONTDATAW
)((ULONG_PTR
)pEfdw
+ pEfdw
->cbSize
);
1916 /* Release the memory and close handle */
1917 HeapFree(GetProcessHeap(), 0, pBuffer
);
1918 NtGdiEnumFontClose(idEnum
);