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
;
159 Info
= RtlAllocateHeap(GetProcessHeap(), 0,
160 INITIAL_FAMILY_COUNT
* sizeof(FONTFAMILYINFO
));
168 lfW
.lfCharSet
= DEFAULT_CHARSET
;
169 lfW
.lfPitchAndFamily
= 0;
170 lfW
.lfFaceName
[0] = 0;
174 FontFamilyCount
= NtGdiGetFontFamilyInfo(Dc
, LogFont
, Info
, INITIAL_FAMILY_COUNT
);
175 if (FontFamilyCount
< 0)
177 RtlFreeHeap(GetProcessHeap(), 0, Info
);
180 if (INITIAL_FAMILY_COUNT
< FontFamilyCount
)
182 FontFamilySize
= FontFamilyCount
;
183 RtlFreeHeap(GetProcessHeap(), 0, Info
);
184 Info
= RtlAllocateHeap(GetProcessHeap(), 0,
185 FontFamilyCount
* sizeof(FONTFAMILYINFO
));
190 FontFamilyCount
= NtGdiGetFontFamilyInfo(Dc
, LogFont
, Info
, FontFamilySize
);
191 if (FontFamilyCount
< 0 || FontFamilySize
< FontFamilyCount
)
193 RtlFreeHeap(GetProcessHeap(), 0, Info
);
198 for (i
= 0; i
< FontFamilyCount
; i
++)
202 Ret
= ((FONTENUMPROCW
) EnumProc
)(
203 (VOID
*)&Info
[i
].EnumLogFontEx
,
204 (VOID
*)&Info
[i
].NewTextMetricEx
,
205 Info
[i
].FontType
, lParam
);
208 { // Could use EnumLogFontExW2A here?
209 LogFontW2A(&EnumLogFontExA
.elfLogFont
, &Info
[i
].EnumLogFontEx
.elfLogFont
);
210 WideCharToMultiByte(CP_THREAD_ACP
, 0, Info
[i
].EnumLogFontEx
.elfFullName
, -1,
211 (LPSTR
)EnumLogFontExA
.elfFullName
, LF_FULLFACESIZE
, NULL
, NULL
);
212 WideCharToMultiByte(CP_THREAD_ACP
, 0, Info
[i
].EnumLogFontEx
.elfStyle
, -1,
213 (LPSTR
)EnumLogFontExA
.elfStyle
, LF_FACESIZE
, NULL
, NULL
);
214 WideCharToMultiByte(CP_THREAD_ACP
, 0, Info
[i
].EnumLogFontEx
.elfScript
, -1,
215 (LPSTR
)EnumLogFontExA
.elfScript
, LF_FACESIZE
, NULL
, NULL
);
216 NewTextMetricExW2A(&NewTextMetricExA
,
217 &Info
[i
].NewTextMetricEx
);
218 Ret
= ((FONTENUMPROCA
) EnumProc
)(
219 (VOID
*)&EnumLogFontExA
,
220 (VOID
*)&NewTextMetricExA
,
221 Info
[i
].FontType
, lParam
);
225 RtlFreeHeap(GetProcessHeap(), 0, Info
);
234 EnumFontFamiliesExW(HDC hdc
, LPLOGFONTW lpLogfont
, FONTENUMPROCW lpEnumFontFamExProc
,
235 LPARAM lParam
, DWORD dwFlags
)
237 return IntEnumFontFamilies(hdc
, lpLogfont
, lpEnumFontFamExProc
, lParam
, TRUE
);
245 EnumFontFamiliesW(HDC hdc
, LPCWSTR lpszFamily
, FONTENUMPROCW lpEnumFontFamProc
,
250 ZeroMemory(&LogFont
, sizeof(LOGFONTW
));
251 LogFont
.lfCharSet
= DEFAULT_CHARSET
;
252 if (NULL
!= lpszFamily
)
254 if (!*lpszFamily
) return 1;
255 lstrcpynW(LogFont
.lfFaceName
, lpszFamily
, LF_FACESIZE
);
258 return IntEnumFontFamilies(hdc
, &LogFont
, lpEnumFontFamProc
, lParam
, TRUE
);
266 EnumFontFamiliesExA (HDC hdc
, LPLOGFONTA lpLogfont
, FONTENUMPROCA lpEnumFontFamExProc
,
267 LPARAM lParam
, DWORD dwFlags
)
269 LOGFONTW LogFontW
, *pLogFontW
;
273 LogFontA2W(&LogFontW
,lpLogfont
);
274 pLogFontW
= &LogFontW
;
276 else pLogFontW
= NULL
;
278 /* no need to convert LogFontW back to lpLogFont b/c it's an [in] parameter only */
279 return IntEnumFontFamilies(hdc
, pLogFontW
, lpEnumFontFamExProc
, lParam
, FALSE
);
287 EnumFontFamiliesA(HDC hdc
, LPCSTR lpszFamily
, FONTENUMPROCA lpEnumFontFamProc
,
292 ZeroMemory(&LogFont
, sizeof(LOGFONTW
));
293 LogFont
.lfCharSet
= DEFAULT_CHARSET
;
294 if (NULL
!= lpszFamily
)
296 if (!*lpszFamily
) return 1;
297 MultiByteToWideChar(CP_THREAD_ACP
, 0, lpszFamily
, -1, LogFont
.lfFaceName
, LF_FACESIZE
);
300 return IntEnumFontFamilies(hdc
, &LogFont
, lpEnumFontFamProc
, lParam
, FALSE
);
309 GetCharacterPlacementA(
314 GCP_RESULTSA
*lpResults
,
319 GCP_RESULTSW resultsW
;
323 if ( !lpString
|| uCount
<= 0 || (nMaxExtent
< 0 && nMaxExtent
!= -1 ) )
325 SetLastError(ERROR_INVALID_PARAMETER
);
328 /* TRACE("%s, %d, %d, 0x%08x\n",
329 debugstr_an(lpString, uCount), uCount, nMaxExtent, dwFlags);
331 /* both structs are equal in size */
332 memcpy(&resultsW
, lpResults
, sizeof(resultsW
));
334 lpStringW
= FONT_mbtowc(hdc
, lpString
, uCount
, &uCountW
, &font_cp
);
335 if (lpStringW
== NULL
)
339 if(lpResults
->lpOutString
)
341 resultsW
.lpOutString
= HeapAlloc(GetProcessHeap(), 0, sizeof(WCHAR
)*uCountW
);
342 if (resultsW
.lpOutString
== NULL
)
344 HeapFree(GetProcessHeap(), 0, lpStringW
);
349 ret
= GetCharacterPlacementW(hdc
, lpStringW
, uCountW
, nMaxExtent
, &resultsW
, dwFlags
);
351 lpResults
->nGlyphs
= resultsW
.nGlyphs
;
352 lpResults
->nMaxFit
= resultsW
.nMaxFit
;
354 if(lpResults
->lpOutString
) {
355 WideCharToMultiByte(font_cp
, 0, resultsW
.lpOutString
, uCountW
,
356 lpResults
->lpOutString
, uCount
, NULL
, NULL
);
359 HeapFree(GetProcessHeap(), 0, lpStringW
);
360 HeapFree(GetProcessHeap(), 0, resultsW
.lpOutString
);
371 GetCharacterPlacementW(
376 GCP_RESULTSW
*lpResults
,
383 DPRINT("GetCharacterPlacementW\n");
385 if(dwFlags
&(~GCP_REORDER
)) DPRINT("flags 0x%08lx ignored\n", dwFlags
);
386 if(lpResults
->lpClass
) DPRINT("classes not implemented\n");
387 if (lpResults
->lpCaretPos
&& (dwFlags
& GCP_REORDER
))
388 DPRINT("Caret positions for complex scripts not implemented\n");
391 if(nSet
> lpResults
->nGlyphs
)
392 nSet
= lpResults
->nGlyphs
;
394 /* return number of initialized fields */
395 lpResults
->nGlyphs
= nSet
;
397 /*if((dwFlags&GCP_REORDER)==0 || !BidiAvail)
399 /* Treat the case where no special handling was requested in a fastpath way */
400 /* copy will do if the GCP_REORDER flag is not set */
401 if(lpResults
->lpOutString
)
402 lstrcpynW( lpResults
->lpOutString
, lpString
, nSet
);
404 if(lpResults
->lpGlyphs
)
405 lstrcpynW( lpResults
->lpGlyphs
, lpString
, nSet
);
407 if(lpResults
->lpOrder
)
409 for(i
= 0; i
< nSet
; i
++)
410 lpResults
->lpOrder
[i
] = i
;
414 BIDI_Reorder( lpString, uCount, dwFlags, WINE_GCPW_FORCE_LTR, lpResults->lpOutString,
415 nSet, lpResults->lpOrder );
418 /* FIXME: Will use the placement chars */
422 for (i
= 0; i
< nSet
; i
++)
424 if (GetCharWidth32W(hdc
, lpString
[i
], lpString
[i
], &c
))
425 lpResults
->lpDx
[i
]= c
;
429 if (lpResults
->lpCaretPos
&& !(dwFlags
& GCP_REORDER
))
433 lpResults
->lpCaretPos
[0] = 0;
434 for (i
= 1; i
< nSet
; i
++)
435 if (GetTextExtentPoint32W(hdc
, &(lpString
[i
- 1]), 1, &size
))
436 lpResults
->lpCaretPos
[i
] = (pos
+= size
.cx
);
439 /*if(lpResults->lpGlyphs)
440 NtGdiGetGlyphIndicesW(hdc, lpString, nSet, lpResults->lpGlyphs, 0);*/
442 if (GetTextExtentPoint32W(hdc
, lpString
, uCount
, &size
))
443 ret
= MAKELONG(size
.cx
, size
.cy
);
450 NewGetCharacterPlacementW(
455 GCP_RESULTSW
*lpResults
,
462 if ( !lpString
|| uCount
<= 0 || (nMaxExtent
< 0 && nMaxExtent
!= -1 ) )
464 SetLastError(ERROR_INVALID_PARAMETER
);
470 if ( GetTextExtentPointW(hdc
, lpString
, uCount
, &Size
) )
472 return MAKELONG(Size
.cx
, Size
.cy
);
478 if ( nSet
> lpResults
->nGlyphs
)
479 nSet
= lpResults
->nGlyphs
;
481 return NtGdiGetCharacterPlacementW( hdc
,
495 GetCharABCWidthsFloatW(HDC hdc
,
500 DPRINT("GetCharABCWidthsFloatW\n");
501 if ((!abcF
) || (FirstChar
> LastChar
))
503 SetLastError(ERROR_INVALID_PARAMETER
);
506 return NtGdiGetCharABCWidthsW( hdc
,
508 (ULONG
)(LastChar
- FirstChar
+ 1),
520 GetCharWidthFloatW(HDC hdc
,
525 DPRINT("GetCharWidthsFloatW\n");
526 if ((!pxBuffer
) || (iFirstChar
> iLastChar
))
528 SetLastError(ERROR_INVALID_PARAMETER
);
531 return NtGdiGetCharWidthW( hdc
,
533 (ULONG
)(iLastChar
- iFirstChar
+ 1),
545 GetCharWidthW(HDC hdc
,
550 DPRINT("GetCharWidthsW\n");
551 if ((!lpBuffer
) || (iFirstChar
> iLastChar
))
553 SetLastError(ERROR_INVALID_PARAMETER
);
556 return NtGdiGetCharWidthW( hdc
,
558 (ULONG
)(iLastChar
- iFirstChar
+ 1),
570 GetCharWidth32W(HDC hdc
,
575 DPRINT("GetCharWidths32W\n");
576 if ((!lpBuffer
) || (iFirstChar
> iLastChar
))
578 SetLastError(ERROR_INVALID_PARAMETER
);
581 return NtGdiGetCharWidthW( hdc
,
583 (ULONG
)(iLastChar
- iFirstChar
+ 1),
585 GCW_NOFLOAT
|GCW_WIN32
,
596 GetCharABCWidthsW(HDC hdc
,
601 DPRINT("GetCharABCWidthsW\n");
602 if ((!lpabc
) || (FirstChar
> LastChar
))
604 SetLastError(ERROR_INVALID_PARAMETER
);
607 return NtGdiGetCharABCWidthsW( hdc
,
609 (ULONG
)(LastChar
- FirstChar
+ 1),
627 INT i
, wlen
, count
= (INT
)(iLastChar
- iFirstChar
+ 1);
632 DPRINT("GetCharWidthsA\n");
633 if(count
<= 0) return FALSE
;
635 str
= HeapAlloc(GetProcessHeap(), 0, count
+1);
639 for(i
= 0; i
< count
; i
++)
640 str
[i
] = (BYTE
)(iFirstChar
+ i
);
643 wstr
= FONT_mbtowc(hdc
, str
, count
+1, &wlen
, NULL
);
646 HeapFree(GetProcessHeap(), 0, str
);
650 ret
= NtGdiGetCharWidthW( hdc
,
657 HeapFree(GetProcessHeap(), 0, str
);
658 HeapFree(GetProcessHeap(), 0, wstr
);
675 INT i
, wlen
, count
= (INT
)(iLastChar
- iFirstChar
+ 1);
680 DPRINT("GetCharWidths32A\n");
681 if(count
<= 0) return FALSE
;
683 str
= HeapAlloc(GetProcessHeap(), 0, count
+1);
686 for(i
= 0; i
< count
; i
++)
687 str
[i
] = (BYTE
)(iFirstChar
+ i
);
690 wstr
= FONT_mbtowc(hdc
, str
, count
+1, &wlen
, NULL
);
693 HeapFree(GetProcessHeap(), 0, str
);
697 ret
= NtGdiGetCharWidthW( hdc
,
701 GCW_NOFLOAT
|GCW_WIN32
,
704 HeapFree(GetProcessHeap(), 0, str
);
705 HeapFree(GetProcessHeap(), 0, wstr
);
722 INT i
, wlen
, count
= (INT
)(iLastChar
- iFirstChar
+ 1);
727 DPRINT("GetCharWidthsFloatA\n");
728 if(count
<= 0) return FALSE
;
730 str
= HeapAlloc(GetProcessHeap(), 0, count
+1);
733 for(i
= 0; i
< count
; i
++)
734 str
[i
] = (BYTE
)(iFirstChar
+ i
);
737 wstr
= FONT_mbtowc(hdc
, str
, count
+1, &wlen
, NULL
);
740 HeapFree(GetProcessHeap(), 0, str
);
743 ret
= NtGdiGetCharWidthW( hdc
, wstr
[0], (ULONG
) count
, (PWCHAR
) wstr
, 0, (PVOID
) pxBuffer
);
745 HeapFree(GetProcessHeap(), 0, str
);
746 HeapFree(GetProcessHeap(), 0, wstr
);
763 INT i
, wlen
, count
= (INT
)(uLastChar
- uFirstChar
+ 1);
768 DPRINT("GetCharABCWidthsA\n");
769 if(count
<= 0) return FALSE
;
771 str
= HeapAlloc(GetProcessHeap(), 0, count
+1);
774 for(i
= 0; i
< count
; i
++)
775 str
[i
] = (BYTE
)(uFirstChar
+ i
);
778 wstr
= FONT_mbtowc(hdc
, str
, count
+1, &wlen
, NULL
);
781 HeapFree(GetProcessHeap(), 0, str
);
785 ret
= NtGdiGetCharABCWidthsW( hdc
,
792 HeapFree(GetProcessHeap(), 0, str
);
793 HeapFree(GetProcessHeap(), 0, wstr
);
803 GetCharABCWidthsFloatA(
810 INT i
, wlen
, count
= (INT
)(iLastChar
- iFirstChar
+ 1);
815 DPRINT("GetCharABCWidthsFloatA\n");
816 if (count
<= 0) return FALSE
;
818 str
= HeapAlloc(GetProcessHeap(), 0, count
+1);
822 for(i
= 0; i
< count
; i
++)
823 str
[i
] = (BYTE
)(iFirstChar
+ i
);
826 wstr
= FONT_mbtowc( hdc
, str
, count
+1, &wlen
, NULL
);
829 HeapFree( GetProcessHeap(), 0, str
);
832 ret
= NtGdiGetCharABCWidthsW( hdc
,wstr
[0],(ULONG
)count
, (PWCHAR
)wstr
, 0, (PVOID
)lpABCF
);
834 HeapFree( GetProcessHeap(), 0, str
);
835 HeapFree( GetProcessHeap(), 0, wstr
);
845 GetCharABCWidthsI(HDC hdc
,
851 DPRINT("GetCharABCWidthsI\n");
852 return NtGdiGetCharABCWidthsW( hdc
,
856 GCABCW_NOFLOAT
|GCABCW_INDICES
,
865 GetCharWidthI(HDC hdc
,
872 DPRINT("GetCharWidthsI\n");
873 if (!lpBuffer
|| (!pgi
&& (giFirst
== MAXUSHORT
))) // Cannot be at max.
875 SetLastError(ERROR_INVALID_PARAMETER
);
878 if (!cgi
) return TRUE
;
879 return NtGdiGetCharWidthW( hdc
,
883 GCW_INDICES
|GCW_NOFLOAT
|GCW_WIN32
,
896 DWORD Gcp
= 0, Ret
= 0;
899 Ret
= NtGdiGetTextCharsetInfo(hDc
, NULL
, 0);
900 if ((Ret
== ARABIC_CHARSET
) || (Ret
== HEBREW_CHARSET
))
901 Ret
= (GCP_KASHIDA
|GCP_DIACRITIC
|GCP_LIGATE
|GCP_GLYPHSHAPE
|GCP_REORDER
);
903 Gcp
= GetDCDWord(hDc
, GdiGetFontLanguageInfo
, GCP_ERROR
);
904 if ( Gcp
== GCP_ERROR
)
928 lpstrW
= FONT_mbtowc(hdc
, lpstr
, count
, &countW
, NULL
);
933 Ret
= NtGdiGetGlyphIndicesW(hdc
, lpstrW
, countW
, pgi
, flags
);
934 HeapFree(GetProcessHeap(), 0, lpstrW
);
957 DPRINT("GetGlyphOutlineA uChar %x\n", uChar
);
958 if (!lpgm
|| !lpmat2
) return GDI_ERROR
;
959 if(!(uFormat
& GGO_GLYPH_INDEX
)) {
962 if(uChar
> 0xff) { /* but, 2 bytes character only */
964 mbchs
[0] = (uChar
& 0xff00) >> 8;
965 mbchs
[1] = (uChar
& 0xff);
968 mbchs
[0] = (uChar
& 0xff);
970 p
= FONT_mbtowc(hdc
, mbchs
, len
, NULL
, NULL
);
974 ret
= NtGdiGetGlyphOutline(hdc
, c
, uFormat
, lpgm
, cbBuffer
, lpvBuffer
, (CONST LPMAT2
)lpmat2
, TRUE
);
975 HeapFree(GetProcessHeap(), 0, p
);
995 DPRINT("GetGlyphOutlineW uChar %x\n", uChar
);
996 if (!lpgm
|| !lpmat2
) return GDI_ERROR
;
997 if (!lpvBuffer
) cbBuffer
= 0;
998 return NtGdiGetGlyphOutline ( hdc
, uChar
, uFormat
, lpgm
, cbBuffer
, lpvBuffer
, (CONST LPMAT2
)lpmat2
, TRUE
);
1007 GetOutlineTextMetricsA(
1010 LPOUTLINETEXTMETRICA lpOTM
1013 char buf
[512], *ptr
;
1015 OUTLINETEXTMETRICW
*lpOTMW
= (OUTLINETEXTMETRICW
*)buf
;
1016 OUTLINETEXTMETRICA
*output
= lpOTM
;
1019 if((ret
= GetOutlineTextMetricsW(hdc
, 0, NULL
)) == 0)
1021 if(ret
> sizeof(buf
))
1023 lpOTMW
= HeapAlloc(GetProcessHeap(), 0, ret
);
1029 GetOutlineTextMetricsW(hdc
, ret
, lpOTMW
);
1031 needed
= sizeof(OUTLINETEXTMETRICA
);
1032 if(lpOTMW
->otmpFamilyName
)
1033 needed
+= WideCharToMultiByte(CP_ACP
, 0,
1034 (WCHAR
*)((char*)lpOTMW
+ (int)lpOTMW
->otmpFamilyName
), -1,
1035 NULL
, 0, NULL
, NULL
);
1036 if(lpOTMW
->otmpFaceName
)
1037 needed
+= WideCharToMultiByte(CP_ACP
, 0,
1038 (WCHAR
*)((char*)lpOTMW
+ (int)lpOTMW
->otmpFaceName
), -1,
1039 NULL
, 0, NULL
, NULL
);
1040 if(lpOTMW
->otmpStyleName
)
1041 needed
+= WideCharToMultiByte(CP_ACP
, 0,
1042 (WCHAR
*)((char*)lpOTMW
+ (int)lpOTMW
->otmpStyleName
), -1,
1043 NULL
, 0, NULL
, NULL
);
1044 if(lpOTMW
->otmpFullName
)
1045 needed
+= WideCharToMultiByte(CP_ACP
, 0,
1046 (WCHAR
*)((char*)lpOTMW
+ (int)lpOTMW
->otmpFullName
), -1,
1047 NULL
, 0, NULL
, NULL
);
1054 DPRINT("needed = %d\n", needed
);
1057 /* Since the supplied buffer isn't big enough, we'll alloc one
1058 that is and memcpy the first cbData bytes into the lpOTM at
1060 output
= HeapAlloc(GetProcessHeap(), 0, needed
);
1067 ret
= output
->otmSize
= min(needed
, cbData
);
1068 FONT_TextMetricWToA( &lpOTMW
->otmTextMetrics
, &output
->otmTextMetrics
);
1069 output
->otmFiller
= 0;
1070 output
->otmPanoseNumber
= lpOTMW
->otmPanoseNumber
;
1071 output
->otmfsSelection
= lpOTMW
->otmfsSelection
;
1072 output
->otmfsType
= lpOTMW
->otmfsType
;
1073 output
->otmsCharSlopeRise
= lpOTMW
->otmsCharSlopeRise
;
1074 output
->otmsCharSlopeRun
= lpOTMW
->otmsCharSlopeRun
;
1075 output
->otmItalicAngle
= lpOTMW
->otmItalicAngle
;
1076 output
->otmEMSquare
= lpOTMW
->otmEMSquare
;
1077 output
->otmAscent
= lpOTMW
->otmAscent
;
1078 output
->otmDescent
= lpOTMW
->otmDescent
;
1079 output
->otmLineGap
= lpOTMW
->otmLineGap
;
1080 output
->otmsCapEmHeight
= lpOTMW
->otmsCapEmHeight
;
1081 output
->otmsXHeight
= lpOTMW
->otmsXHeight
;
1082 output
->otmrcFontBox
= lpOTMW
->otmrcFontBox
;
1083 output
->otmMacAscent
= lpOTMW
->otmMacAscent
;
1084 output
->otmMacDescent
= lpOTMW
->otmMacDescent
;
1085 output
->otmMacLineGap
= lpOTMW
->otmMacLineGap
;
1086 output
->otmusMinimumPPEM
= lpOTMW
->otmusMinimumPPEM
;
1087 output
->otmptSubscriptSize
= lpOTMW
->otmptSubscriptSize
;
1088 output
->otmptSubscriptOffset
= lpOTMW
->otmptSubscriptOffset
;
1089 output
->otmptSuperscriptSize
= lpOTMW
->otmptSuperscriptSize
;
1090 output
->otmptSuperscriptOffset
= lpOTMW
->otmptSuperscriptOffset
;
1091 output
->otmsStrikeoutSize
= lpOTMW
->otmsStrikeoutSize
;
1092 output
->otmsStrikeoutPosition
= lpOTMW
->otmsStrikeoutPosition
;
1093 output
->otmsUnderscoreSize
= lpOTMW
->otmsUnderscoreSize
;
1094 output
->otmsUnderscorePosition
= lpOTMW
->otmsUnderscorePosition
;
1097 ptr
= (char*)(output
+ 1);
1098 left
= needed
- sizeof(*output
);
1100 if(lpOTMW
->otmpFamilyName
) {
1101 output
->otmpFamilyName
= (LPSTR
)(ptr
- (char*)output
);
1102 len
= WideCharToMultiByte(CP_ACP
, 0,
1103 (WCHAR
*)((char*)lpOTMW
+ (int)lpOTMW
->otmpFamilyName
), -1,
1104 ptr
, left
, NULL
, NULL
);
1108 output
->otmpFamilyName
= 0;
1110 if(lpOTMW
->otmpFaceName
) {
1111 output
->otmpFaceName
= (LPSTR
)(ptr
- (char*)output
);
1112 len
= WideCharToMultiByte(CP_ACP
, 0,
1113 (WCHAR
*)((char*)lpOTMW
+ (int)lpOTMW
->otmpFaceName
), -1,
1114 ptr
, left
, NULL
, NULL
);
1118 output
->otmpFaceName
= 0;
1120 if(lpOTMW
->otmpStyleName
) {
1121 output
->otmpStyleName
= (LPSTR
)(ptr
- (char*)output
);
1122 len
= WideCharToMultiByte(CP_ACP
, 0,
1123 (WCHAR
*)((char*)lpOTMW
+ (int)lpOTMW
->otmpStyleName
), -1,
1124 ptr
, left
, NULL
, NULL
);
1128 output
->otmpStyleName
= 0;
1130 if(lpOTMW
->otmpFullName
) {
1131 output
->otmpFullName
= (LPSTR
)(ptr
- (char*)output
);
1132 len
= WideCharToMultiByte(CP_ACP
, 0,
1133 (WCHAR
*)((char*)lpOTMW
+ (int)lpOTMW
->otmpFullName
), -1,
1134 ptr
, left
, NULL
, NULL
);
1137 output
->otmpFullName
= 0;
1141 if(output
!= lpOTM
) {
1142 memcpy(lpOTM
, output
, cbData
);
1143 HeapFree(GetProcessHeap(), 0, output
);
1145 /* check if the string offsets really fit into the provided size */
1146 /* FIXME: should we check string length as well? */
1147 if ((UINT_PTR
)lpOTM
->otmpFamilyName
>= lpOTM
->otmSize
)
1148 lpOTM
->otmpFamilyName
= 0; /* doesn't fit */
1150 if ((UINT_PTR
)lpOTM
->otmpFaceName
>= lpOTM
->otmSize
)
1151 lpOTM
->otmpFaceName
= 0; /* doesn't fit */
1153 if ((UINT_PTR
)lpOTM
->otmpStyleName
>= lpOTM
->otmSize
)
1154 lpOTM
->otmpStyleName
= 0; /* doesn't fit */
1156 if ((UINT_PTR
)lpOTM
->otmpFullName
>= lpOTM
->otmSize
)
1157 lpOTM
->otmpFullName
= 0; /* doesn't fit */
1161 if(lpOTMW
!= (OUTLINETEXTMETRICW
*)buf
)
1162 HeapFree(GetProcessHeap(), 0, lpOTMW
);
1173 GetOutlineTextMetricsW(
1176 LPOUTLINETEXTMETRICW lpOTM
1179 TMDIFF Tmd
; // Should not be zero.
1181 return NtGdiGetOutlineTextMetricsInternalW(hdc
, cbData
, lpOTM
, &Tmd
);
1189 GetKerningPairsW(HDC hdc
,
1191 LPKERNINGPAIR pkpDst
)
1193 if ((cPairs
!= 0) || (pkpDst
== 0))
1195 return NtGdiGetKerningPairs(hdc
,cPairs
,pkpDst
);
1199 SetLastError(ERROR_INVALID_PARAMETER
);
1209 GetKerningPairsA( HDC hDC
,
1211 LPKERNINGPAIR kern_pairA
)
1216 DWORD i
, total_kern_pairs
, kern_pairs_copied
= 0;
1217 KERNINGPAIR
*kern_pairW
;
1219 if (!cPairs
&& kern_pairA
)
1221 SetLastError(ERROR_INVALID_PARAMETER
);
1225 charset
= GetTextCharset(hDC
);
1226 if (!TranslateCharsetInfo(ULongToPtr(charset
), &csi
, TCI_SRCCHARSET
))
1228 DPRINT1("Can't find codepage for charset %d\n", charset
);
1231 /* GetCPInfo() will fail on CP_SYMBOL, and WideCharToMultiByte is supposed
1232 * to fail on an invalid character for CP_SYMBOL.
1234 cpi
.DefaultChar
[0] = 0;
1235 if (csi
.ciACP
!= CP_SYMBOL
&& !GetCPInfo(csi
.ciACP
, &cpi
))
1237 DPRINT1("Can't find codepage %u info\n", csi
.ciACP
);
1240 DPRINT("charset %d => codepage %u\n", charset
, csi
.ciACP
);
1242 total_kern_pairs
= NtGdiGetKerningPairs(hDC
, 0, NULL
);
1243 if (!total_kern_pairs
) return 0;
1245 if (!cPairs
&& !kern_pairA
) return total_kern_pairs
;
1247 kern_pairW
= HeapAlloc(GetProcessHeap(), 0, total_kern_pairs
* sizeof(*kern_pairW
));
1248 if (kern_pairW
== NULL
)
1252 GetKerningPairsW(hDC
, total_kern_pairs
, kern_pairW
);
1254 for (i
= 0; i
< total_kern_pairs
; i
++)
1258 if (!WideCharToMultiByte(csi
.ciACP
, 0, &kern_pairW
[i
].wFirst
, 1, &first
, 1, NULL
, NULL
))
1261 if (!WideCharToMultiByte(csi
.ciACP
, 0, &kern_pairW
[i
].wSecond
, 1, &second
, 1, NULL
, NULL
))
1264 if (first
== cpi
.DefaultChar
[0] || second
== cpi
.DefaultChar
[0])
1269 if (kern_pairs_copied
>= cPairs
) break;
1271 kern_pairA
->wFirst
= (BYTE
)first
;
1272 kern_pairA
->wSecond
= (BYTE
)second
;
1273 kern_pairA
->iKernAmount
= kern_pairW
[i
].iKernAmount
;
1276 kern_pairs_copied
++;
1279 HeapFree(GetProcessHeap(), 0, kern_pairW
);
1281 return kern_pairs_copied
;
1291 CreateFontIndirectExA(const ENUMLOGFONTEXDVA
*elfexd
)
1295 ENUMLOGFONTEXDVW Logfont
;
1297 EnumLogFontExW2A( (LPENUMLOGFONTEXA
) elfexd
,
1298 &Logfont
.elfEnumLogfontEx
);
1300 RtlCopyMemory( &Logfont
.elfDesignVector
,
1301 (PVOID
) &elfexd
->elfDesignVector
,
1302 sizeof(DESIGNVECTOR
));
1304 return NtGdiHfontCreate( &Logfont
, 0, 0, 0, NULL
);
1315 CreateFontIndirectExW(const ENUMLOGFONTEXDVW
*elfexd
)
1317 /* Msdn: Note, this function ignores the elfDesignVector member in
1322 return NtGdiHfontCreate((PENUMLOGFONTEXDVW
) elfexd
, 0, 0, 0, NULL
);
1333 CreateFontIndirectA(
1334 CONST LOGFONTA
*lplf
1341 LogFontA2W(&tlf
, lplf
);
1342 return CreateFontIndirectW(&tlf
);
1353 CreateFontIndirectW(
1354 CONST LOGFONTW
*lplf
1359 ENUMLOGFONTEXDVW Logfont
;
1361 RtlCopyMemory( &Logfont
.elfEnumLogfontEx
.elfLogFont
, lplf
, sizeof(LOGFONTW
));
1362 // Need something other than just cleaning memory here.
1363 // Guess? Use caller data to determine the rest.
1364 RtlZeroMemory( &Logfont
.elfEnumLogfontEx
.elfFullName
,
1365 sizeof(Logfont
.elfEnumLogfontEx
.elfFullName
));
1366 RtlZeroMemory( &Logfont
.elfEnumLogfontEx
.elfStyle
,
1367 sizeof(Logfont
.elfEnumLogfontEx
.elfStyle
));
1368 RtlZeroMemory( &Logfont
.elfEnumLogfontEx
.elfScript
,
1369 sizeof(Logfont
.elfEnumLogfontEx
.elfScript
));
1371 Logfont
.elfDesignVector
.dvNumAxes
= 0; // No more than MM_MAX_NUMAXES
1373 RtlZeroMemory( &Logfont
.elfDesignVector
, sizeof(DESIGNVECTOR
));
1375 return CreateFontIndirectExW(&Logfont
);
1396 DWORD fdwOutputPrecision
,
1397 DWORD fdwClipPrecision
,
1399 DWORD fdwPitchAndFamily
,
1403 ANSI_STRING StringA
;
1404 UNICODE_STRING StringU
;
1407 RtlInitAnsiString(&StringA
, (LPSTR
)lpszFace
);
1408 RtlAnsiStringToUnicodeString(&StringU
, &StringA
, TRUE
);
1410 ret
= CreateFontW(nHeight
,
1425 RtlFreeUnicodeString(&StringU
);
1446 DWORD fdwOutputPrecision
,
1447 DWORD fdwClipPrecision
,
1449 DWORD fdwPitchAndFamily
,
1455 logfont
.lfHeight
= nHeight
;
1456 logfont
.lfWidth
= nWidth
;
1457 logfont
.lfEscapement
= nEscapement
;
1458 logfont
.lfOrientation
= nOrientation
;
1459 logfont
.lfWeight
= nWeight
;
1460 logfont
.lfItalic
= fnItalic
;
1461 logfont
.lfUnderline
= fdwUnderline
;
1462 logfont
.lfStrikeOut
= fdwStrikeOut
;
1463 logfont
.lfCharSet
= fdwCharSet
;
1464 logfont
.lfOutPrecision
= fdwOutputPrecision
;
1465 logfont
.lfClipPrecision
= fdwClipPrecision
;
1466 logfont
.lfQuality
= fdwQuality
;
1467 logfont
.lfPitchAndFamily
= fdwPitchAndFamily
;
1469 if (NULL
!= lpszFace
)
1471 int Size
= sizeof(logfont
.lfFaceName
) / sizeof(WCHAR
);
1472 wcsncpy((wchar_t *)logfont
.lfFaceName
, lpszFace
, Size
- 1);
1473 /* Be 101% sure to have '\0' at end of string */
1474 logfont
.lfFaceName
[Size
- 1] = '\0';
1478 logfont
.lfFaceName
[0] = L
'\0';
1481 return CreateFontIndirectW(&logfont
);
1490 CreateScalableFontResourceA(
1493 LPCSTR lpszFontFile
,
1494 LPCSTR lpszCurrentPath
1506 AddFontResourceExW ( LPCWSTR lpszFilename
, DWORD fl
, PVOID pvReserved
)
1508 if (fl
& ~(FR_PRIVATE
| FR_NOT_ENUM
))
1510 SetLastError( ERROR_INVALID_PARAMETER
);
1514 return GdiAddFontResourceW(lpszFilename
, fl
,0);
1523 AddFontResourceExA ( LPCSTR lpszFilename
, DWORD fl
, PVOID pvReserved
)
1529 if (fl
& ~(FR_PRIVATE
| FR_NOT_ENUM
))
1531 SetLastError( ERROR_INVALID_PARAMETER
);
1535 Status
= HEAP_strdupA2W ( &FilenameW
, lpszFilename
);
1536 if ( !NT_SUCCESS (Status
) )
1538 SetLastError (RtlNtStatusToDosError(Status
));
1542 rc
= GdiAddFontResourceW ( FilenameW
, fl
, 0 );
1543 HEAP_free ( FilenameW
);
1553 AddFontResourceA ( LPCSTR lpszFilename
)
1559 Status
= HEAP_strdupA2W ( &FilenameW
, lpszFilename
);
1560 if ( !NT_SUCCESS (Status
) )
1562 SetLastError (RtlNtStatusToDosError(Status
));
1566 rc
= GdiAddFontResourceW ( FilenameW
, 0, 0);
1568 HEAP_free ( FilenameW
);
1579 AddFontResourceW ( LPCWSTR lpszFilename
)
1581 return GdiAddFontResourceW ( lpszFilename
, 0, 0 );
1590 RemoveFontResourceW(LPCWSTR lpFileName
)
1592 return RemoveFontResourceExW(lpFileName
,0,0);
1601 RemoveFontResourceA(LPCSTR lpFileName
)
1603 return RemoveFontResourceExA(lpFileName
,0,0);
1611 RemoveFontResourceExA(LPCSTR lpFileName
,
1619 /* FIXME the flags */
1621 /* FIXME NtGdiRemoveFontResource handle flags and pdv */
1623 Status
= HEAP_strdupA2W ( &lpFileNameW
, lpFileName
);
1624 if (!NT_SUCCESS (Status
))
1625 SetLastError (RtlNtStatusToDosError(Status
));
1629 HEAP_free ( lpFileNameW
);
1640 RemoveFontResourceExW(LPCWSTR lpFileName
,
1644 /* FIXME the flags */
1646 /* FIXME NtGdiRemoveFontResource handle flags and pdv */
1651 /***********************************************************************
1652 * GdiGetCharDimensions
1654 * Gets the average width of the characters in the English alphabet.
1657 * hdc [I] Handle to the device context to measure on.
1658 * lptm [O] Pointer to memory to store the text metrics into.
1659 * height [O] On exit, the maximum height of characters in the English alphabet.
1662 * The average width of characters in the English alphabet.
1665 * This function is used by the dialog manager to get the size of a dialog
1666 * unit. It should also be used by other pieces of code that need to know
1667 * the size of a dialog unit in logical units without having access to the
1668 * window handle of the dialog.
1669 * Windows caches the font metrics from this function, but we don't and
1670 * there doesn't appear to be an immediate advantage to do so.
1673 * GetTextExtentPointW, GetTextMetricsW, MapDialogRect.
1675 * Despite most of MSDN insisting that the horizontal base unit is
1676 * tmAveCharWidth it isn't. Knowledge base article Q145994
1677 * "HOWTO: Calculate Dialog Units When Not Using the System Font",
1678 * says that we should take the average of the 52 English upper and lower
1686 GdiGetCharDimensions(HDC hdc
, LPTEXTMETRICW lptm
, LONG
*height
)
1690 static const WCHAR alphabet
[] = {
1691 'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q',
1692 'r','s','t','u','v','w','x','y','z','A','B','C','D','E','F','G','H',
1693 'I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z',0};
1695 if(!GetTextMetricsW(hdc
, &tm
)) return 0;
1697 if(!GetTextExtentPointW(hdc
, alphabet
, 52, &sz
)) return 0;
1699 if (lptm
) *lptm
= tm
;
1700 if (height
) *height
= tm
.tmHeight
;
1702 return (sz
.cx
/ 26 + 1) / 2;
1705 /*************************************************************************
1706 * TranslateCharsetInfo [GDI32.@]
1708 * Fills a CHARSETINFO structure for a character set, code page, or
1709 * font. This allows making the correspondance between different labelings
1710 * (character set, Windows, ANSI, and OEM codepages, and Unicode ranges)
1711 * of the same encoding.
1713 * Only one codepage will be set in lpCs->fs. If TCI_SRCFONTSIG is used,
1714 * only one codepage should be set in *lpSrc.
1717 * TRUE on success, FALSE on failure.
1725 TranslateCharsetInfo(
1726 LPDWORD lpSrc
, /* [in]
1727 if flags == TCI_SRCFONTSIG: pointer to fsCsb of a FONTSIGNATURE
1728 if flags == TCI_SRCCHARSET: a character set value
1729 if flags == TCI_SRCCODEPAGE: a code page value
1731 LPCHARSETINFO lpCs
, /* [out] structure to receive charset information */
1732 DWORD flags
/* [in] determines interpretation of lpSrc */)
1736 case TCI_SRCFONTSIG
:
1737 while (index
< MAXTCIINDEX
&& !(*lpSrc
>>index
& 0x0001)) index
++;
1739 case TCI_SRCCODEPAGE
:
1740 while (index
< MAXTCIINDEX
&& PtrToUlong(lpSrc
) != FONT_tci
[index
].ciACP
) index
++;
1742 case TCI_SRCCHARSET
:
1743 while (index
< MAXTCIINDEX
&& PtrToUlong(lpSrc
) != FONT_tci
[index
].ciCharset
) index
++;
1748 if (index
>= MAXTCIINDEX
|| FONT_tci
[index
].ciCharset
== DEFAULT_CHARSET
) return FALSE
;
1749 memcpy(lpCs
, &FONT_tci
[index
], sizeof(CHARSETINFO
));
1764 DWORD Ret
= GDI_ERROR
;
1767 if (GDI_HANDLE_GET_TYPE(hDC
) != GDI_OBJECT_TYPE_DC
)
1769 if (GDI_HANDLE_GET_TYPE(hDC
) == GDI_OBJECT_TYPE_METADC
)
1770 return MFDRV_SetMapperFlags( hDC
, flags
);
1773 PLDC pLDC
= Dc_Attr
->pvLDC
;
1776 SetLastError(ERROR_INVALID_HANDLE
);
1779 if (pLDC
->iType
== LDC_EMFLDC
)
1781 return EMFDRV_SetMapperFlags( hDC
, flags
);
1786 if (!GdiGetHandleUserData((HGDIOBJ
) hDC
, GDI_OBJECT_TYPE_DC
, (PVOID
) &Dc_Attr
)) return GDI_ERROR
;
1788 if (NtCurrentTeb()->GdiTebBatch
.HDC
== hDC
)
1790 if (Dc_Attr
->ulDirty_
& DC_FONTTEXT_DIRTY
)
1793 Dc_Attr
->ulDirty_
&= ~(DC_MODE_DIRTY
|DC_FONTTEXT_DIRTY
);
1798 SetLastError(ERROR_INVALID_PARAMETER
);
1801 Ret
= Dc_Attr
->flFontMapper
;
1802 Dc_Attr
->flFontMapper
= flags
;
1816 FONTENUMPROCW FontFunc
,
1821 return NtGdiEnumFonts ( hDC
, lpFaceName
, FontFunc
, lParam
);
1823 return EnumFontFamiliesW( hDC
, lpFaceName
, FontFunc
, lParam
);
1835 FONTENUMPROCA FontFunc
,
1844 Status
= HEAP_strdupA2W ( &lpFaceNameW
, lpFaceName
);
1845 if (!NT_SUCCESS (Status
))
1846 SetLastError (RtlNtStatusToDosError(Status
));
1849 rc
= NtGdiEnumFonts ( hDC
, lpFaceNameW
, FontFunc
, lParam
);
1851 HEAP_free ( lpFaceNameW
);
1855 return EnumFontFamiliesA( hDC
, lpFaceName
, FontFunc
, lParam
);
1859 #define EfdFontFamilies 3
1863 NewEnumFontFamiliesExW(
1865 LPLOGFONTW lpLogfont
,
1866 FONTENUMPROCW lpEnumFontFamExProcW
,
1870 ULONG_PTR idEnum
, cbDataSize
, cbRetSize
;
1871 PENUMFONTDATAW pEfdw
;
1876 /* Open enumeration handle and find out how much memory we need */
1877 idEnum
= NtGdiEnumFontOpen(hDC
,
1881 (lpLogfont
&& lpLogfont
->lfFaceName
[0])? lpLogfont
->lfFaceName
: NULL
,
1882 lpLogfont
? lpLogfont
->lfCharSet
: DEFAULT_CHARSET
,
1888 if (cbDataSize
== 0)
1890 NtGdiEnumFontClose(idEnum
);
1894 /* Allocate memory */
1895 pBuffer
= HeapAlloc(GetProcessHeap(), 0, cbDataSize
);
1896 if (pBuffer
== NULL
)
1898 SetLastError(ERROR_NOT_ENOUGH_MEMORY
);
1899 NtGdiEnumFontClose(idEnum
);
1903 /* Do the enumeration */
1904 if (!NtGdiEnumFontChunk(hDC
, idEnum
, cbDataSize
, &cbRetSize
, (PVOID
)pBuffer
))
1906 HeapFree(GetProcessHeap(), 0, pBuffer
);
1907 NtGdiEnumFontClose(idEnum
);
1911 /* Get start and end address */
1912 pEfdw
= (PENUMFONTDATAW
)pBuffer
;
1913 pMax
= pBuffer
+ cbDataSize
;
1915 /* Iterate through the structures */
1916 while ((PBYTE
)pEfdw
< pMax
&& ret
)
1918 PNTMW_INTERNAL pNtmwi
= (PNTMW_INTERNAL
)((ULONG_PTR
)pEfdw
+ pEfdw
->ulNtmwiOffset
);
1920 ret
= lpEnumFontFamExProcW((VOID
*)&pEfdw
->elfexdv
.elfEnumLogfontEx
,
1921 (VOID
*)&pNtmwi
->ntmw
,
1925 pEfdw
= (PENUMFONTDATAW
)((ULONG_PTR
)pEfdw
+ pEfdw
->cbSize
);
1928 /* Release the memory and close handle */
1929 HeapFree(GetProcessHeap(), 0, pBuffer
);
1930 NtGdiEnumFontClose(idEnum
);