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 *****************************************************************/
26 return GreExtTextOutW(hdc
, nXStart
, nYStart
, 0, NULL
, (LPWSTR
)lpString
, cchString
, NULL
, 0);
31 GetTextExtentPoint32W = 0
32 GetTextExtentPointW = 1
58 EngSetLastError(ERROR_INVALID_HANDLE
);
62 pdcattr
= pdc
->pdcattr
;
64 TextObj
= RealizeFontInit(pdcattr
->hlfntNew
);
67 Result
= TextIntGetTextExtentPoint( pdc
,
76 TEXTOBJ_UnlockText(TextObj
);
88 GetTextExtentExPointW = 0 and everything else that uses this.
89 GetTextExtentExPointI = 1
108 if ( (!String
&& Count
) || !pSize
)
110 EngSetLastError(ERROR_INVALID_PARAMETER
);
120 pdc
= DC_LockDc(hDC
);
123 EngSetLastError(ERROR_INVALID_HANDLE
);
126 pdcattr
= pdc
->pdcattr
;
128 TextObj
= RealizeFontInit(pdcattr
->hlfntNew
);
131 Result
= TextIntGetTextExtentPoint( pdc
,
140 TEXTOBJ_UnlockText(TextObj
);
151 NtGdiGetCharSet(HDC hDC
)
156 // If here, update everything!
160 EngSetLastError(ERROR_INVALID_HANDLE
);
163 cscp
= ftGdiGetTextCharsetInfo(Dc
, NULL
, 0);
164 pdcattr
= Dc
->pdcattr
;
165 pdcattr
->iCS_CP
= cscp
;
166 pdcattr
->ulDirty_
&= ~DIRTY_CHARSET
;
173 NtGdiGetRasterizerCaps(
174 OUT LPRASTERIZER_STATUS praststat
,
177 NTSTATUS Status
= STATUS_SUCCESS
;
178 RASTERIZER_STATUS rsSafe
;
180 if (praststat
&& cjBytes
)
182 if ( cjBytes
>= sizeof(RASTERIZER_STATUS
) ) cjBytes
= sizeof(RASTERIZER_STATUS
);
183 if ( ftGdiGetRasterizerCaps(&rsSafe
))
187 ProbeForWrite( praststat
,
188 sizeof(RASTERIZER_STATUS
),
190 RtlCopyMemory(praststat
, &rsSafe
, cjBytes
);
192 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
194 Status
= _SEH2_GetExceptionCode();
198 if (!NT_SUCCESS(Status
))
200 SetLastNtError(Status
);
212 NtGdiGetTextCharsetInfo(
214 OUT OPTIONAL LPFONTSIGNATURE lpSig
,
219 FONTSIGNATURE fsSafe
;
220 PFONTSIGNATURE pfsSafe
= &fsSafe
;
221 NTSTATUS Status
= STATUS_SUCCESS
;
226 EngSetLastError(ERROR_INVALID_HANDLE
);
227 return DEFAULT_CHARSET
;
230 if (!lpSig
) pfsSafe
= NULL
;
232 Ret
= HIWORD(ftGdiGetTextCharsetInfo( Dc
, pfsSafe
, dwFlags
));
236 if (Ret
== DEFAULT_CHARSET
)
237 RtlZeroMemory(pfsSafe
, sizeof(FONTSIGNATURE
));
241 ProbeForWrite( lpSig
,
242 sizeof(FONTSIGNATURE
),
244 RtlCopyMemory(lpSig
, pfsSafe
, sizeof(FONTSIGNATURE
));
246 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
248 Status
= _SEH2_GetExceptionCode();
252 if (!NT_SUCCESS(Status
))
254 SetLastNtError(Status
);
255 return DEFAULT_CHARSET
;
265 GetTextExtentExPointW = 0 and everything else that uses this.
266 GetTextExtentExPointI = 1
271 NtGdiGetTextExtentExW(
273 IN OPTIONAL LPWSTR UnsafeString
,
276 OUT OPTIONAL PULONG UnsafeFit
,
277 OUT OPTIONAL PULONG UnsafeDx
,
278 OUT LPSIZE UnsafeSize
,
294 EngSetLastError(ERROR_INVALID_PARAMETER
);
298 /* FIXME: Handle fl */
304 Status
= MmCopyToCaller(UnsafeSize
, &Size
, sizeof(SIZE
));
305 if (! NT_SUCCESS(Status
))
307 SetLastNtError(Status
);
313 String
= ExAllocatePoolWithTag(PagedPool
, Count
* sizeof(WCHAR
), GDITAG_TEXT
);
316 EngSetLastError(ERROR_NOT_ENOUGH_MEMORY
);
320 if (NULL
!= UnsafeDx
)
322 Dx
= ExAllocatePoolWithTag(PagedPool
, Count
* sizeof(INT
), GDITAG_TEXT
);
325 ExFreePoolWithTag(String
, GDITAG_TEXT
);
326 EngSetLastError(ERROR_NOT_ENOUGH_MEMORY
);
335 Status
= MmCopyFromCaller(String
, UnsafeString
, Count
* sizeof(WCHAR
));
336 if (! NT_SUCCESS(Status
))
340 ExFreePoolWithTag(Dx
, GDITAG_TEXT
);
342 ExFreePoolWithTag(String
, GDITAG_TEXT
);
343 SetLastNtError(Status
);
352 ExFreePoolWithTag(Dx
, GDITAG_TEXT
);
354 ExFreePoolWithTag(String
, GDITAG_TEXT
);
355 EngSetLastError(ERROR_INVALID_HANDLE
);
358 pdcattr
= dc
->pdcattr
;
359 TextObj
= RealizeFontInit(pdcattr
->hlfntNew
);
362 Result
= TextIntGetTextExtentPoint( dc
,
367 NULL
== UnsafeFit
? NULL
: &Fit
,
371 TEXTOBJ_UnlockText(TextObj
);
377 ExFreePoolWithTag(String
, GDITAG_TEXT
);
382 ExFreePoolWithTag(Dx
, GDITAG_TEXT
);
387 if (NULL
!= UnsafeFit
)
389 Status
= MmCopyToCaller(UnsafeFit
, &Fit
, sizeof(INT
));
390 if (! NT_SUCCESS(Status
))
394 ExFreePoolWithTag(Dx
, GDITAG_TEXT
);
396 SetLastNtError(Status
);
401 if (NULL
!= UnsafeDx
)
403 Status
= MmCopyToCaller(UnsafeDx
, Dx
, Count
* sizeof(INT
));
404 if (! NT_SUCCESS(Status
))
408 ExFreePoolWithTag(Dx
, GDITAG_TEXT
);
410 SetLastNtError(Status
);
416 ExFreePoolWithTag(Dx
, GDITAG_TEXT
);
419 Status
= MmCopyToCaller(UnsafeSize
, &Size
, sizeof(SIZE
));
420 if (! NT_SUCCESS(Status
))
422 SetLastNtError(Status
);
432 GetTextExtentPoint32W = 0
433 GetTextExtentPointW = 1
437 NtGdiGetTextExtent(HDC hdc
,
443 return NtGdiGetTextExtentExW(hdc
, lpwsz
, cwc
, 0, NULL
, NULL
, psize
, flOpts
);
448 NtGdiSetTextJustification(HDC hDC
,
455 pDc
= DC_LockDc(hDC
);
458 EngSetLastError(ERROR_INVALID_HANDLE
);
462 pdcattr
= pDc
->pdcattr
;
464 pdcattr
->lBreakExtra
= BreakExtra
;
465 pdcattr
->cBreak
= BreakCount
;
478 OUT OPTIONAL LPWSTR FaceName
,
489 /* FIXME: Handle bAliasName */
494 EngSetLastError(ERROR_INVALID_HANDLE
);
497 pdcattr
= Dc
->pdcattr
;
498 hFont
= pdcattr
->hlfntNew
;
501 TextObj
= RealizeFontInit(hFont
);
502 ASSERT(TextObj
!= NULL
);
503 fLen
= wcslen(TextObj
->logfont
.elfEnumLogfontEx
.elfLogFont
.lfFaceName
) + 1;
505 if (FaceName
!= NULL
)
507 Count
= min(Count
, fLen
);
508 Status
= MmCopyToCaller(FaceName
, TextObj
->logfont
.elfEnumLogfontEx
.elfLogFont
.lfFaceName
, Count
* sizeof(WCHAR
));
509 if (!NT_SUCCESS(Status
))
511 TEXTOBJ_UnlockText(TextObj
);
512 SetLastNtError(Status
);
515 /* Terminate if we copied only part of the font name */
516 if (Count
> 0 && Count
< fLen
)
518 FaceName
[Count
- 1] = '\0';
527 TEXTOBJ_UnlockText(TextObj
);
534 NtGdiGetTextMetricsW(
536 OUT TMW_INTERNAL
* pUnsafeTmwi
,
541 if ( cj
<= sizeof(TMW_INTERNAL
) )
543 if (ftGdiGetTextMetricsW(hDC
, &Tmwi
))
547 ProbeForWrite(pUnsafeTmwi
, cj
, 1);
548 RtlCopyMemory(pUnsafeTmwi
, &Tmwi
, cj
);
550 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
552 SetLastNtError(_SEH2_GetExceptionCode());
553 _SEH2_YIELD(return FALSE
);