update for HEAD-2003050101
[reactos.git] / lib / gdi32 / objects / text.c
1 #ifdef UNICODE
2 #undef UNICODE
3 #endif
4
5 #undef WIN32_LEAN_AND_MEAN
6 #include <string.h>
7 #include <windows.h>
8 #include <ddk/ntddk.h>
9 #include <win32k/kapi.h>
10
11 BOOL  
12 STDCALL 
13 TextOutA(
14         HDC  hDC,
15         int  XStart,
16         int  YStart,
17         LPCSTR  String,
18         int  Count)
19 {
20         ANSI_STRING StringA;
21         UNICODE_STRING StringU;
22         BOOL ret;
23
24         if (NULL != String)
25         {
26                 RtlInitAnsiString(&StringA, (LPSTR)String);
27                 RtlAnsiStringToUnicodeString(&StringU, &StringA, TRUE);
28         } else
29                 StringU.Buffer = NULL;
30
31         ret = TextOutW(hDC, XStart, YStart, StringU.Buffer, Count);
32         RtlFreeUnicodeString(&StringU);
33         return ret;
34 }
35
36 BOOL
37 STDCALL
38 TextOutW(
39         HDC  hDC,
40         int  XStart,
41         int  YStart,
42         LPCWSTR  String,
43         int  Count)
44 {
45         return W32kTextOut(hDC, XStart, YStart, String, Count);
46 }
47
48 COLORREF  STDCALL 
49 SetTextColor(HDC hDC, COLORREF color)
50 {
51   return(W32kSetTextColor(hDC, color));
52 }
53
54 BOOL 
55 STDCALL 
56 GetTextMetricsA(
57         HDC             hdc, 
58         LPTEXTMETRICA   tm
59         )
60 {
61         return W32kGetTextMetrics(hdc, (LPTEXTMETRICW) tm);
62 }
63
64 BOOL 
65 STDCALL 
66 GetTextMetricsW(
67         HDC             hdc, 
68         LPTEXTMETRICW   tm
69         )
70 {
71         return W32kGetTextMetrics(hdc, tm);
72 }
73
74 BOOL
75 APIENTRY
76 GetTextExtentPointA(
77         HDC             hDC,
78         LPCSTR          String,
79         int             Count,
80         LPSIZE          Size
81         )
82 {
83         ANSI_STRING StringA;
84         UNICODE_STRING StringU;
85         BOOL ret;
86
87         RtlInitAnsiString(&StringA, (LPSTR)String);
88         RtlAnsiStringToUnicodeString(&StringU, &StringA, TRUE);
89
90         ret = GetTextExtentPointW(hDC, StringU.Buffer, Count, Size);
91
92         RtlFreeUnicodeString(&StringU);
93
94         return ret;
95 }
96
97 BOOL
98 APIENTRY
99 GetTextExtentPointW(
100         HDC             hDC,
101         LPCWSTR         String,
102         int             Count,
103         LPSIZE          Size
104         )
105 {
106         return W32kGetTextExtentPoint(hDC, String, Count, Size);
107 }
108
109 BOOL  
110 STDCALL 
111 ExtTextOutA(
112         HDC             hDC, 
113         int             X, 
114         int             Y, 
115         UINT            Options, 
116         CONST RECT      *Rect,
117         LPCSTR          String, 
118         UINT            Count, 
119         CONST INT       *Spacings
120         )
121 {
122         ANSI_STRING StringA;
123         UNICODE_STRING StringU;
124         BOOL ret;
125
126         RtlInitAnsiString(&StringA, (LPSTR)String);
127         RtlAnsiStringToUnicodeString(&StringU, &StringA, TRUE);
128
129         ret = ExtTextOutW(hDC, X, Y, Options, Rect, StringU.Buffer, Count, Spacings);
130
131         RtlFreeUnicodeString(&StringU);
132
133         return ret;
134 }
135
136 BOOL  
137 STDCALL 
138 ExtTextOutW(
139         HDC             hDC, 
140         int             X, 
141         int             Y, 
142         UINT            Options,         
143         CONST RECT      *Rect,
144         LPCWSTR         String, 
145         UINT            Count, 
146         CONST INT       *Spacings
147         )
148 {
149         return W32kTextOut(hDC, X, Y, String, Count);
150 }
151
152 HFONT
153 STDCALL
154 CreateFontIndirectA(
155         CONST LOGFONTA          *lf
156         )
157 {
158         ANSI_STRING StringA;
159         UNICODE_STRING StringU;
160         HFONT ret;
161         LOGFONTW tlf;
162
163         RtlInitAnsiString(&StringA, (LPSTR)lf->lfFaceName);
164         RtlAnsiStringToUnicodeString(&StringU, &StringA, TRUE);
165         memcpy(&tlf, lf, sizeof(LOGFONTA));
166         memcpy(&tlf.lfFaceName, &StringU.Buffer, StringU.Length);
167
168         ret = CreateFontIndirectW(&tlf);
169
170         RtlFreeUnicodeString(&StringU);
171
172         return ret;
173 }
174
175 HFONT
176 STDCALL
177 CreateFontIndirectW(
178         CONST LOGFONTW          *lf
179         )
180 {
181         return W32kCreateFontIndirect((CONST LPLOGFONTW)lf);
182 }
183
184 HFONT
185 STDCALL
186 CreateFontA(
187         int     Height,
188         int     Width,
189         int     Escapement,
190         int     Orientation,
191         int     Weight,
192         DWORD   Italic,
193         DWORD   Underline,
194         DWORD   StrikeOut,
195         DWORD   CharSet,
196         DWORD   OutputPrecision,
197         DWORD   ClipPrecision,
198         DWORD   Quality,
199         DWORD   PitchAndFamily,
200         LPCSTR  Face
201         )
202 {
203         ANSI_STRING StringA;
204         UNICODE_STRING StringU;
205         HFONT ret;
206
207         RtlInitAnsiString(&StringA, (LPSTR)Face);
208         RtlAnsiStringToUnicodeString(&StringU, &StringA, TRUE);
209
210         ret = CreateFontW(Height, Width, Escapement, Orientation, Weight, Italic, Underline, StrikeOut,
211                           CharSet, OutputPrecision, ClipPrecision, Quality, PitchAndFamily, StringU.Buffer);
212
213         RtlFreeUnicodeString(&StringU);
214
215         return ret;
216 }
217
218 HFONT
219 STDCALL
220 CreateFontW(
221         int     Height,
222         int     Width,
223         int     Escapement,
224         int     Orientation,
225         int     Weight,
226         DWORD   Italic,
227         DWORD   Underline,
228         DWORD   StrikeOut,
229         DWORD   CharSet,
230         DWORD   OutputPrecision,
231         DWORD   ClipPrecision,
232         DWORD   Quality,
233         DWORD   PitchAndFamily,
234         LPCWSTR Face
235         )
236 {
237         return W32kCreateFont(Height, Width, Escapement, Orientation, Weight, Italic, Underline, StrikeOut,
238                           CharSet, OutputPrecision, ClipPrecision, Quality, PitchAndFamily, Face);
239 }
240