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
);
923 Ret
= NtGdiGetGlyphIndicesW(hdc
, lpstrW
, countW
, pgi
, flags
);
924 HeapFree(GetProcessHeap(), 0, lpstrW
);
947 DPRINT("GetGlyphOutlineA uChar %x\n", uChar
);
948 if (!lpgm
|| !lpmat2
) return GDI_ERROR
;
949 if(!(uFormat
& GGO_GLYPH_INDEX
)) {
952 if(uChar
> 0xff) { /* but, 2 bytes character only */
954 mbchs
[0] = (uChar
& 0xff00) >> 8;
955 mbchs
[1] = (uChar
& 0xff);
958 mbchs
[0] = (uChar
& 0xff);
960 p
= FONT_mbtowc(hdc
, mbchs
, len
, NULL
, NULL
);
964 ret
= NtGdiGetGlyphOutline(hdc
, c
, uFormat
, lpgm
, cbBuffer
, lpvBuffer
, (CONST LPMAT2
)lpmat2
, TRUE
);
965 HeapFree(GetProcessHeap(), 0, p
);
985 DPRINT("GetGlyphOutlineW uChar %x\n", uChar
);
986 if (!lpgm
|| !lpmat2
) return GDI_ERROR
;
987 if (!lpvBuffer
) cbBuffer
= 0;
988 return NtGdiGetGlyphOutline ( hdc
, uChar
, uFormat
, lpgm
, cbBuffer
, lpvBuffer
, (CONST LPMAT2
)lpmat2
, TRUE
);
997 GetOutlineTextMetricsA(
1000 LPOUTLINETEXTMETRICA lpOTM
1003 char buf
[512], *ptr
;
1005 OUTLINETEXTMETRICW
*lpOTMW
= (OUTLINETEXTMETRICW
*)buf
;
1006 OUTLINETEXTMETRICA
*output
= lpOTM
;
1009 if((ret
= GetOutlineTextMetricsW(hdc
, 0, NULL
)) == 0)
1011 if(ret
> sizeof(buf
))
1013 lpOTMW
= HeapAlloc(GetProcessHeap(), 0, ret
);
1019 GetOutlineTextMetricsW(hdc
, ret
, lpOTMW
);
1021 needed
= sizeof(OUTLINETEXTMETRICA
);
1022 if(lpOTMW
->otmpFamilyName
)
1023 needed
+= WideCharToMultiByte(CP_ACP
, 0,
1024 (WCHAR
*)((char*)lpOTMW
+ (ptrdiff_t)lpOTMW
->otmpFamilyName
), -1,
1025 NULL
, 0, NULL
, NULL
);
1026 if(lpOTMW
->otmpFaceName
)
1027 needed
+= WideCharToMultiByte(CP_ACP
, 0,
1028 (WCHAR
*)((char*)lpOTMW
+ (ptrdiff_t)lpOTMW
->otmpFaceName
), -1,
1029 NULL
, 0, NULL
, NULL
);
1030 if(lpOTMW
->otmpStyleName
)
1031 needed
+= WideCharToMultiByte(CP_ACP
, 0,
1032 (WCHAR
*)((char*)lpOTMW
+ (ptrdiff_t)lpOTMW
->otmpStyleName
), -1,
1033 NULL
, 0, NULL
, NULL
);
1034 if(lpOTMW
->otmpFullName
)
1035 needed
+= WideCharToMultiByte(CP_ACP
, 0,
1036 (WCHAR
*)((char*)lpOTMW
+ (ptrdiff_t)lpOTMW
->otmpFullName
), -1,
1037 NULL
, 0, NULL
, NULL
);
1044 DPRINT("needed = %d\n", needed
);
1047 /* Since the supplied buffer isn't big enough, we'll alloc one
1048 that is and memcpy the first cbData bytes into the lpOTM at
1050 output
= HeapAlloc(GetProcessHeap(), 0, needed
);
1057 ret
= output
->otmSize
= min(needed
, cbData
);
1058 FONT_TextMetricWToA( &lpOTMW
->otmTextMetrics
, &output
->otmTextMetrics
);
1059 output
->otmFiller
= 0;
1060 output
->otmPanoseNumber
= lpOTMW
->otmPanoseNumber
;
1061 output
->otmfsSelection
= lpOTMW
->otmfsSelection
;
1062 output
->otmfsType
= lpOTMW
->otmfsType
;
1063 output
->otmsCharSlopeRise
= lpOTMW
->otmsCharSlopeRise
;
1064 output
->otmsCharSlopeRun
= lpOTMW
->otmsCharSlopeRun
;
1065 output
->otmItalicAngle
= lpOTMW
->otmItalicAngle
;
1066 output
->otmEMSquare
= lpOTMW
->otmEMSquare
;
1067 output
->otmAscent
= lpOTMW
->otmAscent
;
1068 output
->otmDescent
= lpOTMW
->otmDescent
;
1069 output
->otmLineGap
= lpOTMW
->otmLineGap
;
1070 output
->otmsCapEmHeight
= lpOTMW
->otmsCapEmHeight
;
1071 output
->otmsXHeight
= lpOTMW
->otmsXHeight
;
1072 output
->otmrcFontBox
= lpOTMW
->otmrcFontBox
;
1073 output
->otmMacAscent
= lpOTMW
->otmMacAscent
;
1074 output
->otmMacDescent
= lpOTMW
->otmMacDescent
;
1075 output
->otmMacLineGap
= lpOTMW
->otmMacLineGap
;
1076 output
->otmusMinimumPPEM
= lpOTMW
->otmusMinimumPPEM
;
1077 output
->otmptSubscriptSize
= lpOTMW
->otmptSubscriptSize
;
1078 output
->otmptSubscriptOffset
= lpOTMW
->otmptSubscriptOffset
;
1079 output
->otmptSuperscriptSize
= lpOTMW
->otmptSuperscriptSize
;
1080 output
->otmptSuperscriptOffset
= lpOTMW
->otmptSuperscriptOffset
;
1081 output
->otmsStrikeoutSize
= lpOTMW
->otmsStrikeoutSize
;
1082 output
->otmsStrikeoutPosition
= lpOTMW
->otmsStrikeoutPosition
;
1083 output
->otmsUnderscoreSize
= lpOTMW
->otmsUnderscoreSize
;
1084 output
->otmsUnderscorePosition
= lpOTMW
->otmsUnderscorePosition
;
1087 ptr
= (char*)(output
+ 1);
1088 left
= needed
- sizeof(*output
);
1090 if(lpOTMW
->otmpFamilyName
) {
1091 output
->otmpFamilyName
= (LPSTR
)(ptr
- (char*)output
);
1092 len
= WideCharToMultiByte(CP_ACP
, 0,
1093 (WCHAR
*)((char*)lpOTMW
+ (ptrdiff_t)lpOTMW
->otmpFamilyName
), -1,
1094 ptr
, left
, NULL
, NULL
);
1098 output
->otmpFamilyName
= 0;
1100 if(lpOTMW
->otmpFaceName
) {
1101 output
->otmpFaceName
= (LPSTR
)(ptr
- (char*)output
);
1102 len
= WideCharToMultiByte(CP_ACP
, 0,
1103 (WCHAR
*)((char*)lpOTMW
+ (ptrdiff_t)lpOTMW
->otmpFaceName
), -1,
1104 ptr
, left
, NULL
, NULL
);
1108 output
->otmpFaceName
= 0;
1110 if(lpOTMW
->otmpStyleName
) {
1111 output
->otmpStyleName
= (LPSTR
)(ptr
- (char*)output
);
1112 len
= WideCharToMultiByte(CP_ACP
, 0,
1113 (WCHAR
*)((char*)lpOTMW
+ (ptrdiff_t)lpOTMW
->otmpStyleName
), -1,
1114 ptr
, left
, NULL
, NULL
);
1118 output
->otmpStyleName
= 0;
1120 if(lpOTMW
->otmpFullName
) {
1121 output
->otmpFullName
= (LPSTR
)(ptr
- (char*)output
);
1122 len
= WideCharToMultiByte(CP_ACP
, 0,
1123 (WCHAR
*)((char*)lpOTMW
+ (ptrdiff_t)lpOTMW
->otmpFullName
), -1,
1124 ptr
, left
, NULL
, NULL
);
1127 output
->otmpFullName
= 0;
1131 if(output
!= lpOTM
) {
1132 memcpy(lpOTM
, output
, cbData
);
1133 HeapFree(GetProcessHeap(), 0, output
);
1135 /* check if the string offsets really fit into the provided size */
1136 /* FIXME: should we check string length as well? */
1137 if ((UINT_PTR
)lpOTM
->otmpFamilyName
>= lpOTM
->otmSize
)
1138 lpOTM
->otmpFamilyName
= 0; /* doesn't fit */
1140 if ((UINT_PTR
)lpOTM
->otmpFaceName
>= lpOTM
->otmSize
)
1141 lpOTM
->otmpFaceName
= 0; /* doesn't fit */
1143 if ((UINT_PTR
)lpOTM
->otmpStyleName
>= lpOTM
->otmSize
)
1144 lpOTM
->otmpStyleName
= 0; /* doesn't fit */
1146 if ((UINT_PTR
)lpOTM
->otmpFullName
>= lpOTM
->otmSize
)
1147 lpOTM
->otmpFullName
= 0; /* doesn't fit */
1151 if(lpOTMW
!= (OUTLINETEXTMETRICW
*)buf
)
1152 HeapFree(GetProcessHeap(), 0, lpOTMW
);
1163 GetOutlineTextMetricsW(
1166 LPOUTLINETEXTMETRICW lpOTM
1169 TMDIFF Tmd
; // Should not be zero.
1171 return NtGdiGetOutlineTextMetricsInternalW(hdc
, cbData
, lpOTM
, &Tmd
);
1179 GetKerningPairsW(HDC hdc
,
1181 LPKERNINGPAIR pkpDst
)
1183 if ((cPairs
!= 0) || (pkpDst
== 0))
1185 return NtGdiGetKerningPairs(hdc
,cPairs
,pkpDst
);
1189 SetLastError(ERROR_INVALID_PARAMETER
);
1199 GetKerningPairsA( HDC hDC
,
1201 LPKERNINGPAIR kern_pairA
)
1206 DWORD i
, total_kern_pairs
, kern_pairs_copied
= 0;
1207 KERNINGPAIR
*kern_pairW
;
1209 if (!cPairs
&& kern_pairA
)
1211 SetLastError(ERROR_INVALID_PARAMETER
);
1215 charset
= GetTextCharset(hDC
);
1216 if (!TranslateCharsetInfo(ULongToPtr(charset
), &csi
, TCI_SRCCHARSET
))
1218 DPRINT1("Can't find codepage for charset %d\n", charset
);
1221 /* GetCPInfo() will fail on CP_SYMBOL, and WideCharToMultiByte is supposed
1222 * to fail on an invalid character for CP_SYMBOL.
1224 cpi
.DefaultChar
[0] = 0;
1225 if (csi
.ciACP
!= CP_SYMBOL
&& !GetCPInfo(csi
.ciACP
, &cpi
))
1227 DPRINT1("Can't find codepage %u info\n", csi
.ciACP
);
1230 DPRINT("charset %d => codepage %u\n", charset
, csi
.ciACP
);
1232 total_kern_pairs
= NtGdiGetKerningPairs(hDC
, 0, NULL
);
1233 if (!total_kern_pairs
) return 0;
1235 if (!cPairs
&& !kern_pairA
) return total_kern_pairs
;
1237 kern_pairW
= HeapAlloc(GetProcessHeap(), 0, total_kern_pairs
* sizeof(*kern_pairW
));
1238 if (kern_pairW
== NULL
)
1242 GetKerningPairsW(hDC
, total_kern_pairs
, kern_pairW
);
1244 for (i
= 0; i
< total_kern_pairs
; i
++)
1248 if (!WideCharToMultiByte(csi
.ciACP
, 0, &kern_pairW
[i
].wFirst
, 1, &first
, 1, NULL
, NULL
))
1251 if (!WideCharToMultiByte(csi
.ciACP
, 0, &kern_pairW
[i
].wSecond
, 1, &second
, 1, NULL
, NULL
))
1254 if (first
== cpi
.DefaultChar
[0] || second
== cpi
.DefaultChar
[0])
1259 if (kern_pairs_copied
>= cPairs
) break;
1261 kern_pairA
->wFirst
= (BYTE
)first
;
1262 kern_pairA
->wSecond
= (BYTE
)second
;
1263 kern_pairA
->iKernAmount
= kern_pairW
[i
].iKernAmount
;
1266 kern_pairs_copied
++;
1269 HeapFree(GetProcessHeap(), 0, kern_pairW
);
1271 return kern_pairs_copied
;
1281 CreateFontIndirectExA(const ENUMLOGFONTEXDVA
*elfexd
)
1285 ENUMLOGFONTEXDVW Logfont
;
1287 EnumLogFontExW2A( (LPENUMLOGFONTEXA
) elfexd
,
1288 &Logfont
.elfEnumLogfontEx
);
1290 RtlCopyMemory( &Logfont
.elfDesignVector
,
1291 (PVOID
) &elfexd
->elfDesignVector
,
1292 sizeof(DESIGNVECTOR
));
1294 return NtGdiHfontCreate( &Logfont
, 0, 0, 0, NULL
);
1305 CreateFontIndirectExW(const ENUMLOGFONTEXDVW
*elfexd
)
1307 /* Msdn: Note, this function ignores the elfDesignVector member in
1312 return NtGdiHfontCreate((PENUMLOGFONTEXDVW
) elfexd
, 0, 0, 0, NULL
);
1323 CreateFontIndirectA(
1324 CONST LOGFONTA
*lplf
1331 LogFontA2W(&tlf
, lplf
);
1332 return CreateFontIndirectW(&tlf
);
1343 CreateFontIndirectW(
1344 CONST LOGFONTW
*lplf
1349 ENUMLOGFONTEXDVW Logfont
;
1351 RtlCopyMemory( &Logfont
.elfEnumLogfontEx
.elfLogFont
, lplf
, sizeof(LOGFONTW
));
1352 // Need something other than just cleaning memory here.
1353 // Guess? Use caller data to determine the rest.
1354 RtlZeroMemory( &Logfont
.elfEnumLogfontEx
.elfFullName
,
1355 sizeof(Logfont
.elfEnumLogfontEx
.elfFullName
));
1356 RtlZeroMemory( &Logfont
.elfEnumLogfontEx
.elfStyle
,
1357 sizeof(Logfont
.elfEnumLogfontEx
.elfStyle
));
1358 RtlZeroMemory( &Logfont
.elfEnumLogfontEx
.elfScript
,
1359 sizeof(Logfont
.elfEnumLogfontEx
.elfScript
));
1361 Logfont
.elfDesignVector
.dvNumAxes
= 0; // No more than MM_MAX_NUMAXES
1363 RtlZeroMemory( &Logfont
.elfDesignVector
, sizeof(DESIGNVECTOR
));
1365 return CreateFontIndirectExW(&Logfont
);
1386 DWORD fdwOutputPrecision
,
1387 DWORD fdwClipPrecision
,
1389 DWORD fdwPitchAndFamily
,
1393 ANSI_STRING StringA
;
1394 UNICODE_STRING StringU
;
1397 RtlInitAnsiString(&StringA
, (LPSTR
)lpszFace
);
1398 RtlAnsiStringToUnicodeString(&StringU
, &StringA
, TRUE
);
1400 ret
= CreateFontW(nHeight
,
1415 RtlFreeUnicodeString(&StringU
);
1436 DWORD fdwOutputPrecision
,
1437 DWORD fdwClipPrecision
,
1439 DWORD fdwPitchAndFamily
,
1445 logfont
.lfHeight
= nHeight
;
1446 logfont
.lfWidth
= nWidth
;
1447 logfont
.lfEscapement
= nEscapement
;
1448 logfont
.lfOrientation
= nOrientation
;
1449 logfont
.lfWeight
= nWeight
;
1450 logfont
.lfItalic
= fnItalic
;
1451 logfont
.lfUnderline
= fdwUnderline
;
1452 logfont
.lfStrikeOut
= fdwStrikeOut
;
1453 logfont
.lfCharSet
= fdwCharSet
;
1454 logfont
.lfOutPrecision
= fdwOutputPrecision
;
1455 logfont
.lfClipPrecision
= fdwClipPrecision
;
1456 logfont
.lfQuality
= fdwQuality
;
1457 logfont
.lfPitchAndFamily
= fdwPitchAndFamily
;
1459 if (NULL
!= lpszFace
)
1461 int Size
= sizeof(logfont
.lfFaceName
) / sizeof(WCHAR
);
1462 wcsncpy((wchar_t *)logfont
.lfFaceName
, lpszFace
, Size
- 1);
1463 /* Be 101% sure to have '\0' at end of string */
1464 logfont
.lfFaceName
[Size
- 1] = '\0';
1468 logfont
.lfFaceName
[0] = L
'\0';
1471 return CreateFontIndirectW(&logfont
);
1480 CreateScalableFontResourceA(
1483 LPCSTR lpszFontFile
,
1484 LPCSTR lpszCurrentPath
1496 AddFontResourceExW ( LPCWSTR lpszFilename
, DWORD fl
, PVOID pvReserved
)
1498 if (fl
& ~(FR_PRIVATE
| FR_NOT_ENUM
))
1500 SetLastError( ERROR_INVALID_PARAMETER
);
1504 return GdiAddFontResourceW(lpszFilename
, fl
,0);
1513 AddFontResourceExA ( LPCSTR lpszFilename
, DWORD fl
, PVOID pvReserved
)
1519 if (fl
& ~(FR_PRIVATE
| FR_NOT_ENUM
))
1521 SetLastError( ERROR_INVALID_PARAMETER
);
1525 Status
= HEAP_strdupA2W ( &FilenameW
, lpszFilename
);
1526 if ( !NT_SUCCESS (Status
) )
1528 SetLastError (RtlNtStatusToDosError(Status
));
1532 rc
= GdiAddFontResourceW ( FilenameW
, fl
, 0 );
1533 HEAP_free ( FilenameW
);
1543 AddFontResourceA ( LPCSTR lpszFilename
)
1549 Status
= HEAP_strdupA2W ( &FilenameW
, lpszFilename
);
1550 if ( !NT_SUCCESS (Status
) )
1552 SetLastError (RtlNtStatusToDosError(Status
));
1556 rc
= GdiAddFontResourceW ( FilenameW
, 0, 0);
1558 HEAP_free ( FilenameW
);
1569 AddFontResourceW ( LPCWSTR lpszFilename
)
1571 return GdiAddFontResourceW ( lpszFilename
, 0, 0 );
1580 RemoveFontResourceW(LPCWSTR lpFileName
)
1582 return RemoveFontResourceExW(lpFileName
,0,0);
1591 RemoveFontResourceA(LPCSTR lpFileName
)
1593 return RemoveFontResourceExA(lpFileName
,0,0);
1601 RemoveFontResourceExA(LPCSTR lpFileName
,
1609 /* FIXME the flags */
1611 /* FIXME NtGdiRemoveFontResource handle flags and pdv */
1613 Status
= HEAP_strdupA2W ( &lpFileNameW
, lpFileName
);
1614 if (!NT_SUCCESS (Status
))
1615 SetLastError (RtlNtStatusToDosError(Status
));
1619 HEAP_free ( lpFileNameW
);
1630 RemoveFontResourceExW(LPCWSTR lpFileName
,
1634 /* FIXME the flags */
1636 /* FIXME NtGdiRemoveFontResource handle flags and pdv */
1641 /***********************************************************************
1642 * GdiGetCharDimensions
1644 * Gets the average width of the characters in the English alphabet.
1647 * hdc [I] Handle to the device context to measure on.
1648 * lptm [O] Pointer to memory to store the text metrics into.
1649 * height [O] On exit, the maximum height of characters in the English alphabet.
1652 * The average width of characters in the English alphabet.
1655 * This function is used by the dialog manager to get the size of a dialog
1656 * unit. It should also be used by other pieces of code that need to know
1657 * the size of a dialog unit in logical units without having access to the
1658 * window handle of the dialog.
1659 * Windows caches the font metrics from this function, but we don't and
1660 * there doesn't appear to be an immediate advantage to do so.
1663 * GetTextExtentPointW, GetTextMetricsW, MapDialogRect.
1665 * Despite most of MSDN insisting that the horizontal base unit is
1666 * tmAveCharWidth it isn't. Knowledge base article Q145994
1667 * "HOWTO: Calculate Dialog Units When Not Using the System Font",
1668 * says that we should take the average of the 52 English upper and lower
1676 GdiGetCharDimensions(HDC hdc
, LPTEXTMETRICW lptm
, LONG
*height
)
1680 static const WCHAR alphabet
[] = {
1681 'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q',
1682 'r','s','t','u','v','w','x','y','z','A','B','C','D','E','F','G','H',
1683 'I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z',0};
1685 if(!GetTextMetricsW(hdc
, &tm
)) return 0;
1687 if(!GetTextExtentPointW(hdc
, alphabet
, 52, &sz
)) return 0;
1689 if (lptm
) *lptm
= tm
;
1690 if (height
) *height
= tm
.tmHeight
;
1692 return (sz
.cx
/ 26 + 1) / 2;
1695 /*************************************************************************
1696 * TranslateCharsetInfo [GDI32.@]
1698 * Fills a CHARSETINFO structure for a character set, code page, or
1699 * font. This allows making the correspondance between different labelings
1700 * (character set, Windows, ANSI, and OEM codepages, and Unicode ranges)
1701 * of the same encoding.
1703 * Only one codepage will be set in lpCs->fs. If TCI_SRCFONTSIG is used,
1704 * only one codepage should be set in *lpSrc.
1707 * TRUE on success, FALSE on failure.
1715 TranslateCharsetInfo(
1716 LPDWORD lpSrc
, /* [in]
1717 if flags == TCI_SRCFONTSIG: pointer to fsCsb of a FONTSIGNATURE
1718 if flags == TCI_SRCCHARSET: a character set value
1719 if flags == TCI_SRCCODEPAGE: a code page value
1721 LPCHARSETINFO lpCs
, /* [out] structure to receive charset information */
1722 DWORD flags
/* [in] determines interpretation of lpSrc */)
1726 case TCI_SRCFONTSIG
:
1727 while (index
< MAXTCIINDEX
&& !(*lpSrc
>>index
& 0x0001)) index
++;
1729 case TCI_SRCCODEPAGE
:
1730 while (index
< MAXTCIINDEX
&& PtrToUlong(lpSrc
) != FONT_tci
[index
].ciACP
) index
++;
1732 case TCI_SRCCHARSET
:
1733 while (index
< MAXTCIINDEX
&& PtrToUlong(lpSrc
) != FONT_tci
[index
].ciCharset
) index
++;
1738 if (index
>= MAXTCIINDEX
|| FONT_tci
[index
].ciCharset
== DEFAULT_CHARSET
) return FALSE
;
1739 memcpy(lpCs
, &FONT_tci
[index
], sizeof(CHARSETINFO
));
1754 DWORD Ret
= GDI_ERROR
;
1757 if (GDI_HANDLE_GET_TYPE(hDC
) != GDI_OBJECT_TYPE_DC
)
1759 if (GDI_HANDLE_GET_TYPE(hDC
) == GDI_OBJECT_TYPE_METADC
)
1760 return MFDRV_SetMapperFlags( hDC
, flags
);
1763 PLDC pLDC
= Dc_Attr
->pvLDC
;
1766 SetLastError(ERROR_INVALID_HANDLE
);
1769 if (pLDC
->iType
== LDC_EMFLDC
)
1771 return EMFDRV_SetMapperFlags( hDC
, flags
);
1776 if (!GdiGetHandleUserData((HGDIOBJ
) hDC
, GDI_OBJECT_TYPE_DC
, (PVOID
) &Dc_Attr
)) return GDI_ERROR
;
1778 if (NtCurrentTeb()->GdiTebBatch
.HDC
== hDC
)
1780 if (Dc_Attr
->ulDirty_
& DC_FONTTEXT_DIRTY
)
1783 Dc_Attr
->ulDirty_
&= ~(DC_MODE_DIRTY
|DC_FONTTEXT_DIRTY
);
1788 SetLastError(ERROR_INVALID_PARAMETER
);
1791 Ret
= Dc_Attr
->flFontMapper
;
1792 Dc_Attr
->flFontMapper
= flags
;
1806 FONTENUMPROCW FontFunc
,
1811 return NtGdiEnumFonts ( hDC
, lpFaceName
, FontFunc
, lParam
);
1813 return EnumFontFamiliesW( hDC
, lpFaceName
, FontFunc
, lParam
);
1825 FONTENUMPROCA FontFunc
,
1834 Status
= HEAP_strdupA2W ( &lpFaceNameW
, lpFaceName
);
1835 if (!NT_SUCCESS (Status
))
1836 SetLastError (RtlNtStatusToDosError(Status
));
1839 rc
= NtGdiEnumFonts ( hDC
, lpFaceNameW
, FontFunc
, lParam
);
1841 HEAP_free ( lpFaceNameW
);
1845 return EnumFontFamiliesA( hDC
, lpFaceName
, FontFunc
, lParam
);
1849 #define EfdFontFamilies 3
1853 NewEnumFontFamiliesExW(
1855 LPLOGFONTW lpLogfont
,
1856 FONTENUMPROCW lpEnumFontFamExProcW
,
1860 ULONG_PTR idEnum
, cbDataSize
, cbRetSize
;
1861 PENUMFONTDATAW pEfdw
;
1866 /* Open enumeration handle and find out how much memory we need */
1867 idEnum
= NtGdiEnumFontOpen(hDC
,
1871 (lpLogfont
&& lpLogfont
->lfFaceName
[0])? lpLogfont
->lfFaceName
: NULL
,
1872 lpLogfont
? lpLogfont
->lfCharSet
: DEFAULT_CHARSET
,
1878 if (cbDataSize
== 0)
1880 NtGdiEnumFontClose(idEnum
);
1884 /* Allocate memory */
1885 pBuffer
= HeapAlloc(GetProcessHeap(), 0, cbDataSize
);
1886 if (pBuffer
== NULL
)
1888 SetLastError(ERROR_NOT_ENOUGH_MEMORY
);
1889 NtGdiEnumFontClose(idEnum
);
1893 /* Do the enumeration */
1894 if (!NtGdiEnumFontChunk(hDC
, idEnum
, cbDataSize
, &cbRetSize
, (PVOID
)pBuffer
))
1896 HeapFree(GetProcessHeap(), 0, pBuffer
);
1897 NtGdiEnumFontClose(idEnum
);
1901 /* Get start and end address */
1902 pEfdw
= (PENUMFONTDATAW
)pBuffer
;
1903 pMax
= pBuffer
+ cbDataSize
;
1905 /* Iterate through the structures */
1906 while ((PBYTE
)pEfdw
< pMax
&& ret
)
1908 PNTMW_INTERNAL pNtmwi
= (PNTMW_INTERNAL
)((ULONG_PTR
)pEfdw
+ pEfdw
->ulNtmwiOffset
);
1910 ret
= lpEnumFontFamExProcW((VOID
*)&pEfdw
->elfexdv
.elfEnumLogfontEx
,
1911 (VOID
*)&pNtmwi
->ntmw
,
1915 pEfdw
= (PENUMFONTDATAW
)((ULONG_PTR
)pEfdw
+ pEfdw
->cbSize
);
1918 /* Release the memory and close handle */
1919 HeapFree(GetProcessHeap(), 0, pBuffer
);
1920 NtGdiEnumFontClose(idEnum
);