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 GetTextExtentPoint32W = 0
21 GetTextExtentPointW = 1
47 EngSetLastError(ERROR_INVALID_HANDLE
);
51 pdcattr
= pdc
->pdcattr
;
53 TextObj
= RealizeFontInit(pdcattr
->hlfntNew
);
56 Result
= TextIntGetTextExtentPoint( pdc
,
65 TEXTOBJ_UnlockText(TextObj
);
77 GetTextExtentExPointW = 0 and everything else that uses this.
78 GetTextExtentExPointI = 1
97 if ( (!String
&& Count
) || !pSize
)
99 EngSetLastError(ERROR_INVALID_PARAMETER
);
109 pdc
= DC_LockDc(hDC
);
112 EngSetLastError(ERROR_INVALID_HANDLE
);
115 pdcattr
= pdc
->pdcattr
;
117 TextObj
= RealizeFontInit(pdcattr
->hlfntNew
);
120 Result
= TextIntGetTextExtentPoint( pdc
,
129 TEXTOBJ_UnlockText(TextObj
);
140 NtGdiGetCharSet(HDC hDC
)
145 // If here, update everything!
149 EngSetLastError(ERROR_INVALID_HANDLE
);
152 cscp
= ftGdiGetTextCharsetInfo(Dc
, NULL
, 0);
153 pdcattr
= Dc
->pdcattr
;
154 pdcattr
->iCS_CP
= cscp
;
155 pdcattr
->ulDirty_
&= ~DIRTY_CHARSET
;
162 NtGdiGetRasterizerCaps(
163 OUT LPRASTERIZER_STATUS praststat
,
166 NTSTATUS Status
= STATUS_SUCCESS
;
167 RASTERIZER_STATUS rsSafe
;
169 if (praststat
&& cjBytes
)
171 if ( cjBytes
>= sizeof(RASTERIZER_STATUS
) ) cjBytes
= sizeof(RASTERIZER_STATUS
);
172 if ( ftGdiGetRasterizerCaps(&rsSafe
))
176 ProbeForWrite( praststat
,
177 sizeof(RASTERIZER_STATUS
),
179 RtlCopyMemory(praststat
, &rsSafe
, cjBytes
);
181 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
183 Status
= _SEH2_GetExceptionCode();
187 if (!NT_SUCCESS(Status
))
189 SetLastNtError(Status
);
201 NtGdiGetTextCharsetInfo(
203 OUT OPTIONAL LPFONTSIGNATURE lpSig
,
208 FONTSIGNATURE fsSafe
;
209 PFONTSIGNATURE pfsSafe
= &fsSafe
;
210 NTSTATUS Status
= STATUS_SUCCESS
;
215 EngSetLastError(ERROR_INVALID_HANDLE
);
216 return DEFAULT_CHARSET
;
219 if (!lpSig
) pfsSafe
= NULL
;
221 Ret
= HIWORD(ftGdiGetTextCharsetInfo( Dc
, pfsSafe
, dwFlags
));
225 if (Ret
== DEFAULT_CHARSET
)
226 RtlZeroMemory(pfsSafe
, sizeof(FONTSIGNATURE
));
230 ProbeForWrite( lpSig
,
231 sizeof(FONTSIGNATURE
),
233 RtlCopyMemory(lpSig
, pfsSafe
, sizeof(FONTSIGNATURE
));
235 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
237 Status
= _SEH2_GetExceptionCode();
241 if (!NT_SUCCESS(Status
))
243 SetLastNtError(Status
);
244 return DEFAULT_CHARSET
;
254 GetTextExtentExPointW = 0 and everything else that uses this.
255 GetTextExtentExPointI = 1
260 NtGdiGetTextExtentExW(
262 IN OPTIONAL LPWSTR UnsafeString
,
265 OUT OPTIONAL PULONG UnsafeFit
,
266 OUT OPTIONAL PULONG UnsafeDx
,
267 OUT LPSIZE UnsafeSize
,
283 EngSetLastError(ERROR_INVALID_PARAMETER
);
287 /* FIXME: Handle fl */
293 Status
= MmCopyToCaller(UnsafeSize
, &Size
, sizeof(SIZE
));
294 if (! NT_SUCCESS(Status
))
296 SetLastNtError(Status
);
302 String
= ExAllocatePoolWithTag(PagedPool
, Count
* sizeof(WCHAR
), GDITAG_TEXT
);
305 EngSetLastError(ERROR_NOT_ENOUGH_MEMORY
);
309 if (NULL
!= UnsafeDx
)
311 Dx
= ExAllocatePoolWithTag(PagedPool
, Count
* sizeof(INT
), GDITAG_TEXT
);
314 ExFreePoolWithTag(String
, GDITAG_TEXT
);
315 EngSetLastError(ERROR_NOT_ENOUGH_MEMORY
);
324 Status
= MmCopyFromCaller(String
, UnsafeString
, Count
* sizeof(WCHAR
));
325 if (! NT_SUCCESS(Status
))
329 ExFreePoolWithTag(Dx
, GDITAG_TEXT
);
331 ExFreePoolWithTag(String
, GDITAG_TEXT
);
332 SetLastNtError(Status
);
341 ExFreePoolWithTag(Dx
, GDITAG_TEXT
);
343 ExFreePoolWithTag(String
, GDITAG_TEXT
);
344 EngSetLastError(ERROR_INVALID_HANDLE
);
347 pdcattr
= dc
->pdcattr
;
348 TextObj
= RealizeFontInit(pdcattr
->hlfntNew
);
351 Result
= TextIntGetTextExtentPoint( dc
,
356 NULL
== UnsafeFit
? NULL
: &Fit
,
360 TEXTOBJ_UnlockText(TextObj
);
366 ExFreePoolWithTag(String
, GDITAG_TEXT
);
371 ExFreePoolWithTag(Dx
, GDITAG_TEXT
);
376 if (NULL
!= UnsafeFit
)
378 Status
= MmCopyToCaller(UnsafeFit
, &Fit
, sizeof(INT
));
379 if (! NT_SUCCESS(Status
))
383 ExFreePoolWithTag(Dx
, GDITAG_TEXT
);
385 SetLastNtError(Status
);
390 if (NULL
!= UnsafeDx
)
392 Status
= MmCopyToCaller(UnsafeDx
, Dx
, Count
* sizeof(INT
));
393 if (! NT_SUCCESS(Status
))
397 ExFreePoolWithTag(Dx
, GDITAG_TEXT
);
399 SetLastNtError(Status
);
405 ExFreePoolWithTag(Dx
, GDITAG_TEXT
);
408 Status
= MmCopyToCaller(UnsafeSize
, &Size
, sizeof(SIZE
));
409 if (! NT_SUCCESS(Status
))
411 SetLastNtError(Status
);
421 GetTextExtentPoint32W = 0
422 GetTextExtentPointW = 1
426 NtGdiGetTextExtent(HDC hdc
,
432 return NtGdiGetTextExtentExW(hdc
, lpwsz
, cwc
, 0, NULL
, NULL
, psize
, flOpts
);
437 NtGdiSetTextJustification(HDC hDC
,
444 pDc
= DC_LockDc(hDC
);
447 EngSetLastError(ERROR_INVALID_HANDLE
);
451 pdcattr
= pDc
->pdcattr
;
453 pdcattr
->lBreakExtra
= BreakExtra
;
454 pdcattr
->cBreak
= BreakCount
;
467 OUT OPTIONAL LPWSTR FaceName
,
478 /* FIXME: Handle bAliasName */
483 EngSetLastError(ERROR_INVALID_HANDLE
);
486 pdcattr
= Dc
->pdcattr
;
487 hFont
= pdcattr
->hlfntNew
;
490 TextObj
= RealizeFontInit(hFont
);
491 ASSERT(TextObj
!= NULL
);
492 fLen
= wcslen(TextObj
->logfont
.elfEnumLogfontEx
.elfLogFont
.lfFaceName
) + 1;
494 if (FaceName
!= NULL
)
496 Count
= min(Count
, fLen
);
497 Status
= MmCopyToCaller(FaceName
, TextObj
->logfont
.elfEnumLogfontEx
.elfLogFont
.lfFaceName
, Count
* sizeof(WCHAR
));
498 if (!NT_SUCCESS(Status
))
500 TEXTOBJ_UnlockText(TextObj
);
501 SetLastNtError(Status
);
504 /* Terminate if we copied only part of the font name */
505 if (Count
> 0 && Count
< fLen
)
507 FaceName
[Count
- 1] = '\0';
516 TEXTOBJ_UnlockText(TextObj
);
523 NtGdiGetTextMetricsW(
525 OUT TMW_INTERNAL
* pUnsafeTmwi
,
530 NTSTATUS Status
= STATUS_SUCCESS
;
532 if ( cj
<= sizeof(TMW_INTERNAL
) )
534 if (ftGdiGetTextMetricsW(hDC
, &Tmwi
))
538 ProbeForWrite(pUnsafeTmwi
, cj
, 1);
539 RtlCopyMemory(pUnsafeTmwi
, &Tmwi
, cj
);
541 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
543 Status
= _SEH2_GetExceptionCode();
547 if (!NT_SUCCESS(Status
))
549 SetLastNtError(Status
);