2 * PROJECT: ReactOS win32 kernel mode subsystem
3 * LICENSE: GPL - See COPYING in the top level directory
4 * FILE: win32ss/gdi/ntgdi/text.c
9 /** Includes ******************************************************************/
16 /** Functions *****************************************************************/
26 return GreExtTextOutW(hdc
, nXStart
, nYStart
, 0, NULL
, 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
);
153 _Out_ LPTEXTMETRICW lptm
)
156 if (!ftGdiGetTextMetricsW(hdc
, &tmwi
)) return FALSE
;
157 *lptm
= tmwi
.TextMetric
;
163 NtGdiGetCharSet(HDC hDC
)
168 // If here, update everything!
172 EngSetLastError(ERROR_INVALID_HANDLE
);
175 cscp
= ftGdiGetTextCharsetInfo(Dc
, NULL
, 0);
176 pdcattr
= Dc
->pdcattr
;
177 pdcattr
->iCS_CP
= cscp
;
178 pdcattr
->ulDirty_
&= ~DIRTY_CHARSET
;
185 NtGdiGetRasterizerCaps(
186 OUT LPRASTERIZER_STATUS praststat
,
189 NTSTATUS Status
= STATUS_SUCCESS
;
190 RASTERIZER_STATUS rsSafe
;
192 if (praststat
&& cjBytes
)
194 if ( cjBytes
>= sizeof(RASTERIZER_STATUS
) ) cjBytes
= sizeof(RASTERIZER_STATUS
);
195 if ( ftGdiGetRasterizerCaps(&rsSafe
))
199 ProbeForWrite( praststat
,
200 sizeof(RASTERIZER_STATUS
),
202 RtlCopyMemory(praststat
, &rsSafe
, cjBytes
);
204 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
206 Status
= _SEH2_GetExceptionCode();
210 if (!NT_SUCCESS(Status
))
212 SetLastNtError(Status
);
224 NtGdiGetTextCharsetInfo(
226 OUT OPTIONAL LPFONTSIGNATURE lpSig
,
231 FONTSIGNATURE fsSafe
;
232 PFONTSIGNATURE pfsSafe
= &fsSafe
;
233 NTSTATUS Status
= STATUS_SUCCESS
;
238 EngSetLastError(ERROR_INVALID_HANDLE
);
239 return DEFAULT_CHARSET
;
242 if (!lpSig
) pfsSafe
= NULL
;
244 Ret
= HIWORD(ftGdiGetTextCharsetInfo( Dc
, pfsSafe
, dwFlags
));
248 if (Ret
== DEFAULT_CHARSET
)
249 RtlZeroMemory(pfsSafe
, sizeof(FONTSIGNATURE
));
253 ProbeForWrite( lpSig
,
254 sizeof(FONTSIGNATURE
),
256 RtlCopyMemory(lpSig
, pfsSafe
, sizeof(FONTSIGNATURE
));
258 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
260 Status
= _SEH2_GetExceptionCode();
264 if (!NT_SUCCESS(Status
))
266 SetLastNtError(Status
);
267 return DEFAULT_CHARSET
;
277 GetTextExtentExPointW = 0 and everything else that uses this.
278 GetTextExtentExPointI = 1
283 NtGdiGetTextExtentExW(
285 IN OPTIONAL LPWSTR UnsafeString
,
288 OUT OPTIONAL PULONG UnsafeFit
,
289 OUT OPTIONAL PULONG UnsafeDx
,
290 OUT LPSIZE UnsafeSize
,
306 EngSetLastError(ERROR_INVALID_PARAMETER
);
310 /* FIXME: Handle fl */
316 Status
= MmCopyToCaller(UnsafeSize
, &Size
, sizeof(SIZE
));
317 if (! NT_SUCCESS(Status
))
319 SetLastNtError(Status
);
325 String
= ExAllocatePoolWithTag(PagedPool
, Count
* sizeof(WCHAR
), GDITAG_TEXT
);
328 EngSetLastError(ERROR_NOT_ENOUGH_MEMORY
);
332 if (NULL
!= UnsafeDx
)
334 Dx
= ExAllocatePoolWithTag(PagedPool
, Count
* sizeof(INT
), GDITAG_TEXT
);
337 ExFreePoolWithTag(String
, GDITAG_TEXT
);
338 EngSetLastError(ERROR_NOT_ENOUGH_MEMORY
);
347 Status
= MmCopyFromCaller(String
, UnsafeString
, Count
* sizeof(WCHAR
));
348 if (! NT_SUCCESS(Status
))
352 ExFreePoolWithTag(Dx
, GDITAG_TEXT
);
354 ExFreePoolWithTag(String
, GDITAG_TEXT
);
355 SetLastNtError(Status
);
364 ExFreePoolWithTag(Dx
, GDITAG_TEXT
);
366 ExFreePoolWithTag(String
, GDITAG_TEXT
);
367 EngSetLastError(ERROR_INVALID_HANDLE
);
370 pdcattr
= dc
->pdcattr
;
371 TextObj
= RealizeFontInit(pdcattr
->hlfntNew
);
374 Result
= TextIntGetTextExtentPoint( dc
,
379 NULL
== UnsafeFit
? NULL
: &Fit
,
383 TEXTOBJ_UnlockText(TextObj
);
389 ExFreePoolWithTag(String
, GDITAG_TEXT
);
394 ExFreePoolWithTag(Dx
, GDITAG_TEXT
);
399 if (NULL
!= UnsafeFit
)
401 Status
= MmCopyToCaller(UnsafeFit
, &Fit
, sizeof(INT
));
402 if (! NT_SUCCESS(Status
))
406 ExFreePoolWithTag(Dx
, GDITAG_TEXT
);
408 SetLastNtError(Status
);
413 if (NULL
!= UnsafeDx
)
415 Status
= MmCopyToCaller(UnsafeDx
, Dx
, Count
* sizeof(INT
));
416 if (! NT_SUCCESS(Status
))
420 ExFreePoolWithTag(Dx
, GDITAG_TEXT
);
422 SetLastNtError(Status
);
428 ExFreePoolWithTag(Dx
, GDITAG_TEXT
);
431 Status
= MmCopyToCaller(UnsafeSize
, &Size
, sizeof(SIZE
));
432 if (! NT_SUCCESS(Status
))
434 SetLastNtError(Status
);
444 GetTextExtentPoint32W = 0
445 GetTextExtentPointW = 1
449 NtGdiGetTextExtent(HDC hdc
,
455 return NtGdiGetTextExtentExW(hdc
, lpwsz
, cwc
, 0, NULL
, NULL
, psize
, flOpts
);
460 NtGdiSetTextJustification(HDC hDC
,
467 pDc
= DC_LockDc(hDC
);
470 EngSetLastError(ERROR_INVALID_HANDLE
);
474 pdcattr
= pDc
->pdcattr
;
476 pdcattr
->lBreakExtra
= BreakExtra
;
477 pdcattr
->cBreak
= BreakCount
;
490 OUT OPTIONAL LPWSTR FaceName
,
501 /* FIXME: Handle bAliasName */
506 EngSetLastError(ERROR_INVALID_HANDLE
);
509 pdcattr
= Dc
->pdcattr
;
510 hFont
= pdcattr
->hlfntNew
;
513 TextObj
= RealizeFontInit(hFont
);
514 ASSERT(TextObj
!= NULL
);
515 fLen
= wcslen(TextObj
->logfont
.elfEnumLogfontEx
.elfLogFont
.lfFaceName
) + 1;
517 if (FaceName
!= NULL
)
519 Count
= min(Count
, fLen
);
520 Status
= MmCopyToCaller(FaceName
, TextObj
->logfont
.elfEnumLogfontEx
.elfLogFont
.lfFaceName
, Count
* sizeof(WCHAR
));
521 if (!NT_SUCCESS(Status
))
523 TEXTOBJ_UnlockText(TextObj
);
524 SetLastNtError(Status
);
527 /* Terminate if we copied only part of the font name */
528 if (Count
> 0 && Count
< fLen
)
530 FaceName
[Count
- 1] = '\0';
539 TEXTOBJ_UnlockText(TextObj
);
546 NtGdiGetTextMetricsW(
548 OUT TMW_INTERNAL
* pUnsafeTmwi
,
553 if ( cj
<= sizeof(TMW_INTERNAL
) )
555 if (ftGdiGetTextMetricsW(hDC
, &Tmwi
))
559 ProbeForWrite(pUnsafeTmwi
, cj
, 1);
560 RtlCopyMemory(pUnsafeTmwi
, &Tmwi
, cj
);
562 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
564 SetLastNtError(_SEH2_GetExceptionCode());
565 _SEH2_YIELD(return FALSE
);