2 * PROJECT: ReactOS win32 kernel mode subsystem
3 * LICENSE: GPL - See COPYING in the top level directory
4 * FILE: subsystems/win32/win32k/objects/text.c
9 /** Includes ******************************************************************/
16 /** Functions ******************************************************************/
20 NtGdiGetCharSet(HDC hDC
)
25 // If here, update everything!
29 SetLastWin32Error(ERROR_INVALID_HANDLE
);
32 cscp
= ftGdiGetTextCharsetInfo(Dc
,NULL
,0);
33 pdcattr
= Dc
->pdcattr
;
34 pdcattr
->iCS_CP
= cscp
;
35 pdcattr
->ulDirty_
&= ~DIRTY_CHARSET
;
42 NtGdiGetRasterizerCaps(
43 OUT LPRASTERIZER_STATUS praststat
,
46 NTSTATUS Status
= STATUS_SUCCESS
;
47 RASTERIZER_STATUS rsSafe
;
49 if (praststat
&& cjBytes
)
51 if ( cjBytes
>= sizeof(RASTERIZER_STATUS
) ) cjBytes
= sizeof(RASTERIZER_STATUS
);
52 if ( ftGdiGetRasterizerCaps(&rsSafe
))
56 ProbeForWrite( praststat
,
57 sizeof(RASTERIZER_STATUS
),
59 RtlCopyMemory(praststat
, &rsSafe
, cjBytes
);
61 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
63 Status
= _SEH2_GetExceptionCode();
67 if (!NT_SUCCESS(Status
))
69 SetLastNtError(Status
);
79 NtGdiGetTextCharsetInfo(
81 OUT OPTIONAL LPFONTSIGNATURE lpSig
,
87 PFONTSIGNATURE pfsSafe
= &fsSafe
;
88 NTSTATUS Status
= STATUS_SUCCESS
;
93 SetLastWin32Error(ERROR_INVALID_HANDLE
);
94 return DEFAULT_CHARSET
;
97 if (!lpSig
) pfsSafe
= NULL
;
99 Ret
= HIWORD(ftGdiGetTextCharsetInfo( Dc
, pfsSafe
, dwFlags
));
103 if (Ret
== DEFAULT_CHARSET
)
104 RtlZeroMemory(pfsSafe
, sizeof(FONTSIGNATURE
));
108 ProbeForWrite( lpSig
,
109 sizeof(FONTSIGNATURE
),
111 RtlCopyMemory(lpSig
, pfsSafe
, sizeof(FONTSIGNATURE
));
113 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
115 Status
= _SEH2_GetExceptionCode();
119 if (!NT_SUCCESS(Status
))
121 SetLastNtError(Status
);
122 return DEFAULT_CHARSET
;
132 NtGdiGetTextExtentExW(
134 IN OPTIONAL LPWSTR UnsafeString
,
137 OUT OPTIONAL PULONG UnsafeFit
,
138 OUT OPTIONAL PULONG UnsafeDx
,
139 OUT LPSIZE UnsafeSize
,
153 /* FIXME: Handle fl */
159 Status
= MmCopyToCaller(UnsafeSize
, &Size
, sizeof(SIZE
));
160 if (! NT_SUCCESS(Status
))
162 SetLastNtError(Status
);
168 String
= ExAllocatePoolWithTag(PagedPool
, Count
* sizeof(WCHAR
), TAG_GDITEXT
);
171 SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY
);
175 if (NULL
!= UnsafeDx
)
177 Dx
= ExAllocatePoolWithTag(PagedPool
, Count
* sizeof(INT
), TAG_GDITEXT
);
180 ExFreePoolWithTag(String
, TAG_GDITEXT
);
181 SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY
);
190 Status
= MmCopyFromCaller(String
, UnsafeString
, Count
* sizeof(WCHAR
));
191 if (! NT_SUCCESS(Status
))
195 ExFreePoolWithTag(Dx
, TAG_GDITEXT
);
197 ExFreePoolWithTag(String
, TAG_GDITEXT
);
198 SetLastNtError(Status
);
207 ExFreePoolWithTag(Dx
, TAG_GDITEXT
);
209 ExFreePoolWithTag(String
, TAG_GDITEXT
);
210 SetLastWin32Error(ERROR_INVALID_HANDLE
);
213 pdcattr
= dc
->pdcattr
;
214 TextObj
= RealizeFontInit(pdcattr
->hlfntNew
);
217 Result
= TextIntGetTextExtentPoint(dc
, TextObj
, String
, Count
, MaxExtent
,
218 NULL
== UnsafeFit
? NULL
: &Fit
, Dx
, &Size
);
219 TEXTOBJ_UnlockText(TextObj
);
225 ExFreePoolWithTag(String
, TAG_GDITEXT
);
230 ExFreePoolWithTag(Dx
, TAG_GDITEXT
);
235 if (NULL
!= UnsafeFit
)
237 Status
= MmCopyToCaller(UnsafeFit
, &Fit
, sizeof(INT
));
238 if (! NT_SUCCESS(Status
))
242 ExFreePoolWithTag(Dx
, TAG_GDITEXT
);
244 SetLastNtError(Status
);
249 if (NULL
!= UnsafeDx
)
251 Status
= MmCopyToCaller(UnsafeDx
, Dx
, Count
* sizeof(INT
));
252 if (! NT_SUCCESS(Status
))
256 ExFreePoolWithTag(Dx
, TAG_GDITEXT
);
258 SetLastNtError(Status
);
264 ExFreePoolWithTag(Dx
,TAG_GDITEXT
);
267 Status
= MmCopyToCaller(UnsafeSize
, &Size
, sizeof(SIZE
));
268 if (! NT_SUCCESS(Status
))
270 SetLastNtError(Status
);
279 NtGdiGetTextExtent(HDC hdc
,
285 return NtGdiGetTextExtentExW(hdc
, lpwsz
, cwc
, 0, NULL
, NULL
, psize
, 0);
290 NtGdiSetTextJustification(HDC hDC
,
297 pDc
= DC_LockDc(hDC
);
300 SetLastWin32Error(ERROR_INVALID_HANDLE
);
304 pdcattr
= pDc
->pdcattr
;
306 pdcattr
->lBreakExtra
= BreakExtra
;
307 pdcattr
->cBreak
= BreakCount
;
320 OUT OPTIONAL LPWSTR FaceName
,
330 /* FIXME: Handle bAliasName */
335 SetLastWin32Error(ERROR_INVALID_HANDLE
);
338 pdcattr
= Dc
->pdcattr
;
339 hFont
= pdcattr
->hlfntNew
;
342 TextObj
= RealizeFontInit(hFont
);
343 ASSERT(TextObj
!= NULL
);
344 Count
= min(Count
, wcslen(TextObj
->logfont
.elfEnumLogfontEx
.elfLogFont
.lfFaceName
));
345 Status
= MmCopyToCaller(FaceName
, TextObj
->logfont
.elfEnumLogfontEx
.elfLogFont
.lfFaceName
, Count
* sizeof(WCHAR
));
346 TEXTOBJ_UnlockText(TextObj
);
347 if (!NT_SUCCESS(Status
))
349 SetLastNtError(Status
);
359 NtGdiGetTextMetricsW(
361 OUT TMW_INTERNAL
* pUnsafeTmwi
,
366 NTSTATUS Status
= STATUS_SUCCESS
;
368 if ( cj
<= sizeof(TMW_INTERNAL
) )
370 if (ftGdiGetTextMetricsW(hDC
,&Tmwi
))
374 ProbeForWrite(pUnsafeTmwi
, cj
, 1);
375 RtlCopyMemory(pUnsafeTmwi
,&Tmwi
,cj
);
377 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
379 Status
= _SEH2_GetExceptionCode();
383 if (!NT_SUCCESS(Status
))
385 SetLastNtError(Status
);