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.
67 FONT_TextMetricWToA(const TEXTMETRICW
*ptmW
, LPTEXTMETRICA ptmA
)
69 ptmA
->tmHeight
= ptmW
->tmHeight
;
70 ptmA
->tmAscent
= ptmW
->tmAscent
;
71 ptmA
->tmDescent
= ptmW
->tmDescent
;
72 ptmA
->tmInternalLeading
= ptmW
->tmInternalLeading
;
73 ptmA
->tmExternalLeading
= ptmW
->tmExternalLeading
;
74 ptmA
->tmAveCharWidth
= ptmW
->tmAveCharWidth
;
75 ptmA
->tmMaxCharWidth
= ptmW
->tmMaxCharWidth
;
76 ptmA
->tmWeight
= ptmW
->tmWeight
;
77 ptmA
->tmOverhang
= ptmW
->tmOverhang
;
78 ptmA
->tmDigitizedAspectX
= ptmW
->tmDigitizedAspectX
;
79 ptmA
->tmDigitizedAspectY
= ptmW
->tmDigitizedAspectY
;
80 ptmA
->tmFirstChar
= min(ptmW
->tmFirstChar
, 255);
81 if (ptmW
->tmCharSet
== SYMBOL_CHARSET
)
83 ptmA
->tmFirstChar
= 0x1e;
84 ptmA
->tmLastChar
= 0xff; /* win9x behaviour - we need the OS2 table data to calculate correctly */
88 ptmA
->tmFirstChar
= ptmW
->tmDefaultChar
- 1;
89 ptmA
->tmLastChar
= min(ptmW
->tmLastChar
, 0xff);
91 ptmA
->tmDefaultChar
= ptmW
->tmDefaultChar
;
92 ptmA
->tmBreakChar
= ptmW
->tmBreakChar
;
93 ptmA
->tmItalic
= ptmW
->tmItalic
;
94 ptmA
->tmUnderlined
= ptmW
->tmUnderlined
;
95 ptmA
->tmStruckOut
= ptmW
->tmStruckOut
;
96 ptmA
->tmPitchAndFamily
= ptmW
->tmPitchAndFamily
;
97 ptmA
->tmCharSet
= ptmW
->tmCharSet
;
100 /***********************************************************************
103 * Returns a Unicode translation of str using the charset of the
104 * currently selected font in hdc. If count is -1 then str is assumed
105 * to be '\0' terminated, otherwise it contains the number of bytes to
106 * convert. If plenW is non-NULL, on return it will point to the
107 * number of WCHARs that have been written. If pCP is non-NULL, on
108 * return it will point to the codepage used in the conversion. The
109 * caller should free the returned LPWSTR from the process heap
112 static LPWSTR
FONT_mbtowc(HDC hdc
, LPCSTR str
, INT count
, INT
*plenW
, UINT
*pCP
)
114 UINT cp
= GdiGetCodePage( hdc
);
118 if(count
== -1) count
= strlen(str
);
119 lenW
= MultiByteToWideChar(cp
, 0, str
, count
, NULL
, 0);
120 strW
= HeapAlloc(GetProcessHeap(), 0, lenW
*sizeof(WCHAR
));
123 MultiByteToWideChar(cp
, 0, str
, count
, strW
, lenW
);
124 DPRINT("mapped %s -> %S\n", str
, strW
);
125 if(plenW
) *plenW
= lenW
;
131 NewTextMetricW2A(NEWTEXTMETRICA
*tma
, NEWTEXTMETRICW
*tmw
)
133 FONT_TextMetricWToA((TEXTMETRICW
*) tmw
, (TEXTMETRICA
*) tma
);
134 tma
->ntmFlags
= tmw
->ntmFlags
;
135 tma
->ntmSizeEM
= tmw
->ntmSizeEM
;
136 tma
->ntmCellHeight
= tmw
->ntmCellHeight
;
137 tma
->ntmAvgWidth
= tmw
->ntmAvgWidth
;
141 NewTextMetricExW2A(NEWTEXTMETRICEXA
*tma
, NEWTEXTMETRICEXW
*tmw
)
143 NewTextMetricW2A(&tma
->ntmTm
, &tmw
->ntmTm
);
144 tma
->ntmFontSig
= tmw
->ntmFontSig
;
148 IntEnumFontFamilies(HDC Dc
, LPLOGFONTW LogFont
, PVOID EnumProc
, LPARAM lParam
,
153 PFONTFAMILYINFO Info
;
156 ENUMLOGFONTEXA EnumLogFontExA
;
157 NEWTEXTMETRICEXA NewTextMetricExA
;
159 Info
= RtlAllocateHeap(GetProcessHeap(), 0,
160 INITIAL_FAMILY_COUNT
* sizeof(FONTFAMILYINFO
));
165 FontFamilyCount
= NtGdiGetFontFamilyInfo(Dc
, LogFont
, Info
, INITIAL_FAMILY_COUNT
);
166 if (FontFamilyCount
< 0)
168 RtlFreeHeap(GetProcessHeap(), 0, Info
);
171 if (INITIAL_FAMILY_COUNT
< FontFamilyCount
)
173 FontFamilySize
= FontFamilyCount
;
174 RtlFreeHeap(GetProcessHeap(), 0, Info
);
175 Info
= RtlAllocateHeap(GetProcessHeap(), 0,
176 FontFamilyCount
* sizeof(FONTFAMILYINFO
));
181 FontFamilyCount
= NtGdiGetFontFamilyInfo(Dc
, LogFont
, Info
, FontFamilySize
);
182 if (FontFamilyCount
< 0 || FontFamilySize
< FontFamilyCount
)
184 RtlFreeHeap(GetProcessHeap(), 0, Info
);
189 for (i
= 0; i
< FontFamilyCount
; i
++)
193 Ret
= ((FONTENUMPROCW
) EnumProc
)(
194 (VOID
*)&Info
[i
].EnumLogFontEx
,
195 (VOID
*)&Info
[i
].NewTextMetricEx
,
196 Info
[i
].FontType
, lParam
);
199 { // Could use EnumLogFontExW2A here?
200 LogFontW2A(&EnumLogFontExA
.elfLogFont
, &Info
[i
].EnumLogFontEx
.elfLogFont
);
201 WideCharToMultiByte(CP_THREAD_ACP
, 0, Info
[i
].EnumLogFontEx
.elfFullName
, -1,
202 (LPSTR
)EnumLogFontExA
.elfFullName
, LF_FULLFACESIZE
, NULL
, NULL
);
203 WideCharToMultiByte(CP_THREAD_ACP
, 0, Info
[i
].EnumLogFontEx
.elfStyle
, -1,
204 (LPSTR
)EnumLogFontExA
.elfStyle
, LF_FACESIZE
, NULL
, NULL
);
205 WideCharToMultiByte(CP_THREAD_ACP
, 0, Info
[i
].EnumLogFontEx
.elfScript
, -1,
206 (LPSTR
)EnumLogFontExA
.elfScript
, LF_FACESIZE
, NULL
, NULL
);
207 NewTextMetricExW2A(&NewTextMetricExA
,
208 &Info
[i
].NewTextMetricEx
);
209 Ret
= ((FONTENUMPROCA
) EnumProc
)(
210 (VOID
*)&EnumLogFontExA
,
211 (VOID
*)&NewTextMetricExA
,
212 Info
[i
].FontType
, lParam
);
216 RtlFreeHeap(GetProcessHeap(), 0, Info
);
225 EnumFontFamiliesExW(HDC hdc
, LPLOGFONTW lpLogfont
, FONTENUMPROCW lpEnumFontFamExProc
,
226 LPARAM lParam
, DWORD dwFlags
)
228 return IntEnumFontFamilies(hdc
, lpLogfont
, lpEnumFontFamExProc
, lParam
, TRUE
);
236 EnumFontFamiliesW(HDC hdc
, LPCWSTR lpszFamily
, FONTENUMPROCW lpEnumFontFamProc
,
241 ZeroMemory(&LogFont
, sizeof(LOGFONTW
));
242 LogFont
.lfCharSet
= DEFAULT_CHARSET
;
243 if (NULL
!= lpszFamily
)
245 if (!*lpszFamily
) return 1;
246 lstrcpynW(LogFont
.lfFaceName
, lpszFamily
, LF_FACESIZE
);
249 return IntEnumFontFamilies(hdc
, &LogFont
, lpEnumFontFamProc
, lParam
, TRUE
);
257 EnumFontFamiliesExA (HDC hdc
, LPLOGFONTA lpLogfont
, FONTENUMPROCA lpEnumFontFamExProc
,
258 LPARAM lParam
, DWORD dwFlags
)
260 LOGFONTW LogFontW
, *pLogFontW
;
264 LogFontA2W(&LogFontW
,lpLogfont
);
265 pLogFontW
= &LogFontW
;
267 else pLogFontW
= NULL
;
269 /* no need to convert LogFontW back to lpLogFont b/c it's an [in] parameter only */
270 return IntEnumFontFamilies(hdc
, pLogFontW
, lpEnumFontFamExProc
, lParam
, FALSE
);
278 EnumFontFamiliesA(HDC hdc
, LPCSTR lpszFamily
, FONTENUMPROCA lpEnumFontFamProc
,
283 ZeroMemory(&LogFont
, sizeof(LOGFONTW
));
284 LogFont
.lfCharSet
= DEFAULT_CHARSET
;
285 if (NULL
!= lpszFamily
)
287 if (!*lpszFamily
) return 1;
288 MultiByteToWideChar(CP_THREAD_ACP
, 0, lpszFamily
, -1, LogFont
.lfFaceName
, LF_FACESIZE
);
291 return IntEnumFontFamilies(hdc
, &LogFont
, lpEnumFontFamProc
, lParam
, FALSE
);
300 GetCharacterPlacementA(
305 GCP_RESULTSA
*lpResults
,
310 GCP_RESULTSW resultsW
;
314 if ( !lpString
|| uCount
<= 0 || (nMaxExtent
< 0 && nMaxExtent
!= -1 ) )
316 SetLastError(ERROR_INVALID_PARAMETER
);
319 /* TRACE("%s, %d, %d, 0x%08x\n",
320 debugstr_an(lpString, uCount), uCount, nMaxExtent, dwFlags);
322 /* both structs are equal in size */
323 memcpy(&resultsW
, lpResults
, sizeof(resultsW
));
325 lpStringW
= FONT_mbtowc(hdc
, lpString
, uCount
, &uCountW
, &font_cp
);
326 if(lpResults
->lpOutString
)
328 resultsW
.lpOutString
= HeapAlloc(GetProcessHeap(), 0, sizeof(WCHAR
)*uCountW
);
329 if (resultsW
.lpOutString
== NULL
)
335 ret
= GetCharacterPlacementW(hdc
, lpStringW
, uCountW
, nMaxExtent
, &resultsW
, dwFlags
);
337 lpResults
->nGlyphs
= resultsW
.nGlyphs
;
338 lpResults
->nMaxFit
= resultsW
.nMaxFit
;
340 if(lpResults
->lpOutString
) {
341 WideCharToMultiByte(font_cp
, 0, resultsW
.lpOutString
, uCountW
,
342 lpResults
->lpOutString
, uCount
, NULL
, NULL
);
345 HeapFree(GetProcessHeap(), 0, lpStringW
);
346 HeapFree(GetProcessHeap(), 0, resultsW
.lpOutString
);
357 GetCharacterPlacementW(
362 GCP_RESULTSW
*lpResults
,
369 DPRINT("GetCharacterPlacementW\n");
371 if(dwFlags
&(~GCP_REORDER
)) DPRINT("flags 0x%08lx ignored\n", dwFlags
);
372 if(lpResults
->lpClass
) DPRINT("classes not implemented\n");
373 if (lpResults
->lpCaretPos
&& (dwFlags
& GCP_REORDER
))
374 DPRINT("Caret positions for complex scripts not implemented\n");
377 if(nSet
> lpResults
->nGlyphs
)
378 nSet
= lpResults
->nGlyphs
;
380 /* return number of initialized fields */
381 lpResults
->nGlyphs
= nSet
;
383 /*if((dwFlags&GCP_REORDER)==0 || !BidiAvail)
385 /* Treat the case where no special handling was requested in a fastpath way */
386 /* copy will do if the GCP_REORDER flag is not set */
387 if(lpResults
->lpOutString
)
388 lstrcpynW( lpResults
->lpOutString
, lpString
, nSet
);
390 if(lpResults
->lpGlyphs
)
391 lstrcpynW( lpResults
->lpGlyphs
, lpString
, nSet
);
393 if(lpResults
->lpOrder
)
395 for(i
= 0; i
< nSet
; i
++)
396 lpResults
->lpOrder
[i
] = i
;
400 BIDI_Reorder( lpString, uCount, dwFlags, WINE_GCPW_FORCE_LTR, lpResults->lpOutString,
401 nSet, lpResults->lpOrder );
404 /* FIXME: Will use the placement chars */
408 for (i
= 0; i
< nSet
; i
++)
410 if (GetCharWidth32W(hdc
, lpString
[i
], lpString
[i
], &c
))
411 lpResults
->lpDx
[i
]= c
;
415 if (lpResults
->lpCaretPos
&& !(dwFlags
& GCP_REORDER
))
419 lpResults
->lpCaretPos
[0] = 0;
420 for (i
= 1; i
< nSet
; i
++)
421 if (GetTextExtentPoint32W(hdc
, &(lpString
[i
- 1]), 1, &size
))
422 lpResults
->lpCaretPos
[i
] = (pos
+= size
.cx
);
425 /*if(lpResults->lpGlyphs)
426 NtGdiGetGlyphIndicesW(hdc, lpString, nSet, lpResults->lpGlyphs, 0);*/
428 if (GetTextExtentPoint32W(hdc
, lpString
, uCount
, &size
))
429 ret
= MAKELONG(size
.cx
, size
.cy
);
436 NewGetCharacterPlacementW(
441 GCP_RESULTSW
*lpResults
,
448 if ( !lpString
|| uCount
<= 0 || (nMaxExtent
< 0 && nMaxExtent
!= -1 ) )
450 SetLastError(ERROR_INVALID_PARAMETER
);
456 if ( GetTextExtentPointW(hdc
, lpString
, uCount
, &Size
) )
458 return MAKELONG(Size
.cx
, Size
.cy
);
464 if ( nSet
> lpResults
->nGlyphs
)
465 nSet
= lpResults
->nGlyphs
;
467 return NtGdiGetCharacterPlacementW( hdc
,
481 GetCharABCWidthsFloatW(HDC hdc
,
486 DPRINT("GetCharABCWidthsFloatW\n");
487 if ((!abcF
) || (FirstChar
> LastChar
))
489 SetLastError(ERROR_INVALID_PARAMETER
);
492 return NtGdiGetCharABCWidthsW( hdc
,
494 (ULONG
)(LastChar
- FirstChar
+ 1),
506 GetCharWidthFloatW(HDC hdc
,
511 DPRINT("GetCharWidthsFloatW\n");
512 if ((!pxBuffer
) || (iFirstChar
> iLastChar
))
514 SetLastError(ERROR_INVALID_PARAMETER
);
517 return NtGdiGetCharWidthW( hdc
,
519 (ULONG
)(iLastChar
- iFirstChar
+ 1),
531 GetCharWidthW(HDC hdc
,
536 DPRINT("GetCharWidthsW\n");
537 if ((!lpBuffer
) || (iFirstChar
> iLastChar
))
539 SetLastError(ERROR_INVALID_PARAMETER
);
542 return NtGdiGetCharWidthW( hdc
,
544 (ULONG
)(iLastChar
- iFirstChar
+ 1),
556 GetCharWidth32W(HDC hdc
,
561 DPRINT("GetCharWidths32W\n");
562 if ((!lpBuffer
) || (iFirstChar
> iLastChar
))
564 SetLastError(ERROR_INVALID_PARAMETER
);
567 return NtGdiGetCharWidthW( hdc
,
569 (ULONG
)(iLastChar
- iFirstChar
+ 1),
571 GCW_NOFLOAT
|GCW_WIN32
,
582 GetCharABCWidthsW(HDC hdc
,
587 DPRINT("GetCharABCWidthsW\n");
588 if ((!lpabc
) || (FirstChar
> LastChar
))
590 SetLastError(ERROR_INVALID_PARAMETER
);
593 return NtGdiGetCharABCWidthsW( hdc
,
595 (ULONG
)(LastChar
- FirstChar
+ 1),
613 INT i
, wlen
, count
= (INT
)(iLastChar
- iFirstChar
+ 1);
618 DPRINT("GetCharWidthsA\n");
619 if(count
<= 0) return FALSE
;
621 str
= HeapAlloc(GetProcessHeap(), 0, count
+1);
625 for(i
= 0; i
< count
; i
++)
626 str
[i
] = (BYTE
)(iFirstChar
+ i
);
629 wstr
= FONT_mbtowc(hdc
, str
, count
+1, &wlen
, NULL
);
632 HeapFree(GetProcessHeap(), 0, str
);
636 ret
= NtGdiGetCharWidthW( hdc
,
643 HeapFree(GetProcessHeap(), 0, str
);
644 HeapFree(GetProcessHeap(), 0, wstr
);
661 INT i
, wlen
, count
= (INT
)(iLastChar
- iFirstChar
+ 1);
666 DPRINT("GetCharWidths32A\n");
667 if(count
<= 0) return FALSE
;
669 str
= HeapAlloc(GetProcessHeap(), 0, count
+1);
672 for(i
= 0; i
< count
; i
++)
673 str
[i
] = (BYTE
)(iFirstChar
+ i
);
676 wstr
= FONT_mbtowc(hdc
, str
, count
+1, &wlen
, NULL
);
679 HeapFree(GetProcessHeap(), 0, str
);
683 ret
= NtGdiGetCharWidthW( hdc
,
687 GCW_NOFLOAT
|GCW_WIN32
,
690 HeapFree(GetProcessHeap(), 0, str
);
691 HeapFree(GetProcessHeap(), 0, wstr
);
708 INT i
, wlen
, count
= (INT
)(iLastChar
- iFirstChar
+ 1);
713 DPRINT("GetCharWidthsFloatA\n");
714 if(count
<= 0) return FALSE
;
716 str
= HeapAlloc(GetProcessHeap(), 0, count
+1);
719 for(i
= 0; i
< count
; i
++)
720 str
[i
] = (BYTE
)(iFirstChar
+ i
);
723 wstr
= FONT_mbtowc(hdc
, str
, count
+1, &wlen
, NULL
);
726 HeapFree(GetProcessHeap(), 0, str
);
729 ret
= NtGdiGetCharWidthW( hdc
, wstr
[0], (ULONG
) count
, (PWCHAR
) wstr
, 0, (PVOID
) pxBuffer
);
731 HeapFree(GetProcessHeap(), 0, str
);
732 HeapFree(GetProcessHeap(), 0, wstr
);
749 INT i
, wlen
, count
= (INT
)(uLastChar
- uFirstChar
+ 1);
754 DPRINT("GetCharABCWidthsA\n");
755 if(count
<= 0) return FALSE
;
757 str
= HeapAlloc(GetProcessHeap(), 0, count
+1);
760 for(i
= 0; i
< count
; i
++)
761 str
[i
] = (BYTE
)(uFirstChar
+ i
);
764 wstr
= FONT_mbtowc(hdc
, str
, count
+1, &wlen
, NULL
);
767 HeapFree(GetProcessHeap(), 0, str
);
771 ret
= NtGdiGetCharABCWidthsW( hdc
,
778 HeapFree(GetProcessHeap(), 0, str
);
779 HeapFree(GetProcessHeap(), 0, wstr
);
789 GetCharABCWidthsFloatA(
796 INT i
, wlen
, count
= (INT
)(iLastChar
- iFirstChar
+ 1);
801 DPRINT("GetCharABCWidthsFloatA\n");
802 if (count
<= 0) return FALSE
;
804 str
= HeapAlloc(GetProcessHeap(), 0, count
+1);
808 for(i
= 0; i
< count
; i
++)
809 str
[i
] = (BYTE
)(iFirstChar
+ i
);
812 wstr
= FONT_mbtowc( hdc
, str
, count
+1, &wlen
, NULL
);
815 HeapFree( GetProcessHeap(), 0, str
);
818 ret
= NtGdiGetCharABCWidthsW( hdc
,wstr
[0],(ULONG
)count
, (PWCHAR
)wstr
, 0, (PVOID
)lpABCF
);
820 HeapFree( GetProcessHeap(), 0, str
);
821 HeapFree( GetProcessHeap(), 0, wstr
);
831 GetCharABCWidthsI(HDC hdc
,
837 DPRINT("GetCharABCWidthsI\n");
838 return NtGdiGetCharABCWidthsW( hdc
,
842 GCABCW_NOFLOAT
|GCABCW_INDICES
,
851 GetCharWidthI(HDC hdc
,
858 DPRINT("GetCharWidthsI\n");
859 if (!lpBuffer
|| (!pgi
&& (giFirst
== MAXUSHORT
))) // Cannot be at max.
861 SetLastError(ERROR_INVALID_PARAMETER
);
864 if (!cgi
) return TRUE
;
865 return NtGdiGetCharWidthW( hdc
,
869 GCW_INDICES
|GCW_NOFLOAT
|GCW_WIN32
,
882 DWORD Gcp
= 0, Ret
= 0;
885 Ret
= NtGdiGetTextCharsetInfo(hDc
, NULL
, 0);
886 if ((Ret
== ARABIC_CHARSET
) || (Ret
== HEBREW_CHARSET
))
887 Ret
= (GCP_KASHIDA
|GCP_DIACRITIC
|GCP_LIGATE
|GCP_GLYPHSHAPE
|GCP_REORDER
);
889 Gcp
= GetDCDWord(hDc
, GdiGetFontLanguageInfo
, GCP_ERROR
);
890 if ( Gcp
== GCP_ERROR
)
914 lpstrW
= FONT_mbtowc(hdc
, lpstr
, count
, &countW
, NULL
);
915 Ret
= NtGdiGetGlyphIndicesW(hdc
, lpstrW
, countW
, pgi
, flags
);
916 HeapFree(GetProcessHeap(), 0, lpstrW
);
939 DPRINT("GetGlyphOutlineA uChar %x\n", uChar
);
940 if (!lpgm
|| !lpmat2
) return GDI_ERROR
;
941 if(!(uFormat
& GGO_GLYPH_INDEX
)) {
944 if(uChar
> 0xff) { /* but, 2 bytes character only */
946 mbchs
[0] = (uChar
& 0xff00) >> 8;
947 mbchs
[1] = (uChar
& 0xff);
950 mbchs
[0] = (uChar
& 0xff);
952 p
= FONT_mbtowc(hdc
, mbchs
, len
, NULL
, NULL
);
956 ret
= NtGdiGetGlyphOutline(hdc
, c
, uFormat
, lpgm
, cbBuffer
, lpvBuffer
, (CONST LPMAT2
)lpmat2
, TRUE
);
957 HeapFree(GetProcessHeap(), 0, p
);
977 DPRINT("GetGlyphOutlineW uChar %x\n", uChar
);
978 if (!lpgm
|| !lpmat2
) return GDI_ERROR
;
979 if (!lpvBuffer
) cbBuffer
= 0;
980 return NtGdiGetGlyphOutline ( hdc
, uChar
, uFormat
, lpgm
, cbBuffer
, lpvBuffer
, (CONST LPMAT2
)lpmat2
, TRUE
);
989 GetOutlineTextMetricsA(
992 LPOUTLINETEXTMETRICA lpOTM
997 OUTLINETEXTMETRICW
*lpOTMW
= (OUTLINETEXTMETRICW
*)buf
;
998 OUTLINETEXTMETRICA
*output
= lpOTM
;
1001 if((ret
= GetOutlineTextMetricsW(hdc
, 0, NULL
)) == 0)
1003 if(ret
> sizeof(buf
))
1005 lpOTMW
= HeapAlloc(GetProcessHeap(), 0, ret
);
1011 GetOutlineTextMetricsW(hdc
, ret
, lpOTMW
);
1013 needed
= sizeof(OUTLINETEXTMETRICA
);
1014 if(lpOTMW
->otmpFamilyName
)
1015 needed
+= WideCharToMultiByte(CP_ACP
, 0,
1016 (WCHAR
*)((char*)lpOTMW
+ (int)lpOTMW
->otmpFamilyName
), -1,
1017 NULL
, 0, NULL
, NULL
);
1018 if(lpOTMW
->otmpFaceName
)
1019 needed
+= WideCharToMultiByte(CP_ACP
, 0,
1020 (WCHAR
*)((char*)lpOTMW
+ (int)lpOTMW
->otmpFaceName
), -1,
1021 NULL
, 0, NULL
, NULL
);
1022 if(lpOTMW
->otmpStyleName
)
1023 needed
+= WideCharToMultiByte(CP_ACP
, 0,
1024 (WCHAR
*)((char*)lpOTMW
+ (int)lpOTMW
->otmpStyleName
), -1,
1025 NULL
, 0, NULL
, NULL
);
1026 if(lpOTMW
->otmpFullName
)
1027 needed
+= WideCharToMultiByte(CP_ACP
, 0,
1028 (WCHAR
*)((char*)lpOTMW
+ (int)lpOTMW
->otmpFullName
), -1,
1029 NULL
, 0, NULL
, NULL
);
1036 DPRINT("needed = %d\n", needed
);
1039 /* Since the supplied buffer isn't big enough, we'll alloc one
1040 that is and memcpy the first cbData bytes into the lpOTM at
1042 output
= HeapAlloc(GetProcessHeap(), 0, needed
);
1049 ret
= output
->otmSize
= min(needed
, cbData
);
1050 FONT_TextMetricWToA( &lpOTMW
->otmTextMetrics
, &output
->otmTextMetrics
);
1051 output
->otmFiller
= 0;
1052 output
->otmPanoseNumber
= lpOTMW
->otmPanoseNumber
;
1053 output
->otmfsSelection
= lpOTMW
->otmfsSelection
;
1054 output
->otmfsType
= lpOTMW
->otmfsType
;
1055 output
->otmsCharSlopeRise
= lpOTMW
->otmsCharSlopeRise
;
1056 output
->otmsCharSlopeRun
= lpOTMW
->otmsCharSlopeRun
;
1057 output
->otmItalicAngle
= lpOTMW
->otmItalicAngle
;
1058 output
->otmEMSquare
= lpOTMW
->otmEMSquare
;
1059 output
->otmAscent
= lpOTMW
->otmAscent
;
1060 output
->otmDescent
= lpOTMW
->otmDescent
;
1061 output
->otmLineGap
= lpOTMW
->otmLineGap
;
1062 output
->otmsCapEmHeight
= lpOTMW
->otmsCapEmHeight
;
1063 output
->otmsXHeight
= lpOTMW
->otmsXHeight
;
1064 output
->otmrcFontBox
= lpOTMW
->otmrcFontBox
;
1065 output
->otmMacAscent
= lpOTMW
->otmMacAscent
;
1066 output
->otmMacDescent
= lpOTMW
->otmMacDescent
;
1067 output
->otmMacLineGap
= lpOTMW
->otmMacLineGap
;
1068 output
->otmusMinimumPPEM
= lpOTMW
->otmusMinimumPPEM
;
1069 output
->otmptSubscriptSize
= lpOTMW
->otmptSubscriptSize
;
1070 output
->otmptSubscriptOffset
= lpOTMW
->otmptSubscriptOffset
;
1071 output
->otmptSuperscriptSize
= lpOTMW
->otmptSuperscriptSize
;
1072 output
->otmptSuperscriptOffset
= lpOTMW
->otmptSuperscriptOffset
;
1073 output
->otmsStrikeoutSize
= lpOTMW
->otmsStrikeoutSize
;
1074 output
->otmsStrikeoutPosition
= lpOTMW
->otmsStrikeoutPosition
;
1075 output
->otmsUnderscoreSize
= lpOTMW
->otmsUnderscoreSize
;
1076 output
->otmsUnderscorePosition
= lpOTMW
->otmsUnderscorePosition
;
1079 ptr
= (char*)(output
+ 1);
1080 left
= needed
- sizeof(*output
);
1082 if(lpOTMW
->otmpFamilyName
) {
1083 output
->otmpFamilyName
= (LPSTR
)(ptr
- (char*)output
);
1084 len
= WideCharToMultiByte(CP_ACP
, 0,
1085 (WCHAR
*)((char*)lpOTMW
+ (int)lpOTMW
->otmpFamilyName
), -1,
1086 ptr
, left
, NULL
, NULL
);
1090 output
->otmpFamilyName
= 0;
1092 if(lpOTMW
->otmpFaceName
) {
1093 output
->otmpFaceName
= (LPSTR
)(ptr
- (char*)output
);
1094 len
= WideCharToMultiByte(CP_ACP
, 0,
1095 (WCHAR
*)((char*)lpOTMW
+ (int)lpOTMW
->otmpFaceName
), -1,
1096 ptr
, left
, NULL
, NULL
);
1100 output
->otmpFaceName
= 0;
1102 if(lpOTMW
->otmpStyleName
) {
1103 output
->otmpStyleName
= (LPSTR
)(ptr
- (char*)output
);
1104 len
= WideCharToMultiByte(CP_ACP
, 0,
1105 (WCHAR
*)((char*)lpOTMW
+ (int)lpOTMW
->otmpStyleName
), -1,
1106 ptr
, left
, NULL
, NULL
);
1110 output
->otmpStyleName
= 0;
1112 if(lpOTMW
->otmpFullName
) {
1113 output
->otmpFullName
= (LPSTR
)(ptr
- (char*)output
);
1114 len
= WideCharToMultiByte(CP_ACP
, 0,
1115 (WCHAR
*)((char*)lpOTMW
+ (int)lpOTMW
->otmpFullName
), -1,
1116 ptr
, left
, NULL
, NULL
);
1119 output
->otmpFullName
= 0;
1123 if(output
!= lpOTM
) {
1124 memcpy(lpOTM
, output
, cbData
);
1125 HeapFree(GetProcessHeap(), 0, output
);
1127 /* check if the string offsets really fit into the provided size */
1128 /* FIXME: should we check string length as well? */
1129 if ((UINT_PTR
)lpOTM
->otmpFamilyName
>= lpOTM
->otmSize
)
1130 lpOTM
->otmpFamilyName
= 0; /* doesn't fit */
1132 if ((UINT_PTR
)lpOTM
->otmpFaceName
>= lpOTM
->otmSize
)
1133 lpOTM
->otmpFaceName
= 0; /* doesn't fit */
1135 if ((UINT_PTR
)lpOTM
->otmpStyleName
>= lpOTM
->otmSize
)
1136 lpOTM
->otmpStyleName
= 0; /* doesn't fit */
1138 if ((UINT_PTR
)lpOTM
->otmpFullName
>= lpOTM
->otmSize
)
1139 lpOTM
->otmpFullName
= 0; /* doesn't fit */
1143 if(lpOTMW
!= (OUTLINETEXTMETRICW
*)buf
)
1144 HeapFree(GetProcessHeap(), 0, lpOTMW
);
1155 GetOutlineTextMetricsW(
1158 LPOUTLINETEXTMETRICW lpOTM
1161 TMDIFF Tmd
; // Should not be zero.
1163 return NtGdiGetOutlineTextMetricsInternalW(hdc
, cbData
, lpOTM
, &Tmd
);
1171 GetKerningPairsW(HDC hdc
,
1173 LPKERNINGPAIR pkpDst
)
1175 if ((cPairs
!= 0) || (pkpDst
== 0))
1177 return NtGdiGetKerningPairs(hdc
,cPairs
,pkpDst
);
1181 SetLastError(ERROR_INVALID_PARAMETER
);
1191 GetKerningPairsA( HDC hDC
,
1193 LPKERNINGPAIR kern_pairA
)
1198 DWORD i
, total_kern_pairs
, kern_pairs_copied
= 0;
1199 KERNINGPAIR
*kern_pairW
;
1201 if (!cPairs
&& kern_pairA
)
1203 SetLastError(ERROR_INVALID_PARAMETER
);
1207 charset
= GetTextCharset(hDC
);
1208 if (!TranslateCharsetInfo(ULongToPtr(charset
), &csi
, TCI_SRCCHARSET
))
1210 DPRINT1("Can't find codepage for charset %d\n", charset
);
1213 /* GetCPInfo() will fail on CP_SYMBOL, and WideCharToMultiByte is supposed
1214 * to fail on an invalid character for CP_SYMBOL.
1216 cpi
.DefaultChar
[0] = 0;
1217 if (csi
.ciACP
!= CP_SYMBOL
&& !GetCPInfo(csi
.ciACP
, &cpi
))
1219 DPRINT1("Can't find codepage %u info\n", csi
.ciACP
);
1222 DPRINT("charset %d => codepage %u\n", charset
, csi
.ciACP
);
1224 total_kern_pairs
= NtGdiGetKerningPairs(hDC
, 0, NULL
);
1225 if (!total_kern_pairs
) return 0;
1227 if (!cPairs
&& !kern_pairA
) return total_kern_pairs
;
1229 kern_pairW
= HeapAlloc(GetProcessHeap(), 0, total_kern_pairs
* sizeof(*kern_pairW
));
1230 if (kern_pairW
== NULL
)
1234 GetKerningPairsW(hDC
, total_kern_pairs
, kern_pairW
);
1236 for (i
= 0; i
< total_kern_pairs
; i
++)
1240 if (!WideCharToMultiByte(csi
.ciACP
, 0, &kern_pairW
[i
].wFirst
, 1, &first
, 1, NULL
, NULL
))
1243 if (!WideCharToMultiByte(csi
.ciACP
, 0, &kern_pairW
[i
].wSecond
, 1, &second
, 1, NULL
, NULL
))
1246 if (first
== cpi
.DefaultChar
[0] || second
== cpi
.DefaultChar
[0])
1251 if (kern_pairs_copied
>= cPairs
) break;
1253 kern_pairA
->wFirst
= (BYTE
)first
;
1254 kern_pairA
->wSecond
= (BYTE
)second
;
1255 kern_pairA
->iKernAmount
= kern_pairW
[i
].iKernAmount
;
1258 kern_pairs_copied
++;
1261 HeapFree(GetProcessHeap(), 0, kern_pairW
);
1263 return kern_pairs_copied
;
1273 CreateFontIndirectExA(const ENUMLOGFONTEXDVA
*elfexd
)
1277 ENUMLOGFONTEXDVW Logfont
;
1279 EnumLogFontExW2A( (LPENUMLOGFONTEXA
) elfexd
,
1280 &Logfont
.elfEnumLogfontEx
);
1282 RtlCopyMemory( &Logfont
.elfDesignVector
,
1283 (PVOID
) &elfexd
->elfDesignVector
,
1284 sizeof(DESIGNVECTOR
));
1286 return NtGdiHfontCreate( &Logfont
, 0, 0, 0, NULL
);
1297 CreateFontIndirectExW(const ENUMLOGFONTEXDVW
*elfexd
)
1299 /* Msdn: Note, this function ignores the elfDesignVector member in
1304 return NtGdiHfontCreate((PENUMLOGFONTEXDVW
) elfexd
, 0, 0, 0, NULL
);
1315 CreateFontIndirectA(
1316 CONST LOGFONTA
*lplf
1323 LogFontA2W(&tlf
, lplf
);
1324 return CreateFontIndirectW(&tlf
);
1335 CreateFontIndirectW(
1336 CONST LOGFONTW
*lplf
1341 ENUMLOGFONTEXDVW Logfont
;
1343 RtlCopyMemory( &Logfont
.elfEnumLogfontEx
.elfLogFont
, lplf
, sizeof(LOGFONTW
));
1344 // Need something other than just cleaning memory here.
1345 // Guess? Use caller data to determine the rest.
1346 RtlZeroMemory( &Logfont
.elfEnumLogfontEx
.elfFullName
,
1347 sizeof(Logfont
.elfEnumLogfontEx
.elfFullName
));
1348 RtlZeroMemory( &Logfont
.elfEnumLogfontEx
.elfStyle
,
1349 sizeof(Logfont
.elfEnumLogfontEx
.elfStyle
));
1350 RtlZeroMemory( &Logfont
.elfEnumLogfontEx
.elfScript
,
1351 sizeof(Logfont
.elfEnumLogfontEx
.elfScript
));
1353 Logfont
.elfDesignVector
.dvNumAxes
= 0; // No more than MM_MAX_NUMAXES
1355 RtlZeroMemory( &Logfont
.elfDesignVector
, sizeof(DESIGNVECTOR
));
1357 return CreateFontIndirectExW(&Logfont
);
1378 DWORD fdwOutputPrecision
,
1379 DWORD fdwClipPrecision
,
1381 DWORD fdwPitchAndFamily
,
1385 ANSI_STRING StringA
;
1386 UNICODE_STRING StringU
;
1389 RtlInitAnsiString(&StringA
, (LPSTR
)lpszFace
);
1390 RtlAnsiStringToUnicodeString(&StringU
, &StringA
, TRUE
);
1392 ret
= CreateFontW(nHeight
,
1407 RtlFreeUnicodeString(&StringU
);
1428 DWORD fdwOutputPrecision
,
1429 DWORD fdwClipPrecision
,
1431 DWORD fdwPitchAndFamily
,
1437 logfont
.lfHeight
= nHeight
;
1438 logfont
.lfWidth
= nWidth
;
1439 logfont
.lfEscapement
= nEscapement
;
1440 logfont
.lfOrientation
= nOrientation
;
1441 logfont
.lfWeight
= nWeight
;
1442 logfont
.lfItalic
= fnItalic
;
1443 logfont
.lfUnderline
= fdwUnderline
;
1444 logfont
.lfStrikeOut
= fdwStrikeOut
;
1445 logfont
.lfCharSet
= fdwCharSet
;
1446 logfont
.lfOutPrecision
= fdwOutputPrecision
;
1447 logfont
.lfClipPrecision
= fdwClipPrecision
;
1448 logfont
.lfQuality
= fdwQuality
;
1449 logfont
.lfPitchAndFamily
= fdwPitchAndFamily
;
1451 if (NULL
!= lpszFace
)
1453 int Size
= sizeof(logfont
.lfFaceName
) / sizeof(WCHAR
);
1454 wcsncpy((wchar_t *)logfont
.lfFaceName
, lpszFace
, Size
- 1);
1455 /* Be 101% sure to have '\0' at end of string */
1456 logfont
.lfFaceName
[Size
- 1] = '\0';
1460 logfont
.lfFaceName
[0] = L
'\0';
1463 return CreateFontIndirectW(&logfont
);
1472 CreateScalableFontResourceA(
1475 LPCSTR lpszFontFile
,
1476 LPCSTR lpszCurrentPath
1488 AddFontResourceExW ( LPCWSTR lpszFilename
, DWORD fl
, PVOID pvReserved
)
1490 if (fl
& ~(FR_PRIVATE
| FR_NOT_ENUM
))
1492 SetLastError( ERROR_INVALID_PARAMETER
);
1496 return GdiAddFontResourceW(lpszFilename
, fl
,0);
1505 AddFontResourceExA ( LPCSTR lpszFilename
, DWORD fl
, PVOID pvReserved
)
1511 if (fl
& ~(FR_PRIVATE
| FR_NOT_ENUM
))
1513 SetLastError( ERROR_INVALID_PARAMETER
);
1517 Status
= HEAP_strdupA2W ( &FilenameW
, lpszFilename
);
1518 if ( !NT_SUCCESS (Status
) )
1520 SetLastError (RtlNtStatusToDosError(Status
));
1524 rc
= GdiAddFontResourceW ( FilenameW
, fl
, 0 );
1525 HEAP_free ( FilenameW
);
1535 AddFontResourceA ( LPCSTR lpszFilename
)
1541 Status
= HEAP_strdupA2W ( &FilenameW
, lpszFilename
);
1542 if ( !NT_SUCCESS (Status
) )
1544 SetLastError (RtlNtStatusToDosError(Status
));
1548 rc
= GdiAddFontResourceW ( FilenameW
, 0, 0);
1550 HEAP_free ( FilenameW
);
1561 AddFontResourceW ( LPCWSTR lpszFilename
)
1563 return GdiAddFontResourceW ( lpszFilename
, 0, 0 );
1572 RemoveFontResourceW(LPCWSTR lpFileName
)
1574 return RemoveFontResourceExW(lpFileName
,0,0);
1583 RemoveFontResourceA(LPCSTR lpFileName
)
1585 return RemoveFontResourceExA(lpFileName
,0,0);
1593 RemoveFontResourceExA(LPCSTR lpFileName
,
1601 /* FIXME the flags */
1603 /* FIXME NtGdiRemoveFontResource handle flags and pdv */
1605 Status
= HEAP_strdupA2W ( &lpFileNameW
, lpFileName
);
1606 if (!NT_SUCCESS (Status
))
1607 SetLastError (RtlNtStatusToDosError(Status
));
1611 HEAP_free ( lpFileNameW
);
1622 RemoveFontResourceExW(LPCWSTR lpFileName
,
1626 /* FIXME the flags */
1628 /* FIXME NtGdiRemoveFontResource handle flags and pdv */
1633 /***********************************************************************
1634 * GdiGetCharDimensions
1636 * Gets the average width of the characters in the English alphabet.
1639 * hdc [I] Handle to the device context to measure on.
1640 * lptm [O] Pointer to memory to store the text metrics into.
1641 * height [O] On exit, the maximum height of characters in the English alphabet.
1644 * The average width of characters in the English alphabet.
1647 * This function is used by the dialog manager to get the size of a dialog
1648 * unit. It should also be used by other pieces of code that need to know
1649 * the size of a dialog unit in logical units without having access to the
1650 * window handle of the dialog.
1651 * Windows caches the font metrics from this function, but we don't and
1652 * there doesn't appear to be an immediate advantage to do so.
1655 * GetTextExtentPointW, GetTextMetricsW, MapDialogRect.
1657 * Despite most of MSDN insisting that the horizontal base unit is
1658 * tmAveCharWidth it isn't. Knowledge base article Q145994
1659 * "HOWTO: Calculate Dialog Units When Not Using the System Font",
1660 * says that we should take the average of the 52 English upper and lower
1668 GdiGetCharDimensions(HDC hdc
, LPTEXTMETRICW lptm
, LONG
*height
)
1672 static const WCHAR alphabet
[] = {
1673 'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q',
1674 'r','s','t','u','v','w','x','y','z','A','B','C','D','E','F','G','H',
1675 'I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z',0};
1677 if(!GetTextMetricsW(hdc
, &tm
)) return 0;
1679 if(!GetTextExtentPointW(hdc
, alphabet
, 52, &sz
)) return 0;
1681 if (lptm
) *lptm
= tm
;
1682 if (height
) *height
= tm
.tmHeight
;
1684 return (sz
.cx
/ 26 + 1) / 2;
1687 /*************************************************************************
1688 * TranslateCharsetInfo [GDI32.@]
1690 * Fills a CHARSETINFO structure for a character set, code page, or
1691 * font. This allows making the correspondance between different labelings
1692 * (character set, Windows, ANSI, and OEM codepages, and Unicode ranges)
1693 * of the same encoding.
1695 * Only one codepage will be set in lpCs->fs. If TCI_SRCFONTSIG is used,
1696 * only one codepage should be set in *lpSrc.
1699 * TRUE on success, FALSE on failure.
1707 TranslateCharsetInfo(
1708 LPDWORD lpSrc
, /* [in]
1709 if flags == TCI_SRCFONTSIG: pointer to fsCsb of a FONTSIGNATURE
1710 if flags == TCI_SRCCHARSET: a character set value
1711 if flags == TCI_SRCCODEPAGE: a code page value
1713 LPCHARSETINFO lpCs
, /* [out] structure to receive charset information */
1714 DWORD flags
/* [in] determines interpretation of lpSrc */)
1718 case TCI_SRCFONTSIG
:
1719 while (!(*lpSrc
>>index
& 0x0001) && index
<MAXTCIINDEX
) index
++;
1721 case TCI_SRCCODEPAGE
:
1722 while (PtrToUlong(lpSrc
) != FONT_tci
[index
].ciACP
&& index
< MAXTCIINDEX
) index
++;
1724 case TCI_SRCCHARSET
:
1725 while (PtrToUlong(lpSrc
) != FONT_tci
[index
].ciCharset
&& index
< MAXTCIINDEX
) index
++;
1730 if (index
>= MAXTCIINDEX
|| FONT_tci
[index
].ciCharset
== DEFAULT_CHARSET
) return FALSE
;
1731 memcpy(lpCs
, &FONT_tci
[index
], sizeof(CHARSETINFO
));
1746 DWORD Ret
= GDI_ERROR
;
1749 if (GDI_HANDLE_GET_TYPE(hDC
) != GDI_OBJECT_TYPE_DC
)
1751 if (GDI_HANDLE_GET_TYPE(hDC
) == GDI_OBJECT_TYPE_METADC
)
1752 return MFDRV_SetMapperFlags( hDC
, flags
);
1755 PLDC pLDC
= Dc_Attr
->pvLDC
;
1758 SetLastError(ERROR_INVALID_HANDLE
);
1761 if (pLDC
->iType
== LDC_EMFLDC
)
1763 return EMFDRV_SetMapperFlags( hDC
, flags
);
1768 if (!GdiGetHandleUserData((HGDIOBJ
) hDC
, GDI_OBJECT_TYPE_DC
, (PVOID
) &Dc_Attr
)) return GDI_ERROR
;
1770 if (NtCurrentTeb()->GdiTebBatch
.HDC
== hDC
)
1772 if (Dc_Attr
->ulDirty_
& DC_FONTTEXT_DIRTY
)
1775 Dc_Attr
->ulDirty_
&= ~(DC_MODE_DIRTY
|DC_FONTTEXT_DIRTY
);
1780 SetLastError(ERROR_INVALID_PARAMETER
);
1783 Ret
= Dc_Attr
->flFontMapper
;
1784 Dc_Attr
->flFontMapper
= flags
;
1798 FONTENUMPROCW FontFunc
,
1803 return NtGdiEnumFonts ( hDC
, lpFaceName
, FontFunc
, lParam
);
1805 return EnumFontFamiliesW( hDC
, lpFaceName
, FontFunc
, lParam
);
1817 FONTENUMPROCA FontFunc
,
1826 Status
= HEAP_strdupA2W ( &lpFaceNameW
, lpFaceName
);
1827 if (!NT_SUCCESS (Status
))
1828 SetLastError (RtlNtStatusToDosError(Status
));
1831 rc
= NtGdiEnumFonts ( hDC
, lpFaceNameW
, FontFunc
, lParam
);
1833 HEAP_free ( lpFaceNameW
);
1837 return EnumFontFamiliesA( hDC
, lpFaceName
, FontFunc
, lParam
);
1841 #define EfdFontFamilies 3
1845 NewEnumFontFamiliesExW(
1847 LPLOGFONTW lpLogfont
,
1848 FONTENUMPROCW lpEnumFontFamExProcW
,
1852 ULONG_PTR idEnum
, cbDataSize
, cbRetSize
;
1853 PENUMFONTDATAW pEfdw
;
1858 /* Open enumeration handle and find out how much memory we need */
1859 idEnum
= NtGdiEnumFontOpen(hDC
,
1863 (lpLogfont
&& lpLogfont
->lfFaceName
[0])? lpLogfont
->lfFaceName
: NULL
,
1864 lpLogfont
? lpLogfont
->lfCharSet
: DEFAULT_CHARSET
,
1870 if (cbDataSize
== 0)
1872 NtGdiEnumFontClose(idEnum
);
1876 /* Allocate memory */
1877 pBuffer
= HeapAlloc(GetProcessHeap(), 0, cbDataSize
);
1878 if (pBuffer
== NULL
)
1880 SetLastError(ERROR_NOT_ENOUGH_MEMORY
);
1881 NtGdiEnumFontClose(idEnum
);
1885 /* Do the enumeration */
1886 if (!NtGdiEnumFontChunk(hDC
, idEnum
, cbDataSize
, &cbRetSize
, (PVOID
)pBuffer
))
1888 HeapFree(GetProcessHeap(), 0, pBuffer
);
1889 NtGdiEnumFontClose(idEnum
);
1893 /* Get start and end address */
1894 pEfdw
= (PENUMFONTDATAW
)pBuffer
;
1895 pMax
= pBuffer
+ cbDataSize
;
1897 /* Iterate through the structures */
1898 while ((PBYTE
)pEfdw
< pMax
&& ret
)
1900 PNTMW_INTERNAL pNtmwi
= (PNTMW_INTERNAL
)((ULONG_PTR
)pEfdw
+ pEfdw
->ulNtmwiOffset
);
1902 ret
= lpEnumFontFamExProcW((VOID
*)&pEfdw
->elfexdv
.elfEnumLogfontEx
,
1903 (VOID
*)&pNtmwi
->ntmw
,
1907 pEfdw
= (PENUMFONTDATAW
)((ULONG_PTR
)pEfdw
+ pEfdw
->cbSize
);
1910 /* Release the memory and close handle */
1911 HeapFree(GetProcessHeap(), 0, pBuffer
);
1912 NtGdiEnumFontClose(idEnum
);