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
));
121 MultiByteToWideChar(cp
, 0, str
, count
, strW
, lenW
);
122 DPRINT("mapped %s -> %S\n", str
, strW
);
123 if(plenW
) *plenW
= lenW
;
129 NewTextMetricW2A(NEWTEXTMETRICA
*tma
, NEWTEXTMETRICW
*tmw
)
131 FONT_TextMetricWToA((TEXTMETRICW
*) tmw
, (TEXTMETRICA
*) tma
);
132 tma
->ntmFlags
= tmw
->ntmFlags
;
133 tma
->ntmSizeEM
= tmw
->ntmSizeEM
;
134 tma
->ntmCellHeight
= tmw
->ntmCellHeight
;
135 tma
->ntmAvgWidth
= tmw
->ntmAvgWidth
;
139 NewTextMetricExW2A(NEWTEXTMETRICEXA
*tma
, NEWTEXTMETRICEXW
*tmw
)
141 NewTextMetricW2A(&tma
->ntmTm
, &tmw
->ntmTm
);
142 tma
->ntmFontSig
= tmw
->ntmFontSig
;
146 IntEnumFontFamilies(HDC Dc
, LPLOGFONTW LogFont
, PVOID EnumProc
, LPARAM lParam
,
151 PFONTFAMILYINFO Info
;
154 ENUMLOGFONTEXA EnumLogFontExA
;
155 NEWTEXTMETRICEXA NewTextMetricExA
;
157 Info
= RtlAllocateHeap(GetProcessHeap(), 0,
158 INITIAL_FAMILY_COUNT
* sizeof(FONTFAMILYINFO
));
163 FontFamilyCount
= NtGdiGetFontFamilyInfo(Dc
, LogFont
, Info
, INITIAL_FAMILY_COUNT
);
164 if (FontFamilyCount
< 0)
166 RtlFreeHeap(GetProcessHeap(), 0, Info
);
169 if (INITIAL_FAMILY_COUNT
< FontFamilyCount
)
171 FontFamilySize
= FontFamilyCount
;
172 RtlFreeHeap(GetProcessHeap(), 0, Info
);
173 Info
= RtlAllocateHeap(GetProcessHeap(), 0,
174 FontFamilyCount
* sizeof(FONTFAMILYINFO
));
179 FontFamilyCount
= NtGdiGetFontFamilyInfo(Dc
, LogFont
, Info
, FontFamilySize
);
180 if (FontFamilyCount
< 0 || FontFamilySize
< FontFamilyCount
)
182 RtlFreeHeap(GetProcessHeap(), 0, Info
);
187 for (i
= 0; i
< FontFamilyCount
; i
++)
191 Ret
= ((FONTENUMPROCW
) EnumProc
)(
192 (VOID
*)&Info
[i
].EnumLogFontEx
,
193 (VOID
*)&Info
[i
].NewTextMetricEx
,
194 Info
[i
].FontType
, lParam
);
197 { // Could use EnumLogFontExW2A here?
198 LogFontW2A(&EnumLogFontExA
.elfLogFont
, &Info
[i
].EnumLogFontEx
.elfLogFont
);
199 WideCharToMultiByte(CP_THREAD_ACP
, 0, Info
[i
].EnumLogFontEx
.elfFullName
, -1,
200 (LPSTR
)EnumLogFontExA
.elfFullName
, LF_FULLFACESIZE
, NULL
, NULL
);
201 WideCharToMultiByte(CP_THREAD_ACP
, 0, Info
[i
].EnumLogFontEx
.elfStyle
, -1,
202 (LPSTR
)EnumLogFontExA
.elfStyle
, LF_FACESIZE
, NULL
, NULL
);
203 WideCharToMultiByte(CP_THREAD_ACP
, 0, Info
[i
].EnumLogFontEx
.elfScript
, -1,
204 (LPSTR
)EnumLogFontExA
.elfScript
, LF_FACESIZE
, NULL
, NULL
);
205 NewTextMetricExW2A(&NewTextMetricExA
,
206 &Info
[i
].NewTextMetricEx
);
207 Ret
= ((FONTENUMPROCA
) EnumProc
)(
208 (VOID
*)&EnumLogFontExA
,
209 (VOID
*)&NewTextMetricExA
,
210 Info
[i
].FontType
, lParam
);
214 RtlFreeHeap(GetProcessHeap(), 0, Info
);
223 EnumFontFamiliesExW(HDC hdc
, LPLOGFONTW lpLogfont
, FONTENUMPROCW lpEnumFontFamExProc
,
224 LPARAM lParam
, DWORD dwFlags
)
226 return IntEnumFontFamilies(hdc
, lpLogfont
, lpEnumFontFamExProc
, lParam
, TRUE
);
234 EnumFontFamiliesW(HDC hdc
, LPCWSTR lpszFamily
, FONTENUMPROCW lpEnumFontFamProc
,
239 ZeroMemory(&LogFont
, sizeof(LOGFONTW
));
240 LogFont
.lfCharSet
= DEFAULT_CHARSET
;
241 if (NULL
!= lpszFamily
)
243 if (!*lpszFamily
) return 1;
244 lstrcpynW(LogFont
.lfFaceName
, lpszFamily
, LF_FACESIZE
);
247 return IntEnumFontFamilies(hdc
, &LogFont
, lpEnumFontFamProc
, lParam
, TRUE
);
255 EnumFontFamiliesExA (HDC hdc
, LPLOGFONTA lpLogfont
, FONTENUMPROCA lpEnumFontFamExProc
,
256 LPARAM lParam
, DWORD dwFlags
)
258 LOGFONTW LogFontW
, *pLogFontW
;
262 LogFontA2W(&LogFontW
,lpLogfont
);
263 pLogFontW
= &LogFontW
;
265 else pLogFontW
= NULL
;
267 /* no need to convert LogFontW back to lpLogFont b/c it's an [in] parameter only */
268 return IntEnumFontFamilies(hdc
, pLogFontW
, lpEnumFontFamExProc
, lParam
, FALSE
);
276 EnumFontFamiliesA(HDC hdc
, LPCSTR lpszFamily
, FONTENUMPROCA lpEnumFontFamProc
,
281 ZeroMemory(&LogFont
, sizeof(LOGFONTW
));
282 LogFont
.lfCharSet
= DEFAULT_CHARSET
;
283 if (NULL
!= lpszFamily
)
285 if (!*lpszFamily
) return 1;
286 MultiByteToWideChar(CP_THREAD_ACP
, 0, lpszFamily
, -1, LogFont
.lfFaceName
, LF_FACESIZE
);
289 return IntEnumFontFamilies(hdc
, &LogFont
, lpEnumFontFamProc
, lParam
, FALSE
);
298 GetCharacterPlacementA(
303 GCP_RESULTSA
*lpResults
,
308 GCP_RESULTSW resultsW
;
312 if ( !lpString
|| uCount
<= 0 || (nMaxExtent
< 0 && nMaxExtent
!= -1 ) )
314 SetLastError(ERROR_INVALID_PARAMETER
);
317 /* TRACE("%s, %d, %d, 0x%08x\n",
318 debugstr_an(lpString, uCount), uCount, nMaxExtent, dwFlags);
320 /* both structs are equal in size */
321 memcpy(&resultsW
, lpResults
, sizeof(resultsW
));
323 lpStringW
= FONT_mbtowc(hdc
, lpString
, uCount
, &uCountW
, &font_cp
);
324 if(lpResults
->lpOutString
)
325 resultsW
.lpOutString
= HeapAlloc(GetProcessHeap(), 0, sizeof(WCHAR
)*uCountW
);
327 ret
= GetCharacterPlacementW(hdc
, lpStringW
, uCountW
, nMaxExtent
, &resultsW
, dwFlags
);
329 lpResults
->nGlyphs
= resultsW
.nGlyphs
;
330 lpResults
->nMaxFit
= resultsW
.nMaxFit
;
332 if(lpResults
->lpOutString
) {
333 WideCharToMultiByte(font_cp
, 0, resultsW
.lpOutString
, uCountW
,
334 lpResults
->lpOutString
, uCount
, NULL
, NULL
);
337 HeapFree(GetProcessHeap(), 0, lpStringW
);
338 HeapFree(GetProcessHeap(), 0, resultsW
.lpOutString
);
349 GetCharacterPlacementW(
354 GCP_RESULTSW
*lpResults
,
361 DPRINT("GetCharacterPlacementW\n");
363 if(dwFlags
&(~GCP_REORDER
)) DPRINT("flags 0x%08lx ignored\n", dwFlags
);
364 if(lpResults
->lpClass
) DPRINT("classes not implemented\n");
365 if (lpResults
->lpCaretPos
&& (dwFlags
& GCP_REORDER
))
366 DPRINT("Caret positions for complex scripts not implemented\n");
369 if(nSet
> lpResults
->nGlyphs
)
370 nSet
= lpResults
->nGlyphs
;
372 /* return number of initialized fields */
373 lpResults
->nGlyphs
= nSet
;
375 /*if((dwFlags&GCP_REORDER)==0 || !BidiAvail)
377 /* Treat the case where no special handling was requested in a fastpath way */
378 /* copy will do if the GCP_REORDER flag is not set */
379 if(lpResults
->lpOutString
)
380 lstrcpynW( lpResults
->lpOutString
, lpString
, nSet
);
382 if(lpResults
->lpGlyphs
)
383 lstrcpynW( lpResults
->lpGlyphs
, lpString
, nSet
);
385 if(lpResults
->lpOrder
)
387 for(i
= 0; i
< nSet
; i
++)
388 lpResults
->lpOrder
[i
] = i
;
392 BIDI_Reorder( lpString, uCount, dwFlags, WINE_GCPW_FORCE_LTR, lpResults->lpOutString,
393 nSet, lpResults->lpOrder );
396 /* FIXME: Will use the placement chars */
400 for (i
= 0; i
< nSet
; i
++)
402 if (GetCharWidth32W(hdc
, lpString
[i
], lpString
[i
], &c
))
403 lpResults
->lpDx
[i
]= c
;
407 if (lpResults
->lpCaretPos
&& !(dwFlags
& GCP_REORDER
))
411 lpResults
->lpCaretPos
[0] = 0;
412 for (i
= 1; i
< nSet
; i
++)
413 if (GetTextExtentPoint32W(hdc
, &(lpString
[i
- 1]), 1, &size
))
414 lpResults
->lpCaretPos
[i
] = (pos
+= size
.cx
);
417 /*if(lpResults->lpGlyphs)
418 NtGdiGetGlyphIndicesW(hdc, lpString, nSet, lpResults->lpGlyphs, 0);*/
420 if (GetTextExtentPoint32W(hdc
, lpString
, uCount
, &size
))
421 ret
= MAKELONG(size
.cx
, size
.cy
);
428 NewGetCharacterPlacementW(
433 GCP_RESULTSW
*lpResults
,
440 if ( !lpString
|| uCount
<= 0 || (nMaxExtent
< 0 && nMaxExtent
!= -1 ) )
442 SetLastError(ERROR_INVALID_PARAMETER
);
448 if ( GetTextExtentPointW(hdc
, lpString
, uCount
, &Size
) )
450 return MAKELONG(Size
.cx
, Size
.cy
);
456 if ( nSet
> lpResults
->nGlyphs
)
457 nSet
= lpResults
->nGlyphs
;
459 return NtGdiGetCharacterPlacementW( hdc
,
473 GetCharABCWidthsFloatW(HDC hdc
,
478 DPRINT("GetCharABCWidthsFloatW\n");
479 if ((!abcF
) || (FirstChar
> LastChar
))
481 SetLastError(ERROR_INVALID_PARAMETER
);
484 return NtGdiGetCharABCWidthsW( hdc
,
486 (ULONG
)(LastChar
- FirstChar
+ 1),
498 GetCharWidthFloatW(HDC hdc
,
503 DPRINT("GetCharWidthsFloatW\n");
504 if ((!pxBuffer
) || (iFirstChar
> iLastChar
))
506 SetLastError(ERROR_INVALID_PARAMETER
);
509 return NtGdiGetCharWidthW( hdc
,
511 (ULONG
)(iLastChar
- iFirstChar
+ 1),
523 GetCharWidthW(HDC hdc
,
528 DPRINT("GetCharWidthsW\n");
529 if ((!lpBuffer
) || (iFirstChar
> iLastChar
))
531 SetLastError(ERROR_INVALID_PARAMETER
);
534 return NtGdiGetCharWidthW( hdc
,
536 (ULONG
)(iLastChar
- iFirstChar
+ 1),
548 GetCharWidth32W(HDC hdc
,
553 DPRINT("GetCharWidths32W\n");
554 if ((!lpBuffer
) || (iFirstChar
> iLastChar
))
556 SetLastError(ERROR_INVALID_PARAMETER
);
559 return NtGdiGetCharWidthW( hdc
,
561 (ULONG
)(iLastChar
- iFirstChar
+ 1),
563 GCW_NOFLOAT
|GCW_WIN32
,
574 GetCharABCWidthsW(HDC hdc
,
579 DPRINT("GetCharABCWidthsW\n");
580 if ((!lpabc
) || (FirstChar
> LastChar
))
582 SetLastError(ERROR_INVALID_PARAMETER
);
585 return NtGdiGetCharABCWidthsW( hdc
,
587 (ULONG
)(LastChar
- FirstChar
+ 1),
605 INT i
, wlen
, count
= (INT
)(iLastChar
- iFirstChar
+ 1);
610 DPRINT("GetCharWidthsA\n");
611 if(count
<= 0) return FALSE
;
613 str
= HeapAlloc(GetProcessHeap(), 0, count
+1);
617 for(i
= 0; i
< count
; i
++)
618 str
[i
] = (BYTE
)(iFirstChar
+ i
);
621 wstr
= FONT_mbtowc(hdc
, str
, count
+1, &wlen
, NULL
);
624 HeapFree(GetProcessHeap(), 0, str
);
628 ret
= NtGdiGetCharWidthW( hdc
,
635 HeapFree(GetProcessHeap(), 0, str
);
636 HeapFree(GetProcessHeap(), 0, wstr
);
653 INT i
, wlen
, count
= (INT
)(iLastChar
- iFirstChar
+ 1);
658 DPRINT("GetCharWidths32A\n");
659 if(count
<= 0) return FALSE
;
661 str
= HeapAlloc(GetProcessHeap(), 0, count
+1);
664 for(i
= 0; i
< count
; i
++)
665 str
[i
] = (BYTE
)(iFirstChar
+ i
);
668 wstr
= FONT_mbtowc(hdc
, str
, count
+1, &wlen
, NULL
);
671 HeapFree(GetProcessHeap(), 0, str
);
675 ret
= NtGdiGetCharWidthW( hdc
,
679 GCW_NOFLOAT
|GCW_WIN32
,
682 HeapFree(GetProcessHeap(), 0, str
);
683 HeapFree(GetProcessHeap(), 0, wstr
);
700 INT i
, wlen
, count
= (INT
)(iLastChar
- iFirstChar
+ 1);
705 DPRINT("GetCharWidthsFloatA\n");
706 if(count
<= 0) return FALSE
;
708 str
= HeapAlloc(GetProcessHeap(), 0, count
+1);
711 for(i
= 0; i
< count
; i
++)
712 str
[i
] = (BYTE
)(iFirstChar
+ i
);
715 wstr
= FONT_mbtowc(hdc
, str
, count
+1, &wlen
, NULL
);
718 HeapFree(GetProcessHeap(), 0, str
);
721 ret
= NtGdiGetCharWidthW( hdc
, wstr
[0], (ULONG
) count
, (PWCHAR
) wstr
, 0, (PVOID
) pxBuffer
);
723 HeapFree(GetProcessHeap(), 0, str
);
724 HeapFree(GetProcessHeap(), 0, wstr
);
741 INT i
, wlen
, count
= (INT
)(uLastChar
- uFirstChar
+ 1);
746 DPRINT("GetCharABCWidthsA\n");
747 if(count
<= 0) return FALSE
;
749 str
= HeapAlloc(GetProcessHeap(), 0, count
+1);
752 for(i
= 0; i
< count
; i
++)
753 str
[i
] = (BYTE
)(uFirstChar
+ i
);
756 wstr
= FONT_mbtowc(hdc
, str
, count
+1, &wlen
, NULL
);
759 HeapFree(GetProcessHeap(), 0, str
);
763 ret
= NtGdiGetCharABCWidthsW( hdc
,
770 HeapFree(GetProcessHeap(), 0, str
);
771 HeapFree(GetProcessHeap(), 0, wstr
);
781 GetCharABCWidthsFloatA(
788 INT i
, wlen
, count
= (INT
)(iLastChar
- iFirstChar
+ 1);
793 DPRINT("GetCharABCWidthsFloatA\n");
794 if (count
<= 0) return FALSE
;
796 str
= HeapAlloc(GetProcessHeap(), 0, count
+1);
800 for(i
= 0; i
< count
; i
++)
801 str
[i
] = (BYTE
)(iFirstChar
+ i
);
804 wstr
= FONT_mbtowc( hdc
, str
, count
+1, &wlen
, NULL
);
807 HeapFree( GetProcessHeap(), 0, str
);
810 ret
= NtGdiGetCharABCWidthsW( hdc
,wstr
[0],(ULONG
)count
, (PWCHAR
)wstr
, 0, (PVOID
)lpABCF
);
812 HeapFree( GetProcessHeap(), 0, str
);
813 HeapFree( GetProcessHeap(), 0, wstr
);
823 GetCharABCWidthsI(HDC hdc
,
829 DPRINT("GetCharABCWidthsI\n");
830 return NtGdiGetCharABCWidthsW( hdc
,
834 GCABCW_NOFLOAT
|GCABCW_INDICES
,
843 GetCharWidthI(HDC hdc
,
850 DPRINT("GetCharWidthsI\n");
851 if (!lpBuffer
|| (!pgi
&& (giFirst
== MAXUSHORT
))) // Cannot be at max.
853 SetLastError(ERROR_INVALID_PARAMETER
);
856 if (!cgi
) return TRUE
;
857 return NtGdiGetCharWidthW( hdc
,
861 GCW_INDICES
|GCW_NOFLOAT
|GCW_WIN32
,
874 DWORD Gcp
= 0, Ret
= 0;
877 Ret
= NtGdiGetTextCharsetInfo(hDc
, NULL
, 0);
878 if ((Ret
== ARABIC_CHARSET
) || (Ret
== HEBREW_CHARSET
))
879 Ret
= (GCP_KASHIDA
|GCP_DIACRITIC
|GCP_LIGATE
|GCP_GLYPHSHAPE
|GCP_REORDER
);
881 Gcp
= GetDCDWord(hDc
, GdiGetFontLanguageInfo
, GCP_ERROR
);
882 if ( Gcp
== GCP_ERROR
)
906 lpstrW
= FONT_mbtowc(hdc
, lpstr
, count
, &countW
, NULL
);
907 Ret
= NtGdiGetGlyphIndicesW(hdc
, lpstrW
, countW
, pgi
, flags
);
908 HeapFree(GetProcessHeap(), 0, lpstrW
);
931 DPRINT("GetGlyphOutlineA uChar %x\n", uChar
);
932 if (!lpgm
|| !lpmat2
) return GDI_ERROR
;
933 if(!(uFormat
& GGO_GLYPH_INDEX
)) {
936 if(uChar
> 0xff) { /* but, 2 bytes character only */
938 mbchs
[0] = (uChar
& 0xff00) >> 8;
939 mbchs
[1] = (uChar
& 0xff);
942 mbchs
[0] = (uChar
& 0xff);
944 p
= FONT_mbtowc(hdc
, mbchs
, len
, NULL
, NULL
);
948 ret
= NtGdiGetGlyphOutline(hdc
, c
, uFormat
, lpgm
, cbBuffer
, lpvBuffer
, (CONST LPMAT2
)lpmat2
, TRUE
);
949 HeapFree(GetProcessHeap(), 0, p
);
969 DPRINT("GetGlyphOutlineW uChar %x\n", uChar
);
970 if (!lpgm
|| !lpmat2
) return GDI_ERROR
;
971 if (!lpvBuffer
) cbBuffer
= 0;
972 return NtGdiGetGlyphOutline ( hdc
, uChar
, uFormat
, lpgm
, cbBuffer
, lpvBuffer
, (CONST LPMAT2
)lpmat2
, TRUE
);
981 GetOutlineTextMetricsA(
984 LPOUTLINETEXTMETRICA lpOTM
989 OUTLINETEXTMETRICW
*lpOTMW
= (OUTLINETEXTMETRICW
*)buf
;
990 OUTLINETEXTMETRICA
*output
= lpOTM
;
993 if((ret
= GetOutlineTextMetricsW(hdc
, 0, NULL
)) == 0)
995 if(ret
> sizeof(buf
))
996 lpOTMW
= HeapAlloc(GetProcessHeap(), 0, ret
);
997 GetOutlineTextMetricsW(hdc
, ret
, lpOTMW
);
999 needed
= sizeof(OUTLINETEXTMETRICA
);
1000 if(lpOTMW
->otmpFamilyName
)
1001 needed
+= WideCharToMultiByte(CP_ACP
, 0,
1002 (WCHAR
*)((char*)lpOTMW
+ (int)lpOTMW
->otmpFamilyName
), -1,
1003 NULL
, 0, NULL
, NULL
);
1004 if(lpOTMW
->otmpFaceName
)
1005 needed
+= WideCharToMultiByte(CP_ACP
, 0,
1006 (WCHAR
*)((char*)lpOTMW
+ (int)lpOTMW
->otmpFaceName
), -1,
1007 NULL
, 0, NULL
, NULL
);
1008 if(lpOTMW
->otmpStyleName
)
1009 needed
+= WideCharToMultiByte(CP_ACP
, 0,
1010 (WCHAR
*)((char*)lpOTMW
+ (int)lpOTMW
->otmpStyleName
), -1,
1011 NULL
, 0, NULL
, NULL
);
1012 if(lpOTMW
->otmpFullName
)
1013 needed
+= WideCharToMultiByte(CP_ACP
, 0,
1014 (WCHAR
*)((char*)lpOTMW
+ (int)lpOTMW
->otmpFullName
), -1,
1015 NULL
, 0, NULL
, NULL
);
1022 DPRINT("needed = %d\n", needed
);
1024 /* Since the supplied buffer isn't big enough, we'll alloc one
1025 that is and memcpy the first cbData bytes into the lpOTM at
1027 output
= HeapAlloc(GetProcessHeap(), 0, needed
);
1029 ret
= output
->otmSize
= min(needed
, cbData
);
1030 FONT_TextMetricWToA( &lpOTMW
->otmTextMetrics
, &output
->otmTextMetrics
);
1031 output
->otmFiller
= 0;
1032 output
->otmPanoseNumber
= lpOTMW
->otmPanoseNumber
;
1033 output
->otmfsSelection
= lpOTMW
->otmfsSelection
;
1034 output
->otmfsType
= lpOTMW
->otmfsType
;
1035 output
->otmsCharSlopeRise
= lpOTMW
->otmsCharSlopeRise
;
1036 output
->otmsCharSlopeRun
= lpOTMW
->otmsCharSlopeRun
;
1037 output
->otmItalicAngle
= lpOTMW
->otmItalicAngle
;
1038 output
->otmEMSquare
= lpOTMW
->otmEMSquare
;
1039 output
->otmAscent
= lpOTMW
->otmAscent
;
1040 output
->otmDescent
= lpOTMW
->otmDescent
;
1041 output
->otmLineGap
= lpOTMW
->otmLineGap
;
1042 output
->otmsCapEmHeight
= lpOTMW
->otmsCapEmHeight
;
1043 output
->otmsXHeight
= lpOTMW
->otmsXHeight
;
1044 output
->otmrcFontBox
= lpOTMW
->otmrcFontBox
;
1045 output
->otmMacAscent
= lpOTMW
->otmMacAscent
;
1046 output
->otmMacDescent
= lpOTMW
->otmMacDescent
;
1047 output
->otmMacLineGap
= lpOTMW
->otmMacLineGap
;
1048 output
->otmusMinimumPPEM
= lpOTMW
->otmusMinimumPPEM
;
1049 output
->otmptSubscriptSize
= lpOTMW
->otmptSubscriptSize
;
1050 output
->otmptSubscriptOffset
= lpOTMW
->otmptSubscriptOffset
;
1051 output
->otmptSuperscriptSize
= lpOTMW
->otmptSuperscriptSize
;
1052 output
->otmptSuperscriptOffset
= lpOTMW
->otmptSuperscriptOffset
;
1053 output
->otmsStrikeoutSize
= lpOTMW
->otmsStrikeoutSize
;
1054 output
->otmsStrikeoutPosition
= lpOTMW
->otmsStrikeoutPosition
;
1055 output
->otmsUnderscoreSize
= lpOTMW
->otmsUnderscoreSize
;
1056 output
->otmsUnderscorePosition
= lpOTMW
->otmsUnderscorePosition
;
1059 ptr
= (char*)(output
+ 1);
1060 left
= needed
- sizeof(*output
);
1062 if(lpOTMW
->otmpFamilyName
) {
1063 output
->otmpFamilyName
= (LPSTR
)(ptr
- (char*)output
);
1064 len
= WideCharToMultiByte(CP_ACP
, 0,
1065 (WCHAR
*)((char*)lpOTMW
+ (int)lpOTMW
->otmpFamilyName
), -1,
1066 ptr
, left
, NULL
, NULL
);
1070 output
->otmpFamilyName
= 0;
1072 if(lpOTMW
->otmpFaceName
) {
1073 output
->otmpFaceName
= (LPSTR
)(ptr
- (char*)output
);
1074 len
= WideCharToMultiByte(CP_ACP
, 0,
1075 (WCHAR
*)((char*)lpOTMW
+ (int)lpOTMW
->otmpFaceName
), -1,
1076 ptr
, left
, NULL
, NULL
);
1080 output
->otmpFaceName
= 0;
1082 if(lpOTMW
->otmpStyleName
) {
1083 output
->otmpStyleName
= (LPSTR
)(ptr
- (char*)output
);
1084 len
= WideCharToMultiByte(CP_ACP
, 0,
1085 (WCHAR
*)((char*)lpOTMW
+ (int)lpOTMW
->otmpStyleName
), -1,
1086 ptr
, left
, NULL
, NULL
);
1090 output
->otmpStyleName
= 0;
1092 if(lpOTMW
->otmpFullName
) {
1093 output
->otmpFullName
= (LPSTR
)(ptr
- (char*)output
);
1094 len
= WideCharToMultiByte(CP_ACP
, 0,
1095 (WCHAR
*)((char*)lpOTMW
+ (int)lpOTMW
->otmpFullName
), -1,
1096 ptr
, left
, NULL
, NULL
);
1099 output
->otmpFullName
= 0;
1103 if(output
!= lpOTM
) {
1104 memcpy(lpOTM
, output
, cbData
);
1105 HeapFree(GetProcessHeap(), 0, output
);
1107 /* check if the string offsets really fit into the provided size */
1108 /* FIXME: should we check string length as well? */
1109 if ((UINT_PTR
)lpOTM
->otmpFamilyName
>= lpOTM
->otmSize
)
1110 lpOTM
->otmpFamilyName
= 0; /* doesn't fit */
1112 if ((UINT_PTR
)lpOTM
->otmpFaceName
>= lpOTM
->otmSize
)
1113 lpOTM
->otmpFaceName
= 0; /* doesn't fit */
1115 if ((UINT_PTR
)lpOTM
->otmpStyleName
>= lpOTM
->otmSize
)
1116 lpOTM
->otmpStyleName
= 0; /* doesn't fit */
1118 if ((UINT_PTR
)lpOTM
->otmpFullName
>= lpOTM
->otmSize
)
1119 lpOTM
->otmpFullName
= 0; /* doesn't fit */
1123 if(lpOTMW
!= (OUTLINETEXTMETRICW
*)buf
)
1124 HeapFree(GetProcessHeap(), 0, lpOTMW
);
1135 GetOutlineTextMetricsW(
1138 LPOUTLINETEXTMETRICW lpOTM
1141 TMDIFF Tmd
; // Should not be zero.
1143 return NtGdiGetOutlineTextMetricsInternalW(hdc
, cbData
, lpOTM
, &Tmd
);
1151 GetKerningPairsW(HDC hdc
,
1153 LPKERNINGPAIR pkpDst
)
1155 if ((cPairs
!= 0) || (pkpDst
== 0))
1157 return NtGdiGetKerningPairs(hdc
,cPairs
,pkpDst
);
1161 SetLastError(ERROR_INVALID_PARAMETER
);
1171 GetKerningPairsA( HDC hDC
,
1173 LPKERNINGPAIR kern_pairA
)
1178 DWORD i
, total_kern_pairs
, kern_pairs_copied
= 0;
1179 KERNINGPAIR
*kern_pairW
;
1181 if (!cPairs
&& kern_pairA
)
1183 SetLastError(ERROR_INVALID_PARAMETER
);
1187 charset
= GetTextCharset(hDC
);
1188 if (!TranslateCharsetInfo(ULongToPtr(charset
), &csi
, TCI_SRCCHARSET
))
1190 DPRINT1("Can't find codepage for charset %d\n", charset
);
1193 /* GetCPInfo() will fail on CP_SYMBOL, and WideCharToMultiByte is supposed
1194 * to fail on an invalid character for CP_SYMBOL.
1196 cpi
.DefaultChar
[0] = 0;
1197 if (csi
.ciACP
!= CP_SYMBOL
&& !GetCPInfo(csi
.ciACP
, &cpi
))
1199 DPRINT1("Can't find codepage %u info\n", csi
.ciACP
);
1202 DPRINT("charset %d => codepage %u\n", charset
, csi
.ciACP
);
1204 total_kern_pairs
= NtGdiGetKerningPairs(hDC
, 0, NULL
);
1205 if (!total_kern_pairs
) return 0;
1207 if (!cPairs
&& !kern_pairA
) return total_kern_pairs
;
1209 kern_pairW
= HeapAlloc(GetProcessHeap(), 0, total_kern_pairs
* sizeof(*kern_pairW
));
1210 GetKerningPairsW(hDC
, total_kern_pairs
, kern_pairW
);
1212 for (i
= 0; i
< total_kern_pairs
; i
++)
1216 if (!WideCharToMultiByte(csi
.ciACP
, 0, &kern_pairW
[i
].wFirst
, 1, &first
, 1, NULL
, NULL
))
1219 if (!WideCharToMultiByte(csi
.ciACP
, 0, &kern_pairW
[i
].wSecond
, 1, &second
, 1, NULL
, NULL
))
1222 if (first
== cpi
.DefaultChar
[0] || second
== cpi
.DefaultChar
[0])
1227 if (kern_pairs_copied
>= cPairs
) break;
1229 kern_pairA
->wFirst
= (BYTE
)first
;
1230 kern_pairA
->wSecond
= (BYTE
)second
;
1231 kern_pairA
->iKernAmount
= kern_pairW
[i
].iKernAmount
;
1234 kern_pairs_copied
++;
1237 HeapFree(GetProcessHeap(), 0, kern_pairW
);
1239 return kern_pairs_copied
;
1249 CreateFontIndirectExA(const ENUMLOGFONTEXDVA
*elfexd
)
1253 ENUMLOGFONTEXDVW Logfont
;
1255 EnumLogFontExW2A( (LPENUMLOGFONTEXA
) elfexd
,
1256 &Logfont
.elfEnumLogfontEx
);
1258 RtlCopyMemory( &Logfont
.elfDesignVector
,
1259 (PVOID
) &elfexd
->elfDesignVector
,
1260 sizeof(DESIGNVECTOR
));
1262 return NtGdiHfontCreate( &Logfont
, 0, 0, 0, NULL
);
1273 CreateFontIndirectExW(const ENUMLOGFONTEXDVW
*elfexd
)
1275 /* Msdn: Note, this function ignores the elfDesignVector member in
1280 return NtGdiHfontCreate((PENUMLOGFONTEXDVW
) elfexd
, 0, 0, 0, NULL
);
1291 CreateFontIndirectA(
1292 CONST LOGFONTA
*lplf
1299 LogFontA2W(&tlf
, lplf
);
1300 return CreateFontIndirectW(&tlf
);
1311 CreateFontIndirectW(
1312 CONST LOGFONTW
*lplf
1317 ENUMLOGFONTEXDVW Logfont
;
1319 RtlCopyMemory( &Logfont
.elfEnumLogfontEx
.elfLogFont
, lplf
, sizeof(LOGFONTW
));
1320 // Need something other than just cleaning memory here.
1321 // Guess? Use caller data to determine the rest.
1322 RtlZeroMemory( &Logfont
.elfEnumLogfontEx
.elfFullName
,
1323 sizeof(Logfont
.elfEnumLogfontEx
.elfFullName
));
1324 RtlZeroMemory( &Logfont
.elfEnumLogfontEx
.elfStyle
,
1325 sizeof(Logfont
.elfEnumLogfontEx
.elfStyle
));
1326 RtlZeroMemory( &Logfont
.elfEnumLogfontEx
.elfScript
,
1327 sizeof(Logfont
.elfEnumLogfontEx
.elfScript
));
1329 Logfont
.elfDesignVector
.dvNumAxes
= 0; // No more than MM_MAX_NUMAXES
1331 RtlZeroMemory( &Logfont
.elfDesignVector
, sizeof(DESIGNVECTOR
));
1333 return CreateFontIndirectExW(&Logfont
);
1354 DWORD fdwOutputPrecision
,
1355 DWORD fdwClipPrecision
,
1357 DWORD fdwPitchAndFamily
,
1361 ANSI_STRING StringA
;
1362 UNICODE_STRING StringU
;
1365 RtlInitAnsiString(&StringA
, (LPSTR
)lpszFace
);
1366 RtlAnsiStringToUnicodeString(&StringU
, &StringA
, TRUE
);
1368 ret
= CreateFontW(nHeight
,
1383 RtlFreeUnicodeString(&StringU
);
1404 DWORD fdwOutputPrecision
,
1405 DWORD fdwClipPrecision
,
1407 DWORD fdwPitchAndFamily
,
1413 logfont
.lfHeight
= nHeight
;
1414 logfont
.lfWidth
= nWidth
;
1415 logfont
.lfEscapement
= nEscapement
;
1416 logfont
.lfOrientation
= nOrientation
;
1417 logfont
.lfWeight
= nWeight
;
1418 logfont
.lfItalic
= fnItalic
;
1419 logfont
.lfUnderline
= fdwUnderline
;
1420 logfont
.lfStrikeOut
= fdwStrikeOut
;
1421 logfont
.lfCharSet
= fdwCharSet
;
1422 logfont
.lfOutPrecision
= fdwOutputPrecision
;
1423 logfont
.lfClipPrecision
= fdwClipPrecision
;
1424 logfont
.lfQuality
= fdwQuality
;
1425 logfont
.lfPitchAndFamily
= fdwPitchAndFamily
;
1427 if (NULL
!= lpszFace
)
1429 int Size
= sizeof(logfont
.lfFaceName
) / sizeof(WCHAR
);
1430 wcsncpy((wchar_t *)logfont
.lfFaceName
, lpszFace
, Size
- 1);
1431 /* Be 101% sure to have '\0' at end of string */
1432 logfont
.lfFaceName
[Size
- 1] = '\0';
1436 logfont
.lfFaceName
[0] = L
'\0';
1439 return CreateFontIndirectW(&logfont
);
1448 CreateScalableFontResourceA(
1451 LPCSTR lpszFontFile
,
1452 LPCSTR lpszCurrentPath
1464 AddFontResourceExW ( LPCWSTR lpszFilename
, DWORD fl
, PVOID pvReserved
)
1466 if (fl
& ~(FR_PRIVATE
| FR_NOT_ENUM
))
1468 SetLastError( ERROR_INVALID_PARAMETER
);
1472 return GdiAddFontResourceW(lpszFilename
, fl
,0);
1481 AddFontResourceExA ( LPCSTR lpszFilename
, DWORD fl
, PVOID pvReserved
)
1487 if (fl
& ~(FR_PRIVATE
| FR_NOT_ENUM
))
1489 SetLastError( ERROR_INVALID_PARAMETER
);
1493 Status
= HEAP_strdupA2W ( &FilenameW
, lpszFilename
);
1494 if ( !NT_SUCCESS (Status
) )
1496 SetLastError (RtlNtStatusToDosError(Status
));
1500 rc
= GdiAddFontResourceW ( FilenameW
, fl
, 0 );
1501 HEAP_free ( FilenameW
);
1511 AddFontResourceA ( LPCSTR lpszFilename
)
1517 Status
= HEAP_strdupA2W ( &FilenameW
, lpszFilename
);
1518 if ( !NT_SUCCESS (Status
) )
1520 SetLastError (RtlNtStatusToDosError(Status
));
1524 rc
= GdiAddFontResourceW ( FilenameW
, 0, 0);
1526 HEAP_free ( FilenameW
);
1537 AddFontResourceW ( LPCWSTR lpszFilename
)
1539 return GdiAddFontResourceW ( lpszFilename
, 0, 0 );
1548 RemoveFontResourceW(LPCWSTR lpFileName
)
1550 return RemoveFontResourceExW(lpFileName
,0,0);
1559 RemoveFontResourceA(LPCSTR lpFileName
)
1561 return RemoveFontResourceExA(lpFileName
,0,0);
1569 RemoveFontResourceExA(LPCSTR lpFileName
,
1577 /* FIXME the flags */
1579 /* FIXME NtGdiRemoveFontResource handle flags and pdv */
1581 Status
= HEAP_strdupA2W ( &lpFileNameW
, lpFileName
);
1582 if (!NT_SUCCESS (Status
))
1583 SetLastError (RtlNtStatusToDosError(Status
));
1587 HEAP_free ( lpFileNameW
);
1598 RemoveFontResourceExW(LPCWSTR lpFileName
,
1602 /* FIXME the flags */
1604 /* FIXME NtGdiRemoveFontResource handle flags and pdv */
1609 /***********************************************************************
1610 * GdiGetCharDimensions
1612 * Gets the average width of the characters in the English alphabet.
1615 * hdc [I] Handle to the device context to measure on.
1616 * lptm [O] Pointer to memory to store the text metrics into.
1617 * height [O] On exit, the maximum height of characters in the English alphabet.
1620 * The average width of characters in the English alphabet.
1623 * This function is used by the dialog manager to get the size of a dialog
1624 * unit. It should also be used by other pieces of code that need to know
1625 * the size of a dialog unit in logical units without having access to the
1626 * window handle of the dialog.
1627 * Windows caches the font metrics from this function, but we don't and
1628 * there doesn't appear to be an immediate advantage to do so.
1631 * GetTextExtentPointW, GetTextMetricsW, MapDialogRect.
1633 * Despite most of MSDN insisting that the horizontal base unit is
1634 * tmAveCharWidth it isn't. Knowledge base article Q145994
1635 * "HOWTO: Calculate Dialog Units When Not Using the System Font",
1636 * says that we should take the average of the 52 English upper and lower
1644 GdiGetCharDimensions(HDC hdc
, LPTEXTMETRICW lptm
, LONG
*height
)
1648 static const WCHAR alphabet
[] = {
1649 'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q',
1650 'r','s','t','u','v','w','x','y','z','A','B','C','D','E','F','G','H',
1651 'I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z',0};
1653 if(!GetTextMetricsW(hdc
, &tm
)) return 0;
1655 if(!GetTextExtentPointW(hdc
, alphabet
, 52, &sz
)) return 0;
1657 if (lptm
) *lptm
= tm
;
1658 if (height
) *height
= tm
.tmHeight
;
1660 return (sz
.cx
/ 26 + 1) / 2;
1663 /*************************************************************************
1664 * TranslateCharsetInfo [GDI32.@]
1666 * Fills a CHARSETINFO structure for a character set, code page, or
1667 * font. This allows making the correspondance between different labelings
1668 * (character set, Windows, ANSI, and OEM codepages, and Unicode ranges)
1669 * of the same encoding.
1671 * Only one codepage will be set in lpCs->fs. If TCI_SRCFONTSIG is used,
1672 * only one codepage should be set in *lpSrc.
1675 * TRUE on success, FALSE on failure.
1683 TranslateCharsetInfo(
1684 LPDWORD lpSrc
, /* [in]
1685 if flags == TCI_SRCFONTSIG: pointer to fsCsb of a FONTSIGNATURE
1686 if flags == TCI_SRCCHARSET: a character set value
1687 if flags == TCI_SRCCODEPAGE: a code page value
1689 LPCHARSETINFO lpCs
, /* [out] structure to receive charset information */
1690 DWORD flags
/* [in] determines interpretation of lpSrc */)
1694 case TCI_SRCFONTSIG
:
1695 while (!(*lpSrc
>>index
& 0x0001) && index
<MAXTCIINDEX
) index
++;
1697 case TCI_SRCCODEPAGE
:
1698 while (PtrToUlong(lpSrc
) != FONT_tci
[index
].ciACP
&& index
< MAXTCIINDEX
) index
++;
1700 case TCI_SRCCHARSET
:
1701 while (PtrToUlong(lpSrc
) != FONT_tci
[index
].ciCharset
&& index
< MAXTCIINDEX
) index
++;
1706 if (index
>= MAXTCIINDEX
|| FONT_tci
[index
].ciCharset
== DEFAULT_CHARSET
) return FALSE
;
1707 memcpy(lpCs
, &FONT_tci
[index
], sizeof(CHARSETINFO
));
1722 DWORD Ret
= GDI_ERROR
;
1725 if (GDI_HANDLE_GET_TYPE(hDC
) != GDI_OBJECT_TYPE_DC
)
1727 if (GDI_HANDLE_GET_TYPE(hDC
) == GDI_OBJECT_TYPE_METADC
)
1728 return MFDRV_SetMapperFlags( hDC
, flags
);
1731 PLDC pLDC
= Dc_Attr
->pvLDC
;
1734 SetLastError(ERROR_INVALID_HANDLE
);
1737 if (pLDC
->iType
== LDC_EMFLDC
)
1739 return EMFDRV_SetMapperFlags( hDC
, flags
);
1744 if (!GdiGetHandleUserData((HGDIOBJ
) hDC
, GDI_OBJECT_TYPE_DC
, (PVOID
) &Dc_Attr
)) return GDI_ERROR
;
1746 if (NtCurrentTeb()->GdiTebBatch
.HDC
== hDC
)
1748 if (Dc_Attr
->ulDirty_
& DC_FONTTEXT_DIRTY
)
1751 Dc_Attr
->ulDirty_
&= ~(DC_MODE_DIRTY
|DC_FONTTEXT_DIRTY
);
1756 SetLastError(ERROR_INVALID_PARAMETER
);
1759 Ret
= Dc_Attr
->flFontMapper
;
1760 Dc_Attr
->flFontMapper
= flags
;
1774 FONTENUMPROCW FontFunc
,
1779 return NtGdiEnumFonts ( hDC
, lpFaceName
, FontFunc
, lParam
);
1781 return EnumFontFamiliesW( hDC
, lpFaceName
, FontFunc
, lParam
);
1793 FONTENUMPROCA FontFunc
,
1802 Status
= HEAP_strdupA2W ( &lpFaceNameW
, lpFaceName
);
1803 if (!NT_SUCCESS (Status
))
1804 SetLastError (RtlNtStatusToDosError(Status
));
1807 rc
= NtGdiEnumFonts ( hDC
, lpFaceNameW
, FontFunc
, lParam
);
1809 HEAP_free ( lpFaceNameW
);
1813 return EnumFontFamiliesA( hDC
, lpFaceName
, FontFunc
, lParam
);
1817 #define EfdFontFamilies 3
1821 NewEnumFontFamiliesExW(
1823 LPLOGFONTW lpLogfont
,
1824 FONTENUMPROCW lpEnumFontFamExProcW
,
1828 ULONG_PTR idEnum
, cbDataSize
, cbRetSize
;
1829 PENUMFONTDATAW pEfdw
;
1834 /* Open enumeration handle and find out how much memory we need */
1835 idEnum
= NtGdiEnumFontOpen(hDC
,
1839 (lpLogfont
&& lpLogfont
->lfFaceName
[0])? lpLogfont
->lfFaceName
: NULL
,
1840 lpLogfont
? lpLogfont
->lfCharSet
: DEFAULT_CHARSET
,
1846 if (cbDataSize
== 0)
1848 NtGdiEnumFontClose(idEnum
);
1852 /* Allocate memory */
1853 pBuffer
= HeapAlloc(GetProcessHeap(), 0, cbDataSize
);
1854 if (pBuffer
== NULL
)
1856 SetLastError(ERROR_NOT_ENOUGH_MEMORY
);
1857 NtGdiEnumFontClose(idEnum
);
1861 /* Do the enumeration */
1862 if (!NtGdiEnumFontChunk(hDC
, idEnum
, cbDataSize
, &cbRetSize
, (PVOID
)pBuffer
))
1864 HeapFree(GetProcessHeap(), 0, pBuffer
);
1865 NtGdiEnumFontClose(idEnum
);
1869 /* Get start and end address */
1870 pEfdw
= (PENUMFONTDATAW
)pBuffer
;
1871 pMax
= pBuffer
+ cbDataSize
;
1873 /* Iterate through the structures */
1874 while ((PBYTE
)pEfdw
< pMax
&& ret
)
1876 PNTMW_INTERNAL pNtmwi
= (PNTMW_INTERNAL
)((ULONG_PTR
)pEfdw
+ pEfdw
->ulNtmwiOffset
);
1878 ret
= lpEnumFontFamExProcW((VOID
*)&pEfdw
->elfexdv
.elfEnumLogfontEx
,
1879 (VOID
*)&pNtmwi
->ntmw
,
1883 pEfdw
= (PENUMFONTDATAW
)((ULONG_PTR
)pEfdw
+ pEfdw
->cbSize
);
1886 /* Release the memory and close handle */
1887 HeapFree(GetProcessHeap(), 0, pBuffer
);
1888 NtGdiEnumFontClose(idEnum
);