2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS system libraries
4 * FILE: lib/gdi32/object/font.c
16 * For TranslateCharsetInfo
18 #define MAXTCIINDEX 32
19 static const CHARSETINFO FONT_tci
[MAXTCIINDEX
] = {
21 { ANSI_CHARSET
, 1252, {{0,0,0,0},{FS_LATIN1
,0}} },
22 { EASTEUROPE_CHARSET
, 1250, {{0,0,0,0},{FS_LATIN2
,0}} },
23 { RUSSIAN_CHARSET
, 1251, {{0,0,0,0},{FS_CYRILLIC
,0}} },
24 { GREEK_CHARSET
, 1253, {{0,0,0,0},{FS_GREEK
,0}} },
25 { TURKISH_CHARSET
, 1254, {{0,0,0,0},{FS_TURKISH
,0}} },
26 { HEBREW_CHARSET
, 1255, {{0,0,0,0},{FS_HEBREW
,0}} },
27 { ARABIC_CHARSET
, 1256, {{0,0,0,0},{FS_ARABIC
,0}} },
28 { BALTIC_CHARSET
, 1257, {{0,0,0,0},{FS_BALTIC
,0}} },
29 { VIETNAMESE_CHARSET
, 1258, {{0,0,0,0},{FS_VIETNAMESE
,0}} },
30 /* reserved by ANSI */
31 { DEFAULT_CHARSET
, 0, {{0,0,0,0},{FS_LATIN1
,0}} },
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}} },
39 { THAI_CHARSET
, 874, {{0,0,0,0},{FS_THAI
,0}} },
40 { SHIFTJIS_CHARSET
, 932, {{0,0,0,0},{FS_JISJAPAN
,0}} },
41 { GB2312_CHARSET
, 936, {{0,0,0,0},{FS_CHINESESIMP
,0}} },
42 { HANGEUL_CHARSET
, 949, {{0,0,0,0},{FS_WANSUNG
,0}} },
43 { CHINESEBIG5_CHARSET
, 950, {{0,0,0,0},{FS_CHINESETRAD
,0}} },
44 { JOHAB_CHARSET
, 1361, {{0,0,0,0},{FS_JOHAB
,0}} },
45 /* reserved for alternate ANSI and OEM */
46 { DEFAULT_CHARSET
, 0, {{0,0,0,0},{FS_LATIN1
,0}} },
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 /* reserved for system */
55 { DEFAULT_CHARSET
, 0, {{0,0,0,0},{FS_LATIN1
,0}} },
56 { SYMBOL_CHARSET
, CP_SYMBOL
, {{0,0,0,0},{FS_SYMBOL
,0}} }
59 #define INITIAL_FAMILY_COUNT 64
61 /***********************************************************************
62 * TEXTMETRIC conversion functions.
66 FONT_TextMetricWToA(const TEXTMETRICW
*ptmW
, LPTEXTMETRICA ptmA
)
68 ptmA
->tmHeight
= ptmW
->tmHeight
;
69 ptmA
->tmAscent
= ptmW
->tmAscent
;
70 ptmA
->tmDescent
= ptmW
->tmDescent
;
71 ptmA
->tmInternalLeading
= ptmW
->tmInternalLeading
;
72 ptmA
->tmExternalLeading
= ptmW
->tmExternalLeading
;
73 ptmA
->tmAveCharWidth
= ptmW
->tmAveCharWidth
;
74 ptmA
->tmMaxCharWidth
= ptmW
->tmMaxCharWidth
;
75 ptmA
->tmWeight
= ptmW
->tmWeight
;
76 ptmA
->tmOverhang
= ptmW
->tmOverhang
;
77 ptmA
->tmDigitizedAspectX
= ptmW
->tmDigitizedAspectX
;
78 ptmA
->tmDigitizedAspectY
= ptmW
->tmDigitizedAspectY
;
79 ptmA
->tmFirstChar
= min(ptmW
->tmFirstChar
, 255);
80 if (ptmW
->tmCharSet
== SYMBOL_CHARSET
)
82 ptmA
->tmFirstChar
= 0x1e;
83 ptmA
->tmLastChar
= 0xff; /* win9x behaviour - we need the OS2 table data to calculate correctly */
87 ptmA
->tmFirstChar
= ptmW
->tmDefaultChar
- 1;
88 ptmA
->tmLastChar
= min(ptmW
->tmLastChar
, 0xff);
90 ptmA
->tmDefaultChar
= ptmW
->tmDefaultChar
;
91 ptmA
->tmBreakChar
= ptmW
->tmBreakChar
;
92 ptmA
->tmItalic
= ptmW
->tmItalic
;
93 ptmA
->tmUnderlined
= ptmW
->tmUnderlined
;
94 ptmA
->tmStruckOut
= ptmW
->tmStruckOut
;
95 ptmA
->tmPitchAndFamily
= ptmW
->tmPitchAndFamily
;
96 ptmA
->tmCharSet
= ptmW
->tmCharSet
;
99 /***********************************************************************
102 * Returns a Unicode translation of str using the charset of the
103 * currently selected font in hdc. If count is -1 then str is assumed
104 * to be '\0' terminated, otherwise it contains the number of bytes to
105 * convert. If plenW is non-NULL, on return it will point to the
106 * number of WCHARs that have been written. If pCP is non-NULL, on
107 * return it will point to the codepage used in the conversion. The
108 * caller should free the returned LPWSTR from the process heap
111 static LPWSTR
FONT_mbtowc(HDC hdc
, LPCSTR str
, INT count
, INT
*plenW
, UINT
*pCP
)
113 UINT cp
= GdiGetCodePage( hdc
);
117 if(count
== -1) count
= strlen(str
);
118 lenW
= MultiByteToWideChar(cp
, 0, str
, count
, NULL
, 0);
119 strW
= HeapAlloc(GetProcessHeap(), 0, lenW
*sizeof(WCHAR
));
122 MultiByteToWideChar(cp
, 0, str
, count
, strW
, lenW
);
123 DPRINT("mapped %s -> %S\n", str
, strW
);
124 if(plenW
) *plenW
= lenW
;
130 NewTextMetricW2A(NEWTEXTMETRICA
*tma
, NEWTEXTMETRICW
*tmw
)
132 FONT_TextMetricWToA((TEXTMETRICW
*) tmw
, (TEXTMETRICA
*) tma
);
133 tma
->ntmFlags
= tmw
->ntmFlags
;
134 tma
->ntmSizeEM
= tmw
->ntmSizeEM
;
135 tma
->ntmCellHeight
= tmw
->ntmCellHeight
;
136 tma
->ntmAvgWidth
= tmw
->ntmAvgWidth
;
140 NewTextMetricExW2A(NEWTEXTMETRICEXA
*tma
, NEWTEXTMETRICEXW
*tmw
)
142 NewTextMetricW2A(&tma
->ntmTm
, &tmw
->ntmTm
);
143 tma
->ntmFontSig
= tmw
->ntmFontSig
;
147 IntEnumFontFamilies(HDC Dc
, LPLOGFONTW LogFont
, PVOID EnumProc
, LPARAM lParam
,
152 PFONTFAMILYINFO Info
;
155 ENUMLOGFONTEXA EnumLogFontExA
;
156 NEWTEXTMETRICEXA NewTextMetricExA
;
158 Info
= RtlAllocateHeap(GetProcessHeap(), 0,
159 INITIAL_FAMILY_COUNT
* sizeof(FONTFAMILYINFO
));
164 FontFamilyCount
= NtGdiGetFontFamilyInfo(Dc
, LogFont
, Info
, INITIAL_FAMILY_COUNT
);
165 if (FontFamilyCount
< 0)
167 RtlFreeHeap(GetProcessHeap(), 0, Info
);
170 if (INITIAL_FAMILY_COUNT
< FontFamilyCount
)
172 FontFamilySize
= FontFamilyCount
;
173 RtlFreeHeap(GetProcessHeap(), 0, Info
);
174 Info
= RtlAllocateHeap(GetProcessHeap(), 0,
175 FontFamilyCount
* sizeof(FONTFAMILYINFO
));
180 FontFamilyCount
= NtGdiGetFontFamilyInfo(Dc
, LogFont
, Info
, FontFamilySize
);
181 if (FontFamilyCount
< 0 || FontFamilySize
< FontFamilyCount
)
183 RtlFreeHeap(GetProcessHeap(), 0, Info
);
188 for (i
= 0; i
< FontFamilyCount
; i
++)
192 Ret
= ((FONTENUMPROCW
) EnumProc
)(
193 (VOID
*)&Info
[i
].EnumLogFontEx
,
194 (VOID
*)&Info
[i
].NewTextMetricEx
,
195 Info
[i
].FontType
, lParam
);
198 { // Could use EnumLogFontExW2A here?
199 LogFontW2A(&EnumLogFontExA
.elfLogFont
, &Info
[i
].EnumLogFontEx
.elfLogFont
);
200 WideCharToMultiByte(CP_THREAD_ACP
, 0, Info
[i
].EnumLogFontEx
.elfFullName
, -1,
201 (LPSTR
)EnumLogFontExA
.elfFullName
, LF_FULLFACESIZE
, NULL
, NULL
);
202 WideCharToMultiByte(CP_THREAD_ACP
, 0, Info
[i
].EnumLogFontEx
.elfStyle
, -1,
203 (LPSTR
)EnumLogFontExA
.elfStyle
, LF_FACESIZE
, NULL
, NULL
);
204 WideCharToMultiByte(CP_THREAD_ACP
, 0, Info
[i
].EnumLogFontEx
.elfScript
, -1,
205 (LPSTR
)EnumLogFontExA
.elfScript
, LF_FACESIZE
, NULL
, NULL
);
206 NewTextMetricExW2A(&NewTextMetricExA
,
207 &Info
[i
].NewTextMetricEx
);
208 Ret
= ((FONTENUMPROCA
) EnumProc
)(
209 (VOID
*)&EnumLogFontExA
,
210 (VOID
*)&NewTextMetricExA
,
211 Info
[i
].FontType
, lParam
);
215 RtlFreeHeap(GetProcessHeap(), 0, Info
);
224 EnumFontFamiliesExW(HDC hdc
, LPLOGFONTW lpLogfont
, FONTENUMPROCW lpEnumFontFamExProc
,
225 LPARAM lParam
, DWORD dwFlags
)
227 return IntEnumFontFamilies(hdc
, lpLogfont
, lpEnumFontFamExProc
, lParam
, TRUE
);
235 EnumFontFamiliesW(HDC hdc
, LPCWSTR lpszFamily
, FONTENUMPROCW lpEnumFontFamProc
,
240 ZeroMemory(&LogFont
, sizeof(LOGFONTW
));
241 LogFont
.lfCharSet
= DEFAULT_CHARSET
;
242 if (NULL
!= lpszFamily
)
244 if (!*lpszFamily
) return 1;
245 lstrcpynW(LogFont
.lfFaceName
, lpszFamily
, LF_FACESIZE
);
248 return IntEnumFontFamilies(hdc
, &LogFont
, lpEnumFontFamProc
, lParam
, TRUE
);
256 EnumFontFamiliesExA (HDC hdc
, LPLOGFONTA lpLogfont
, FONTENUMPROCA lpEnumFontFamExProc
,
257 LPARAM lParam
, DWORD dwFlags
)
259 LOGFONTW LogFontW
, *pLogFontW
;
263 LogFontA2W(&LogFontW
,lpLogfont
);
264 pLogFontW
= &LogFontW
;
266 else pLogFontW
= NULL
;
268 /* no need to convert LogFontW back to lpLogFont b/c it's an [in] parameter only */
269 return IntEnumFontFamilies(hdc
, pLogFontW
, lpEnumFontFamExProc
, lParam
, FALSE
);
277 EnumFontFamiliesA(HDC hdc
, LPCSTR lpszFamily
, FONTENUMPROCA lpEnumFontFamProc
,
282 ZeroMemory(&LogFont
, sizeof(LOGFONTW
));
283 LogFont
.lfCharSet
= DEFAULT_CHARSET
;
284 if (NULL
!= lpszFamily
)
286 if (!*lpszFamily
) return 1;
287 MultiByteToWideChar(CP_THREAD_ACP
, 0, lpszFamily
, -1, LogFont
.lfFaceName
, LF_FACESIZE
);
290 return IntEnumFontFamilies(hdc
, &LogFont
, lpEnumFontFamProc
, lParam
, FALSE
);
299 GetCharacterPlacementA(
304 GCP_RESULTSA
*lpResults
,
309 GCP_RESULTSW resultsW
;
313 if ( !lpString
|| uCount
<= 0 || (nMaxExtent
< 0 && nMaxExtent
!= -1 ) )
315 SetLastError(ERROR_INVALID_PARAMETER
);
318 /* TRACE("%s, %d, %d, 0x%08x\n",
319 debugstr_an(lpString, uCount), uCount, nMaxExtent, dwFlags);
321 /* both structs are equal in size */
322 memcpy(&resultsW
, lpResults
, sizeof(resultsW
));
324 lpStringW
= FONT_mbtowc(hdc
, lpString
, uCount
, &uCountW
, &font_cp
);
325 if (lpStringW
== NULL
)
329 if(lpResults
->lpOutString
)
331 resultsW
.lpOutString
= HeapAlloc(GetProcessHeap(), 0, sizeof(WCHAR
)*uCountW
);
332 if (resultsW
.lpOutString
== NULL
)
334 HeapFree(GetProcessHeap(), 0, lpStringW
);
339 ret
= GetCharacterPlacementW(hdc
, lpStringW
, uCountW
, nMaxExtent
, &resultsW
, dwFlags
);
341 lpResults
->nGlyphs
= resultsW
.nGlyphs
;
342 lpResults
->nMaxFit
= resultsW
.nMaxFit
;
344 if(lpResults
->lpOutString
) {
345 WideCharToMultiByte(font_cp
, 0, resultsW
.lpOutString
, uCountW
,
346 lpResults
->lpOutString
, uCount
, NULL
, NULL
);
349 HeapFree(GetProcessHeap(), 0, lpStringW
);
350 HeapFree(GetProcessHeap(), 0, resultsW
.lpOutString
);
361 GetCharacterPlacementW(
366 GCP_RESULTSW
*lpResults
,
373 DPRINT("GetCharacterPlacementW\n");
375 if(dwFlags
&(~GCP_REORDER
)) DPRINT("flags 0x%08lx ignored\n", dwFlags
);
376 if(lpResults
->lpClass
) DPRINT("classes not implemented\n");
377 if (lpResults
->lpCaretPos
&& (dwFlags
& GCP_REORDER
))
378 DPRINT("Caret positions for complex scripts not implemented\n");
381 if(nSet
> lpResults
->nGlyphs
)
382 nSet
= lpResults
->nGlyphs
;
384 /* return number of initialized fields */
385 lpResults
->nGlyphs
= nSet
;
387 /*if((dwFlags&GCP_REORDER)==0 || !BidiAvail)
389 /* Treat the case where no special handling was requested in a fastpath way */
390 /* copy will do if the GCP_REORDER flag is not set */
391 if(lpResults
->lpOutString
)
392 lstrcpynW( lpResults
->lpOutString
, lpString
, nSet
);
394 if(lpResults
->lpGlyphs
)
395 lstrcpynW( lpResults
->lpGlyphs
, lpString
, nSet
);
397 if(lpResults
->lpOrder
)
399 for(i
= 0; i
< nSet
; i
++)
400 lpResults
->lpOrder
[i
] = i
;
404 BIDI_Reorder( lpString, uCount, dwFlags, WINE_GCPW_FORCE_LTR, lpResults->lpOutString,
405 nSet, lpResults->lpOrder );
408 /* FIXME: Will use the placement chars */
412 for (i
= 0; i
< nSet
; i
++)
414 if (GetCharWidth32W(hdc
, lpString
[i
], lpString
[i
], &c
))
415 lpResults
->lpDx
[i
]= c
;
419 if (lpResults
->lpCaretPos
&& !(dwFlags
& GCP_REORDER
))
423 lpResults
->lpCaretPos
[0] = 0;
424 for (i
= 1; i
< nSet
; i
++)
425 if (GetTextExtentPoint32W(hdc
, &(lpString
[i
- 1]), 1, &size
))
426 lpResults
->lpCaretPos
[i
] = (pos
+= size
.cx
);
429 /*if(lpResults->lpGlyphs)
430 NtGdiGetGlyphIndicesW(hdc, lpString, nSet, lpResults->lpGlyphs, 0);*/
432 if (GetTextExtentPoint32W(hdc
, lpString
, uCount
, &size
))
433 ret
= MAKELONG(size
.cx
, size
.cy
);
440 NewGetCharacterPlacementW(
445 GCP_RESULTSW
*lpResults
,
452 if ( !lpString
|| uCount
<= 0 || (nMaxExtent
< 0 && nMaxExtent
!= -1 ) )
454 SetLastError(ERROR_INVALID_PARAMETER
);
460 if ( GetTextExtentPointW(hdc
, lpString
, uCount
, &Size
) )
462 return MAKELONG(Size
.cx
, Size
.cy
);
468 if ( nSet
> lpResults
->nGlyphs
)
469 nSet
= lpResults
->nGlyphs
;
471 return NtGdiGetCharacterPlacementW( hdc
,
485 GetCharABCWidthsFloatW(HDC hdc
,
490 DPRINT("GetCharABCWidthsFloatW\n");
491 if ((!abcF
) || (FirstChar
> LastChar
))
493 SetLastError(ERROR_INVALID_PARAMETER
);
496 return NtGdiGetCharABCWidthsW( hdc
,
498 (ULONG
)(LastChar
- FirstChar
+ 1),
510 GetCharWidthFloatW(HDC hdc
,
515 DPRINT("GetCharWidthsFloatW\n");
516 if ((!pxBuffer
) || (iFirstChar
> iLastChar
))
518 SetLastError(ERROR_INVALID_PARAMETER
);
521 return NtGdiGetCharWidthW( hdc
,
523 (ULONG
)(iLastChar
- iFirstChar
+ 1),
535 GetCharWidthW(HDC hdc
,
540 DPRINT("GetCharWidthsW\n");
541 if ((!lpBuffer
) || (iFirstChar
> iLastChar
))
543 SetLastError(ERROR_INVALID_PARAMETER
);
546 return NtGdiGetCharWidthW( hdc
,
548 (ULONG
)(iLastChar
- iFirstChar
+ 1),
560 GetCharWidth32W(HDC hdc
,
565 DPRINT("GetCharWidths32W\n");
566 if ((!lpBuffer
) || (iFirstChar
> iLastChar
))
568 SetLastError(ERROR_INVALID_PARAMETER
);
571 return NtGdiGetCharWidthW( hdc
,
573 (ULONG
)(iLastChar
- iFirstChar
+ 1),
575 GCW_NOFLOAT
|GCW_WIN32
,
586 GetCharABCWidthsW(HDC hdc
,
591 DPRINT("GetCharABCWidthsW\n");
592 if ((!lpabc
) || (FirstChar
> LastChar
))
594 SetLastError(ERROR_INVALID_PARAMETER
);
597 return NtGdiGetCharABCWidthsW( hdc
,
599 (ULONG
)(LastChar
- FirstChar
+ 1),
617 INT i
, wlen
, count
= (INT
)(iLastChar
- iFirstChar
+ 1);
622 DPRINT("GetCharWidthsA\n");
623 if(count
<= 0) return FALSE
;
625 str
= HeapAlloc(GetProcessHeap(), 0, count
+1);
629 for(i
= 0; i
< count
; i
++)
630 str
[i
] = (BYTE
)(iFirstChar
+ i
);
633 wstr
= FONT_mbtowc(hdc
, str
, count
+1, &wlen
, NULL
);
636 HeapFree(GetProcessHeap(), 0, str
);
640 ret
= NtGdiGetCharWidthW( hdc
,
647 HeapFree(GetProcessHeap(), 0, str
);
648 HeapFree(GetProcessHeap(), 0, wstr
);
665 INT i
, wlen
, count
= (INT
)(iLastChar
- iFirstChar
+ 1);
670 DPRINT("GetCharWidths32A\n");
671 if(count
<= 0) return FALSE
;
673 str
= HeapAlloc(GetProcessHeap(), 0, count
+1);
676 for(i
= 0; i
< count
; i
++)
677 str
[i
] = (BYTE
)(iFirstChar
+ i
);
680 wstr
= FONT_mbtowc(hdc
, str
, count
+1, &wlen
, NULL
);
683 HeapFree(GetProcessHeap(), 0, str
);
687 ret
= NtGdiGetCharWidthW( hdc
,
691 GCW_NOFLOAT
|GCW_WIN32
,
694 HeapFree(GetProcessHeap(), 0, str
);
695 HeapFree(GetProcessHeap(), 0, wstr
);
712 INT i
, wlen
, count
= (INT
)(iLastChar
- iFirstChar
+ 1);
717 DPRINT("GetCharWidthsFloatA\n");
718 if(count
<= 0) return FALSE
;
720 str
= HeapAlloc(GetProcessHeap(), 0, count
+1);
723 for(i
= 0; i
< count
; i
++)
724 str
[i
] = (BYTE
)(iFirstChar
+ i
);
727 wstr
= FONT_mbtowc(hdc
, str
, count
+1, &wlen
, NULL
);
730 HeapFree(GetProcessHeap(), 0, str
);
733 ret
= NtGdiGetCharWidthW( hdc
, wstr
[0], (ULONG
) count
, (PWCHAR
) wstr
, 0, (PVOID
) pxBuffer
);
735 HeapFree(GetProcessHeap(), 0, str
);
736 HeapFree(GetProcessHeap(), 0, wstr
);
753 INT i
, wlen
, count
= (INT
)(uLastChar
- uFirstChar
+ 1);
758 DPRINT("GetCharABCWidthsA\n");
759 if(count
<= 0) return FALSE
;
761 str
= HeapAlloc(GetProcessHeap(), 0, count
+1);
764 for(i
= 0; i
< count
; i
++)
765 str
[i
] = (BYTE
)(uFirstChar
+ i
);
768 wstr
= FONT_mbtowc(hdc
, str
, count
+1, &wlen
, NULL
);
771 HeapFree(GetProcessHeap(), 0, str
);
775 ret
= NtGdiGetCharABCWidthsW( hdc
,
782 HeapFree(GetProcessHeap(), 0, str
);
783 HeapFree(GetProcessHeap(), 0, wstr
);
793 GetCharABCWidthsFloatA(
800 INT i
, wlen
, count
= (INT
)(iLastChar
- iFirstChar
+ 1);
805 DPRINT("GetCharABCWidthsFloatA\n");
806 if (count
<= 0) return FALSE
;
808 str
= HeapAlloc(GetProcessHeap(), 0, count
+1);
812 for(i
= 0; i
< count
; i
++)
813 str
[i
] = (BYTE
)(iFirstChar
+ i
);
816 wstr
= FONT_mbtowc( hdc
, str
, count
+1, &wlen
, NULL
);
819 HeapFree( GetProcessHeap(), 0, str
);
822 ret
= NtGdiGetCharABCWidthsW( hdc
,wstr
[0],(ULONG
)count
, (PWCHAR
)wstr
, 0, (PVOID
)lpABCF
);
824 HeapFree( GetProcessHeap(), 0, str
);
825 HeapFree( GetProcessHeap(), 0, wstr
);
835 GetCharABCWidthsI(HDC hdc
,
841 DPRINT("GetCharABCWidthsI\n");
842 return NtGdiGetCharABCWidthsW( hdc
,
846 GCABCW_NOFLOAT
|GCABCW_INDICES
,
855 GetCharWidthI(HDC hdc
,
862 DPRINT("GetCharWidthsI\n");
863 if (!lpBuffer
|| (!pgi
&& (giFirst
== MAXUSHORT
))) // Cannot be at max.
865 SetLastError(ERROR_INVALID_PARAMETER
);
868 if (!cgi
) return TRUE
;
869 return NtGdiGetCharWidthW( hdc
,
873 GCW_INDICES
|GCW_NOFLOAT
|GCW_WIN32
,
886 DWORD Gcp
= 0, Ret
= 0;
889 Ret
= NtGdiGetTextCharsetInfo(hDc
, NULL
, 0);
890 if ((Ret
== ARABIC_CHARSET
) || (Ret
== HEBREW_CHARSET
))
891 Ret
= (GCP_KASHIDA
|GCP_DIACRITIC
|GCP_LIGATE
|GCP_GLYPHSHAPE
|GCP_REORDER
);
893 Gcp
= GetDCDWord(hDc
, GdiGetFontLanguageInfo
, GCP_ERROR
);
894 if ( Gcp
== GCP_ERROR
)
918 lpstrW
= FONT_mbtowc(hdc
, lpstr
, count
, &countW
, NULL
);
919 Ret
= NtGdiGetGlyphIndicesW(hdc
, lpstrW
, countW
, pgi
, flags
);
920 HeapFree(GetProcessHeap(), 0, lpstrW
);
943 DPRINT("GetGlyphOutlineA uChar %x\n", uChar
);
944 if (!lpgm
|| !lpmat2
) return GDI_ERROR
;
945 if(!(uFormat
& GGO_GLYPH_INDEX
)) {
948 if(uChar
> 0xff) { /* but, 2 bytes character only */
950 mbchs
[0] = (uChar
& 0xff00) >> 8;
951 mbchs
[1] = (uChar
& 0xff);
954 mbchs
[0] = (uChar
& 0xff);
956 p
= FONT_mbtowc(hdc
, mbchs
, len
, NULL
, NULL
);
960 ret
= NtGdiGetGlyphOutline(hdc
, c
, uFormat
, lpgm
, cbBuffer
, lpvBuffer
, (CONST LPMAT2
)lpmat2
, TRUE
);
961 HeapFree(GetProcessHeap(), 0, p
);
981 DPRINT("GetGlyphOutlineW uChar %x\n", uChar
);
982 if (!lpgm
|| !lpmat2
) return GDI_ERROR
;
983 if (!lpvBuffer
) cbBuffer
= 0;
984 return NtGdiGetGlyphOutline ( hdc
, uChar
, uFormat
, lpgm
, cbBuffer
, lpvBuffer
, (CONST LPMAT2
)lpmat2
, TRUE
);
993 GetOutlineTextMetricsA(
996 LPOUTLINETEXTMETRICA lpOTM
1001 OUTLINETEXTMETRICW
*lpOTMW
= (OUTLINETEXTMETRICW
*)buf
;
1002 OUTLINETEXTMETRICA
*output
= lpOTM
;
1005 if((ret
= GetOutlineTextMetricsW(hdc
, 0, NULL
)) == 0)
1007 if(ret
> sizeof(buf
))
1009 lpOTMW
= HeapAlloc(GetProcessHeap(), 0, ret
);
1015 GetOutlineTextMetricsW(hdc
, ret
, lpOTMW
);
1017 needed
= sizeof(OUTLINETEXTMETRICA
);
1018 if(lpOTMW
->otmpFamilyName
)
1019 needed
+= WideCharToMultiByte(CP_ACP
, 0,
1020 (WCHAR
*)((char*)lpOTMW
+ (int)lpOTMW
->otmpFamilyName
), -1,
1021 NULL
, 0, NULL
, NULL
);
1022 if(lpOTMW
->otmpFaceName
)
1023 needed
+= WideCharToMultiByte(CP_ACP
, 0,
1024 (WCHAR
*)((char*)lpOTMW
+ (int)lpOTMW
->otmpFaceName
), -1,
1025 NULL
, 0, NULL
, NULL
);
1026 if(lpOTMW
->otmpStyleName
)
1027 needed
+= WideCharToMultiByte(CP_ACP
, 0,
1028 (WCHAR
*)((char*)lpOTMW
+ (int)lpOTMW
->otmpStyleName
), -1,
1029 NULL
, 0, NULL
, NULL
);
1030 if(lpOTMW
->otmpFullName
)
1031 needed
+= WideCharToMultiByte(CP_ACP
, 0,
1032 (WCHAR
*)((char*)lpOTMW
+ (int)lpOTMW
->otmpFullName
), -1,
1033 NULL
, 0, NULL
, NULL
);
1040 DPRINT("needed = %d\n", needed
);
1043 /* Since the supplied buffer isn't big enough, we'll alloc one
1044 that is and memcpy the first cbData bytes into the lpOTM at
1046 output
= HeapAlloc(GetProcessHeap(), 0, needed
);
1053 ret
= output
->otmSize
= min(needed
, cbData
);
1054 FONT_TextMetricWToA( &lpOTMW
->otmTextMetrics
, &output
->otmTextMetrics
);
1055 output
->otmFiller
= 0;
1056 output
->otmPanoseNumber
= lpOTMW
->otmPanoseNumber
;
1057 output
->otmfsSelection
= lpOTMW
->otmfsSelection
;
1058 output
->otmfsType
= lpOTMW
->otmfsType
;
1059 output
->otmsCharSlopeRise
= lpOTMW
->otmsCharSlopeRise
;
1060 output
->otmsCharSlopeRun
= lpOTMW
->otmsCharSlopeRun
;
1061 output
->otmItalicAngle
= lpOTMW
->otmItalicAngle
;
1062 output
->otmEMSquare
= lpOTMW
->otmEMSquare
;
1063 output
->otmAscent
= lpOTMW
->otmAscent
;
1064 output
->otmDescent
= lpOTMW
->otmDescent
;
1065 output
->otmLineGap
= lpOTMW
->otmLineGap
;
1066 output
->otmsCapEmHeight
= lpOTMW
->otmsCapEmHeight
;
1067 output
->otmsXHeight
= lpOTMW
->otmsXHeight
;
1068 output
->otmrcFontBox
= lpOTMW
->otmrcFontBox
;
1069 output
->otmMacAscent
= lpOTMW
->otmMacAscent
;
1070 output
->otmMacDescent
= lpOTMW
->otmMacDescent
;
1071 output
->otmMacLineGap
= lpOTMW
->otmMacLineGap
;
1072 output
->otmusMinimumPPEM
= lpOTMW
->otmusMinimumPPEM
;
1073 output
->otmptSubscriptSize
= lpOTMW
->otmptSubscriptSize
;
1074 output
->otmptSubscriptOffset
= lpOTMW
->otmptSubscriptOffset
;
1075 output
->otmptSuperscriptSize
= lpOTMW
->otmptSuperscriptSize
;
1076 output
->otmptSuperscriptOffset
= lpOTMW
->otmptSuperscriptOffset
;
1077 output
->otmsStrikeoutSize
= lpOTMW
->otmsStrikeoutSize
;
1078 output
->otmsStrikeoutPosition
= lpOTMW
->otmsStrikeoutPosition
;
1079 output
->otmsUnderscoreSize
= lpOTMW
->otmsUnderscoreSize
;
1080 output
->otmsUnderscorePosition
= lpOTMW
->otmsUnderscorePosition
;
1083 ptr
= (char*)(output
+ 1);
1084 left
= needed
- sizeof(*output
);
1086 if(lpOTMW
->otmpFamilyName
) {
1087 output
->otmpFamilyName
= (LPSTR
)(ptr
- (char*)output
);
1088 len
= WideCharToMultiByte(CP_ACP
, 0,
1089 (WCHAR
*)((char*)lpOTMW
+ (int)lpOTMW
->otmpFamilyName
), -1,
1090 ptr
, left
, NULL
, NULL
);
1094 output
->otmpFamilyName
= 0;
1096 if(lpOTMW
->otmpFaceName
) {
1097 output
->otmpFaceName
= (LPSTR
)(ptr
- (char*)output
);
1098 len
= WideCharToMultiByte(CP_ACP
, 0,
1099 (WCHAR
*)((char*)lpOTMW
+ (int)lpOTMW
->otmpFaceName
), -1,
1100 ptr
, left
, NULL
, NULL
);
1104 output
->otmpFaceName
= 0;
1106 if(lpOTMW
->otmpStyleName
) {
1107 output
->otmpStyleName
= (LPSTR
)(ptr
- (char*)output
);
1108 len
= WideCharToMultiByte(CP_ACP
, 0,
1109 (WCHAR
*)((char*)lpOTMW
+ (int)lpOTMW
->otmpStyleName
), -1,
1110 ptr
, left
, NULL
, NULL
);
1114 output
->otmpStyleName
= 0;
1116 if(lpOTMW
->otmpFullName
) {
1117 output
->otmpFullName
= (LPSTR
)(ptr
- (char*)output
);
1118 len
= WideCharToMultiByte(CP_ACP
, 0,
1119 (WCHAR
*)((char*)lpOTMW
+ (int)lpOTMW
->otmpFullName
), -1,
1120 ptr
, left
, NULL
, NULL
);
1123 output
->otmpFullName
= 0;
1127 if(output
!= lpOTM
) {
1128 memcpy(lpOTM
, output
, cbData
);
1129 HeapFree(GetProcessHeap(), 0, output
);
1131 /* check if the string offsets really fit into the provided size */
1132 /* FIXME: should we check string length as well? */
1133 if ((UINT_PTR
)lpOTM
->otmpFamilyName
>= lpOTM
->otmSize
)
1134 lpOTM
->otmpFamilyName
= 0; /* doesn't fit */
1136 if ((UINT_PTR
)lpOTM
->otmpFaceName
>= lpOTM
->otmSize
)
1137 lpOTM
->otmpFaceName
= 0; /* doesn't fit */
1139 if ((UINT_PTR
)lpOTM
->otmpStyleName
>= lpOTM
->otmSize
)
1140 lpOTM
->otmpStyleName
= 0; /* doesn't fit */
1142 if ((UINT_PTR
)lpOTM
->otmpFullName
>= lpOTM
->otmSize
)
1143 lpOTM
->otmpFullName
= 0; /* doesn't fit */
1147 if(lpOTMW
!= (OUTLINETEXTMETRICW
*)buf
)
1148 HeapFree(GetProcessHeap(), 0, lpOTMW
);
1159 GetOutlineTextMetricsW(
1162 LPOUTLINETEXTMETRICW lpOTM
1165 TMDIFF Tmd
; // Should not be zero.
1167 return NtGdiGetOutlineTextMetricsInternalW(hdc
, cbData
, lpOTM
, &Tmd
);
1175 GetKerningPairsW(HDC hdc
,
1177 LPKERNINGPAIR pkpDst
)
1179 if ((cPairs
!= 0) || (pkpDst
== 0))
1181 return NtGdiGetKerningPairs(hdc
,cPairs
,pkpDst
);
1185 SetLastError(ERROR_INVALID_PARAMETER
);
1195 GetKerningPairsA( HDC hDC
,
1197 LPKERNINGPAIR kern_pairA
)
1202 DWORD i
, total_kern_pairs
, kern_pairs_copied
= 0;
1203 KERNINGPAIR
*kern_pairW
;
1205 if (!cPairs
&& kern_pairA
)
1207 SetLastError(ERROR_INVALID_PARAMETER
);
1211 charset
= GetTextCharset(hDC
);
1212 if (!TranslateCharsetInfo(ULongToPtr(charset
), &csi
, TCI_SRCCHARSET
))
1214 DPRINT1("Can't find codepage for charset %d\n", charset
);
1217 /* GetCPInfo() will fail on CP_SYMBOL, and WideCharToMultiByte is supposed
1218 * to fail on an invalid character for CP_SYMBOL.
1220 cpi
.DefaultChar
[0] = 0;
1221 if (csi
.ciACP
!= CP_SYMBOL
&& !GetCPInfo(csi
.ciACP
, &cpi
))
1223 DPRINT1("Can't find codepage %u info\n", csi
.ciACP
);
1226 DPRINT("charset %d => codepage %u\n", charset
, csi
.ciACP
);
1228 total_kern_pairs
= NtGdiGetKerningPairs(hDC
, 0, NULL
);
1229 if (!total_kern_pairs
) return 0;
1231 if (!cPairs
&& !kern_pairA
) return total_kern_pairs
;
1233 kern_pairW
= HeapAlloc(GetProcessHeap(), 0, total_kern_pairs
* sizeof(*kern_pairW
));
1234 if (kern_pairW
== NULL
)
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((VOID
*)&pEfdw
->elfexdv
.elfEnumLogfontEx
,
1907 (VOID
*)&pNtmwi
->ntmw
,
1911 pEfdw
= (PENUMFONTDATAW
)((ULONG_PTR
)pEfdw
+ pEfdw
->cbSize
);
1914 /* Release the memory and close handle */
1915 HeapFree(GetProcessHeap(), 0, pBuffer
);
1916 NtGdiEnumFontClose(idEnum
);