5 #undef WIN32_LEAN_AND_MEAN
9 #include <win32k/kapi.h>
22 return NtGdiSetTextAlign(a0, a1);
39 UNICODE_STRING StringU;
44 RtlInitAnsiString(&StringA, (LPSTR)String);
45 RtlAnsiStringToUnicodeString(&StringU, &StringA, TRUE);
47 StringU.Buffer = NULL;
49 ret = TextOutW(hDC, XStart, YStart, StringU.Buffer, Count);
50 RtlFreeUnicodeString(&StringU);
67 return NtGdiTextOut(hDC, XStart, YStart, String, Count);
75 SetTextColor(HDC hDC, COLORREF color)
77 return(NtGdiSetTextColor(hDC, color));
82 MetricsCharConvert(WCHAR w, CHAR *b)
84 UNICODE_STRING WString;
98 RtlInitUnicodeString(&WString, WBuf);
101 RtlInitAnsiString(&AString, ABuf);
103 Status = RtlUnicodeStringToAnsiString(&AString, &WString, FALSE);
104 if (! NT_SUCCESS(Status))
106 SetLastError(RtlNtStatusToDosError(Status));
127 UNICODE_STRING WString;
134 if (! NtGdiGetTextMetrics(hdc, &tmw))
139 tm->tmHeight = tmw.tmHeight;
140 tm->tmAscent = tmw.tmAscent;
141 tm->tmDescent = tmw.tmDescent;
142 tm->tmInternalLeading = tmw.tmInternalLeading;
143 tm->tmExternalLeading = tmw.tmExternalLeading;
144 tm->tmAveCharWidth = tmw.tmAveCharWidth;
145 tm->tmMaxCharWidth = tmw.tmMaxCharWidth;
146 tm->tmWeight = tmw.tmWeight;
147 tm->tmOverhang = tmw.tmOverhang;
148 tm->tmDigitizedAspectX = tmw.tmDigitizedAspectX;
149 tm->tmDigitizedAspectY = tmw.tmDigitizedAspectY;
151 /* The Unicode FirstChar/LastChar need not correspond to the ANSI
152 FirstChar/LastChar. For example, if the font contains glyphs for
153 letters A-Z and an accented version of the letter e, the Unicode
154 FirstChar would be A and the Unicode LastChar would be the accented
155 e. If you just translate those to ANSI, the range would become
156 letters A-E instead of A-Z.
157 We translate all possible ANSI chars to Unicode and find the first
158 and last translated character which fall into the Unicode FirstChar/
159 LastChar range and return the corresponding ANSI char. */
161 /* Setup an Ansi string containing all possible letters (note: skip '\0' at
162 the beginning since that would be interpreted as end-of-string, handle
163 '\0' special later */
164 for (Letter = 1; Letter < 256; Letter++)
166 ABuf[Letter - 1] = (CHAR) Letter;
167 WBuf[Letter - 1] = L' ';
171 RtlInitAnsiString(&AString, ABuf);
172 RtlInitUnicodeString(&WString, WBuf);
174 /* Find the corresponding Unicode characters */
175 Status = RtlAnsiStringToUnicodeString(&WString, &AString, FALSE);
176 if (! NT_SUCCESS(Status))
178 SetLastError(RtlNtStatusToDosError(Status));
182 /* Scan for the first ANSI character which maps to an Unicode character
184 tm->tmFirstChar = '\0';
185 if (L'\0' != tmw.tmFirstChar)
187 for (Letter = 1; Letter < 256; Letter++)
189 if (tmw.tmFirstChar <= WBuf[Letter - 1] &&
190 WBuf[Letter - 1] <= tmw.tmLastChar)
192 tm->tmFirstChar = (CHAR) Letter;
198 /* Scan for the last ANSI character which maps to an Unicode character
200 tm->tmLastChar = '\0';
201 if (L'\0' != tmw.tmLastChar)
203 for (Letter = 255; 0 < Letter; Letter--)
205 if (tmw.tmFirstChar <= WBuf[Letter - 1] &&
206 WBuf[Letter - 1] <= tmw.tmLastChar)
208 tm->tmLastChar = (CHAR) Letter;
214 if (! MetricsCharConvert(tmw.tmDefaultChar, &tm->tmDefaultChar) ||
215 ! MetricsCharConvert(tmw.tmBreakChar, &tm->tmBreakChar))
220 tm->tmItalic = tmw.tmItalic;
221 tm->tmUnderlined = tmw.tmUnderlined;
222 tm->tmStruckOut = tmw.tmStruckOut;
223 tm->tmPitchAndFamily = tmw.tmPitchAndFamily;
224 tm->tmCharSet = tmw.tmCharSet;
240 return NtGdiGetTextMetrics(hdc, tm);
257 UNICODE_STRING StringU;
260 RtlInitAnsiString(&StringA, (LPSTR)String);
261 RtlAnsiStringToUnicodeString(&StringU, &StringA, TRUE);
263 ret = GetTextExtentPointW(hDC, StringU.Buffer, Count, Size);
265 RtlFreeUnicodeString(&StringU);
283 return NtGdiGetTextExtentPoint(hDC, String, Count, Size);
292 GetTextExtentPoint32A(
300 UNICODE_STRING StringU;
303 RtlInitAnsiString(&StringA, (LPSTR)String);
304 RtlAnsiStringToUnicodeString(&StringU, &StringA, TRUE);
306 ret = GetTextExtentPoint32W(hDC, StringU.Buffer, Count, Size);
308 RtlFreeUnicodeString(&StringU);
319 GetTextExtentPoint32W(
326 return NtGdiGetTextExtentPoint32(hDC, String, Count, Size);
347 UNICODE_STRING StringU;
350 RtlInitAnsiString(&StringA, (LPSTR)String);
351 RtlAnsiStringToUnicodeString(&StringU, &StringA, TRUE);
353 ret = ExtTextOutW(hDC, X, Y, Options, Rect, StringU.Buffer, Count, Spacings);
355 RtlFreeUnicodeString(&StringU);
377 return NtGdiTextOut(hDC, X, Y, String, Count);
391 UNICODE_STRING StringU;
395 RtlInitAnsiString(&StringA, (LPSTR)lf->lfFaceName);
396 RtlAnsiStringToUnicodeString(&StringU, &StringA, TRUE);
397 memcpy(&tlf, lf, sizeof(LOGFONTA));
398 memcpy(&tlf.lfFaceName, &StringU.Buffer, StringU.Length);
400 ret = CreateFontIndirectW(&tlf);
402 RtlFreeUnicodeString(&StringU);
417 return NtGdiCreateFontIndirect((CONST LPLOGFONTW)lf);
436 DWORD OutputPrecision,
439 DWORD PitchAndFamily,
444 UNICODE_STRING StringU;
447 RtlInitAnsiString(&StringA, (LPSTR)Face);
448 RtlAnsiStringToUnicodeString(&StringU, &StringA, TRUE);
450 ret = CreateFontW(Height, Width, Escapement, Orientation, Weight, Italic, Underline, StrikeOut,
451 CharSet, OutputPrecision, ClipPrecision, Quality, PitchAndFamily, StringU.Buffer);
453 RtlFreeUnicodeString(&StringU);
474 DWORD OutputPrecision,
477 DWORD PitchAndFamily,
481 return NtGdiCreateFont(Height, Width, Escapement, Orientation, Weight, Italic, Underline, StrikeOut,
482 CharSet, OutputPrecision, ClipPrecision, Quality, PitchAndFamily, Face);