2003-05-18 17:16:18 +00:00
|
|
|
/*
|
2008-10-29 21:57:04 +00:00
|
|
|
* PROJECT: ReactOS win32 kernel mode subsystem
|
|
|
|
* LICENSE: GPL - See COPYING in the top level directory
|
|
|
|
* FILE: subsystems/win32/win32k/objects/text.c
|
2008-10-30 01:32:44 +00:00
|
|
|
* PURPOSE: Text/Font
|
2011-01-09 19:51:06 +00:00
|
|
|
* PROGRAMMER:
|
2003-05-18 17:16:18 +00:00
|
|
|
*/
|
2011-01-09 19:51:06 +00:00
|
|
|
|
2008-10-29 21:57:04 +00:00
|
|
|
/** Includes ******************************************************************/
|
2005-06-29 07:09:25 +00:00
|
|
|
|
2010-04-26 13:58:46 +00:00
|
|
|
#include <win32k.h>
|
2002-09-08 10:23:54 +00:00
|
|
|
|
2005-06-29 07:09:25 +00:00
|
|
|
#define NDEBUG
|
|
|
|
#include <debug.h>
|
|
|
|
|
2009-08-17 05:46:57 +00:00
|
|
|
/** Functions *****************************************************************/
|
|
|
|
|
2013-09-27 23:36:39 +00:00
|
|
|
BOOL FASTCALL
|
|
|
|
GreTextOutW(
|
|
|
|
HDC hdc,
|
|
|
|
int nXStart,
|
|
|
|
int nYStart,
|
|
|
|
LPCWSTR lpString,
|
|
|
|
int cchString)
|
|
|
|
{
|
|
|
|
return GreExtTextOutW(hdc, nXStart, nYStart, 0, NULL, (LPWSTR)lpString, cchString, NULL, 0);
|
|
|
|
}
|
|
|
|
|
2009-11-28 19:34:45 +00:00
|
|
|
/*
|
|
|
|
flOpts :
|
|
|
|
GetTextExtentPoint32W = 0
|
|
|
|
GetTextExtentPointW = 1
|
|
|
|
*/
|
2009-08-17 05:46:57 +00:00
|
|
|
BOOL
|
|
|
|
FASTCALL
|
|
|
|
GreGetTextExtentW(
|
|
|
|
HDC hDC,
|
|
|
|
LPWSTR lpwsz,
|
|
|
|
INT cwc,
|
|
|
|
LPSIZE psize,
|
|
|
|
UINT flOpts)
|
|
|
|
{
|
2011-12-11 20:09:53 +00:00
|
|
|
PDC pdc;
|
|
|
|
PDC_ATTR pdcattr;
|
|
|
|
BOOL Result;
|
|
|
|
PTEXTOBJ TextObj;
|
|
|
|
|
|
|
|
if (!cwc)
|
|
|
|
{
|
|
|
|
psize->cx = 0;
|
|
|
|
psize->cy = 0;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
pdc = DC_LockDc(hDC);
|
|
|
|
if (!pdc)
|
|
|
|
{
|
|
|
|
EngSetLastError(ERROR_INVALID_HANDLE);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
pdcattr = pdc->pdcattr;
|
|
|
|
|
|
|
|
TextObj = RealizeFontInit(pdcattr->hlfntNew);
|
|
|
|
if ( TextObj )
|
|
|
|
{
|
|
|
|
Result = TextIntGetTextExtentPoint( pdc,
|
|
|
|
TextObj,
|
|
|
|
lpwsz,
|
|
|
|
cwc,
|
|
|
|
0,
|
|
|
|
NULL,
|
|
|
|
0,
|
|
|
|
psize,
|
|
|
|
flOpts);
|
|
|
|
TEXTOBJ_UnlockText(TextObj);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
Result = FALSE;
|
|
|
|
|
|
|
|
DC_UnlockDc(pdc);
|
|
|
|
return Result;
|
2011-01-09 19:51:06 +00:00
|
|
|
}
|
2009-08-17 05:46:57 +00:00
|
|
|
|
2009-11-28 19:34:45 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
fl :
|
|
|
|
GetTextExtentExPointW = 0 and everything else that uses this.
|
|
|
|
GetTextExtentExPointI = 1
|
|
|
|
*/
|
2009-08-17 05:46:57 +00:00
|
|
|
BOOL
|
|
|
|
FASTCALL
|
|
|
|
GreGetTextExtentExW(
|
|
|
|
HDC hDC,
|
|
|
|
LPWSTR String,
|
|
|
|
ULONG Count,
|
|
|
|
ULONG MaxExtent,
|
|
|
|
PULONG Fit,
|
|
|
|
PULONG Dx,
|
|
|
|
LPSIZE pSize,
|
|
|
|
FLONG fl)
|
|
|
|
{
|
2011-12-11 20:09:53 +00:00
|
|
|
PDC pdc;
|
|
|
|
PDC_ATTR pdcattr;
|
|
|
|
BOOL Result;
|
|
|
|
PTEXTOBJ TextObj;
|
|
|
|
|
|
|
|
if ( (!String && Count ) || !pSize )
|
|
|
|
{
|
|
|
|
EngSetLastError(ERROR_INVALID_PARAMETER);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( !Count )
|
|
|
|
{
|
|
|
|
if ( Fit ) Fit = 0;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
pdc = DC_LockDc(hDC);
|
|
|
|
if (NULL == pdc)
|
|
|
|
{
|
|
|
|
EngSetLastError(ERROR_INVALID_HANDLE);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
pdcattr = pdc->pdcattr;
|
|
|
|
|
|
|
|
TextObj = RealizeFontInit(pdcattr->hlfntNew);
|
|
|
|
if ( TextObj )
|
|
|
|
{
|
|
|
|
Result = TextIntGetTextExtentPoint( pdc,
|
|
|
|
TextObj,
|
|
|
|
String,
|
|
|
|
Count,
|
|
|
|
MaxExtent,
|
|
|
|
(LPINT)Fit,
|
|
|
|
(LPINT)Dx,
|
|
|
|
pSize,
|
|
|
|
fl);
|
|
|
|
TEXTOBJ_UnlockText(TextObj);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
Result = FALSE;
|
|
|
|
|
|
|
|
DC_UnlockDc(pdc);
|
|
|
|
return Result;
|
2009-08-17 05:46:57 +00:00
|
|
|
}
|
2003-03-28 16:20:51 +00:00
|
|
|
|
2008-10-30 10:46:27 +00:00
|
|
|
DWORD
|
|
|
|
APIENTRY
|
|
|
|
NtGdiGetCharSet(HDC hDC)
|
|
|
|
{
|
2011-12-11 20:09:53 +00:00
|
|
|
PDC Dc;
|
|
|
|
PDC_ATTR pdcattr;
|
|
|
|
DWORD cscp;
|
|
|
|
// If here, update everything!
|
|
|
|
Dc = DC_LockDc(hDC);
|
|
|
|
if (!Dc)
|
|
|
|
{
|
|
|
|
EngSetLastError(ERROR_INVALID_HANDLE);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
cscp = ftGdiGetTextCharsetInfo(Dc, NULL, 0);
|
|
|
|
pdcattr = Dc->pdcattr;
|
|
|
|
pdcattr->iCS_CP = cscp;
|
|
|
|
pdcattr->ulDirty_ &= ~DIRTY_CHARSET;
|
|
|
|
DC_UnlockDc( Dc );
|
|
|
|
return cscp;
|
2008-10-30 10:46:27 +00:00
|
|
|
}
|
|
|
|
|
2008-10-30 01:32:44 +00:00
|
|
|
BOOL
|
|
|
|
APIENTRY
|
|
|
|
NtGdiGetRasterizerCaps(
|
|
|
|
OUT LPRASTERIZER_STATUS praststat,
|
|
|
|
IN ULONG cjBytes)
|
|
|
|
{
|
2011-12-11 20:09:53 +00:00
|
|
|
NTSTATUS Status = STATUS_SUCCESS;
|
|
|
|
RASTERIZER_STATUS rsSafe;
|
2008-10-30 01:32:44 +00:00
|
|
|
|
2011-12-11 20:09:53 +00:00
|
|
|
if (praststat && cjBytes)
|
|
|
|
{
|
|
|
|
if ( cjBytes >= sizeof(RASTERIZER_STATUS) ) cjBytes = sizeof(RASTERIZER_STATUS);
|
|
|
|
if ( ftGdiGetRasterizerCaps(&rsSafe))
|
2008-10-30 01:32:44 +00:00
|
|
|
{
|
2011-12-11 20:09:53 +00:00
|
|
|
_SEH2_TRY
|
|
|
|
{
|
|
|
|
ProbeForWrite( praststat,
|
|
|
|
sizeof(RASTERIZER_STATUS),
|
|
|
|
1);
|
|
|
|
RtlCopyMemory(praststat, &rsSafe, cjBytes );
|
|
|
|
}
|
|
|
|
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
|
|
|
|
{
|
|
|
|
Status = _SEH2_GetExceptionCode();
|
|
|
|
}
|
|
|
|
_SEH2_END;
|
|
|
|
|
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
SetLastNtError(Status);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
2008-10-30 01:32:44 +00:00
|
|
|
}
|
2011-12-11 20:09:53 +00:00
|
|
|
}
|
|
|
|
return FALSE;
|
2008-10-30 01:32:44 +00:00
|
|
|
}
|
|
|
|
|
2008-10-30 10:46:27 +00:00
|
|
|
INT
|
|
|
|
APIENTRY
|
|
|
|
NtGdiGetTextCharsetInfo(
|
|
|
|
IN HDC hdc,
|
|
|
|
OUT OPTIONAL LPFONTSIGNATURE lpSig,
|
|
|
|
IN DWORD dwFlags)
|
|
|
|
{
|
2011-12-11 20:09:53 +00:00
|
|
|
PDC Dc;
|
|
|
|
INT Ret;
|
|
|
|
FONTSIGNATURE fsSafe;
|
|
|
|
PFONTSIGNATURE pfsSafe = &fsSafe;
|
|
|
|
NTSTATUS Status = STATUS_SUCCESS;
|
|
|
|
|
|
|
|
Dc = DC_LockDc(hdc);
|
|
|
|
if (!Dc)
|
|
|
|
{
|
|
|
|
EngSetLastError(ERROR_INVALID_HANDLE);
|
|
|
|
return DEFAULT_CHARSET;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!lpSig) pfsSafe = NULL;
|
|
|
|
|
|
|
|
Ret = HIWORD(ftGdiGetTextCharsetInfo( Dc, pfsSafe, dwFlags));
|
|
|
|
|
|
|
|
if (lpSig)
|
|
|
|
{
|
|
|
|
if (Ret == DEFAULT_CHARSET)
|
|
|
|
RtlZeroMemory(pfsSafe, sizeof(FONTSIGNATURE));
|
|
|
|
|
|
|
|
_SEH2_TRY
|
|
|
|
{
|
|
|
|
ProbeForWrite( lpSig,
|
|
|
|
sizeof(FONTSIGNATURE),
|
|
|
|
1);
|
|
|
|
RtlCopyMemory(lpSig, pfsSafe, sizeof(FONTSIGNATURE));
|
|
|
|
}
|
|
|
|
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
|
|
|
|
{
|
|
|
|
Status = _SEH2_GetExceptionCode();
|
|
|
|
}
|
|
|
|
_SEH2_END;
|
|
|
|
|
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
SetLastNtError(Status);
|
|
|
|
return DEFAULT_CHARSET;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
DC_UnlockDc(Dc);
|
|
|
|
return Ret;
|
2008-10-30 10:46:27 +00:00
|
|
|
}
|
|
|
|
|
2009-11-28 19:34:45 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
fl :
|
|
|
|
GetTextExtentExPointW = 0 and everything else that uses this.
|
|
|
|
GetTextExtentExPointI = 1
|
|
|
|
*/
|
2008-10-30 01:32:44 +00:00
|
|
|
W32KAPI
|
|
|
|
BOOL
|
|
|
|
APIENTRY
|
|
|
|
NtGdiGetTextExtentExW(
|
|
|
|
IN HDC hDC,
|
|
|
|
IN OPTIONAL LPWSTR UnsafeString,
|
|
|
|
IN ULONG Count,
|
|
|
|
IN ULONG MaxExtent,
|
|
|
|
OUT OPTIONAL PULONG UnsafeFit,
|
|
|
|
OUT OPTIONAL PULONG UnsafeDx,
|
|
|
|
OUT LPSIZE UnsafeSize,
|
|
|
|
IN FLONG fl
|
|
|
|
)
|
|
|
|
{
|
2011-12-11 20:09:53 +00:00
|
|
|
PDC dc;
|
|
|
|
PDC_ATTR pdcattr;
|
|
|
|
LPWSTR String;
|
|
|
|
SIZE Size;
|
|
|
|
NTSTATUS Status;
|
|
|
|
BOOLEAN Result;
|
|
|
|
INT Fit;
|
|
|
|
LPINT Dx;
|
|
|
|
PTEXTOBJ TextObj;
|
|
|
|
|
2012-04-21 16:05:24 +00:00
|
|
|
if ((LONG)Count < 0)
|
|
|
|
{
|
|
|
|
EngSetLastError(ERROR_INVALID_PARAMETER);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2011-12-11 20:09:53 +00:00
|
|
|
/* FIXME: Handle fl */
|
|
|
|
|
|
|
|
if (0 == Count)
|
2008-10-30 01:32:44 +00:00
|
|
|
{
|
2011-12-11 20:09:53 +00:00
|
|
|
Size.cx = 0;
|
|
|
|
Size.cy = 0;
|
|
|
|
Status = MmCopyToCaller(UnsafeSize, &Size, sizeof(SIZE));
|
|
|
|
if (! NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
SetLastNtError(Status);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
return TRUE;
|
2008-10-30 01:32:44 +00:00
|
|
|
}
|
|
|
|
|
2011-12-11 20:09:53 +00:00
|
|
|
String = ExAllocatePoolWithTag(PagedPool, Count * sizeof(WCHAR), GDITAG_TEXT);
|
|
|
|
if (NULL == String)
|
2008-10-30 01:32:44 +00:00
|
|
|
{
|
2011-12-11 20:09:53 +00:00
|
|
|
EngSetLastError(ERROR_NOT_ENOUGH_MEMORY);
|
|
|
|
return FALSE;
|
2008-10-30 01:32:44 +00:00
|
|
|
}
|
|
|
|
|
2011-12-11 20:09:53 +00:00
|
|
|
if (NULL != UnsafeDx)
|
2008-10-30 01:32:44 +00:00
|
|
|
{
|
2011-12-11 20:09:53 +00:00
|
|
|
Dx = ExAllocatePoolWithTag(PagedPool, Count * sizeof(INT), GDITAG_TEXT);
|
|
|
|
if (NULL == Dx)
|
|
|
|
{
|
|
|
|
ExFreePoolWithTag(String, GDITAG_TEXT);
|
|
|
|
EngSetLastError(ERROR_NOT_ENOUGH_MEMORY);
|
|
|
|
return FALSE;
|
|
|
|
}
|
2008-10-30 01:32:44 +00:00
|
|
|
}
|
2011-12-11 20:09:53 +00:00
|
|
|
else
|
2008-10-30 01:32:44 +00:00
|
|
|
{
|
2011-12-11 20:09:53 +00:00
|
|
|
Dx = NULL;
|
2008-10-30 01:32:44 +00:00
|
|
|
}
|
|
|
|
|
2011-12-11 20:09:53 +00:00
|
|
|
Status = MmCopyFromCaller(String, UnsafeString, Count * sizeof(WCHAR));
|
|
|
|
if (! NT_SUCCESS(Status))
|
2008-10-30 01:32:44 +00:00
|
|
|
{
|
2011-12-11 20:09:53 +00:00
|
|
|
if (NULL != Dx)
|
|
|
|
{
|
|
|
|
ExFreePoolWithTag(Dx, GDITAG_TEXT);
|
|
|
|
}
|
|
|
|
ExFreePoolWithTag(String, GDITAG_TEXT);
|
|
|
|
SetLastNtError(Status);
|
|
|
|
return FALSE;
|
2008-10-30 01:32:44 +00:00
|
|
|
}
|
|
|
|
|
2011-12-11 20:09:53 +00:00
|
|
|
dc = DC_LockDc(hDC);
|
|
|
|
if (NULL == dc)
|
2008-10-30 01:32:44 +00:00
|
|
|
{
|
2011-12-11 20:09:53 +00:00
|
|
|
if (NULL != Dx)
|
|
|
|
{
|
|
|
|
ExFreePoolWithTag(Dx, GDITAG_TEXT);
|
|
|
|
}
|
|
|
|
ExFreePoolWithTag(String, GDITAG_TEXT);
|
|
|
|
EngSetLastError(ERROR_INVALID_HANDLE);
|
|
|
|
return FALSE;
|
2008-10-30 01:32:44 +00:00
|
|
|
}
|
2011-12-11 20:09:53 +00:00
|
|
|
pdcattr = dc->pdcattr;
|
|
|
|
TextObj = RealizeFontInit(pdcattr->hlfntNew);
|
|
|
|
if ( TextObj )
|
|
|
|
{
|
|
|
|
Result = TextIntGetTextExtentPoint( dc,
|
|
|
|
TextObj,
|
|
|
|
String,
|
|
|
|
Count,
|
|
|
|
MaxExtent,
|
|
|
|
NULL == UnsafeFit ? NULL : &Fit,
|
|
|
|
Dx,
|
|
|
|
&Size,
|
|
|
|
fl);
|
|
|
|
TEXTOBJ_UnlockText(TextObj);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
Result = FALSE;
|
|
|
|
DC_UnlockDc(dc);
|
2008-10-30 01:32:44 +00:00
|
|
|
|
2011-12-11 20:09:53 +00:00
|
|
|
ExFreePoolWithTag(String, GDITAG_TEXT);
|
|
|
|
if (! Result)
|
2008-10-30 01:32:44 +00:00
|
|
|
{
|
2011-12-11 20:09:53 +00:00
|
|
|
if (NULL != Dx)
|
|
|
|
{
|
|
|
|
ExFreePoolWithTag(Dx, GDITAG_TEXT);
|
|
|
|
}
|
|
|
|
return FALSE;
|
2008-10-30 01:32:44 +00:00
|
|
|
}
|
|
|
|
|
2011-12-11 20:09:53 +00:00
|
|
|
if (NULL != UnsafeFit)
|
2008-10-30 01:32:44 +00:00
|
|
|
{
|
2011-12-11 20:09:53 +00:00
|
|
|
Status = MmCopyToCaller(UnsafeFit, &Fit, sizeof(INT));
|
|
|
|
if (! NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
if (NULL != Dx)
|
|
|
|
{
|
|
|
|
ExFreePoolWithTag(Dx, GDITAG_TEXT);
|
|
|
|
}
|
|
|
|
SetLastNtError(Status);
|
|
|
|
return FALSE;
|
|
|
|
}
|
2008-10-30 01:32:44 +00:00
|
|
|
}
|
|
|
|
|
2011-12-11 20:09:53 +00:00
|
|
|
if (NULL != UnsafeDx)
|
2008-10-30 01:32:44 +00:00
|
|
|
{
|
2011-12-11 20:09:53 +00:00
|
|
|
Status = MmCopyToCaller(UnsafeDx, Dx, Count * sizeof(INT));
|
|
|
|
if (! NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
if (NULL != Dx)
|
|
|
|
{
|
|
|
|
ExFreePoolWithTag(Dx, GDITAG_TEXT);
|
|
|
|
}
|
|
|
|
SetLastNtError(Status);
|
|
|
|
return FALSE;
|
|
|
|
}
|
2008-10-30 01:32:44 +00:00
|
|
|
}
|
2011-12-11 20:09:53 +00:00
|
|
|
if (NULL != Dx)
|
2008-10-30 01:32:44 +00:00
|
|
|
{
|
2011-12-11 20:09:53 +00:00
|
|
|
ExFreePoolWithTag(Dx, GDITAG_TEXT);
|
2008-10-30 01:32:44 +00:00
|
|
|
}
|
|
|
|
|
2011-12-11 20:09:53 +00:00
|
|
|
Status = MmCopyToCaller(UnsafeSize, &Size, sizeof(SIZE));
|
|
|
|
if (! NT_SUCCESS(Status))
|
2008-10-30 01:32:44 +00:00
|
|
|
{
|
2011-12-11 20:09:53 +00:00
|
|
|
SetLastNtError(Status);
|
|
|
|
return FALSE;
|
2008-10-30 01:32:44 +00:00
|
|
|
}
|
|
|
|
|
2011-12-11 20:09:53 +00:00
|
|
|
return TRUE;
|
2008-10-30 01:32:44 +00:00
|
|
|
}
|
|
|
|
|
2009-11-28 19:34:45 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
flOpts :
|
|
|
|
GetTextExtentPoint32W = 0
|
|
|
|
GetTextExtentPointW = 1
|
|
|
|
*/
|
2008-10-30 01:32:44 +00:00
|
|
|
BOOL
|
2008-11-29 22:48:58 +00:00
|
|
|
APIENTRY
|
2008-10-30 01:32:44 +00:00
|
|
|
NtGdiGetTextExtent(HDC hdc,
|
|
|
|
LPWSTR lpwsz,
|
|
|
|
INT cwc,
|
|
|
|
LPSIZE psize,
|
|
|
|
UINT flOpts)
|
|
|
|
{
|
2011-12-11 20:09:53 +00:00
|
|
|
return NtGdiGetTextExtentExW(hdc, lpwsz, cwc, 0, NULL, NULL, psize, flOpts);
|
2008-10-30 01:32:44 +00:00
|
|
|
}
|
|
|
|
|
2008-10-29 21:57:04 +00:00
|
|
|
BOOL
|
2008-11-29 22:48:58 +00:00
|
|
|
APIENTRY
|
2008-10-29 21:57:04 +00:00
|
|
|
NtGdiSetTextJustification(HDC hDC,
|
|
|
|
int BreakExtra,
|
|
|
|
int BreakCount)
|
2007-04-27 05:42:25 +00:00
|
|
|
{
|
2011-12-11 20:09:53 +00:00
|
|
|
PDC pDc;
|
|
|
|
PDC_ATTR pdcattr;
|
2008-03-19 00:56:40 +00:00
|
|
|
|
2011-12-11 20:09:53 +00:00
|
|
|
pDc = DC_LockDc(hDC);
|
|
|
|
if (!pDc)
|
|
|
|
{
|
|
|
|
EngSetLastError(ERROR_INVALID_HANDLE);
|
|
|
|
return FALSE;
|
|
|
|
}
|
2004-03-23 00:18:54 +00:00
|
|
|
|
2011-12-11 20:09:53 +00:00
|
|
|
pdcattr = pDc->pdcattr;
|
2004-03-23 00:18:54 +00:00
|
|
|
|
2011-12-11 20:09:53 +00:00
|
|
|
pdcattr->lBreakExtra = BreakExtra;
|
|
|
|
pdcattr->cBreak = BreakCount;
|
2004-03-23 00:18:54 +00:00
|
|
|
|
2011-12-11 20:09:53 +00:00
|
|
|
DC_UnlockDc(pDc);
|
|
|
|
return TRUE;
|
2004-03-23 00:18:54 +00:00
|
|
|
}
|
|
|
|
|
2008-10-30 01:32:44 +00:00
|
|
|
|
|
|
|
W32KAPI
|
|
|
|
INT
|
|
|
|
APIENTRY
|
|
|
|
NtGdiGetTextFaceW(
|
|
|
|
IN HDC hDC,
|
|
|
|
IN INT Count,
|
|
|
|
OUT OPTIONAL LPWSTR FaceName,
|
|
|
|
IN BOOL bAliasName
|
|
|
|
)
|
|
|
|
{
|
2011-12-11 20:09:53 +00:00
|
|
|
PDC Dc;
|
|
|
|
PDC_ATTR pdcattr;
|
|
|
|
HFONT hFont;
|
|
|
|
PTEXTOBJ TextObj;
|
|
|
|
NTSTATUS Status;
|
|
|
|
INT fLen, ret;
|
|
|
|
|
|
|
|
/* FIXME: Handle bAliasName */
|
|
|
|
|
|
|
|
Dc = DC_LockDc(hDC);
|
|
|
|
if (Dc == NULL)
|
|
|
|
{
|
|
|
|
EngSetLastError(ERROR_INVALID_HANDLE);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
pdcattr = Dc->pdcattr;
|
|
|
|
hFont = pdcattr->hlfntNew;
|
|
|
|
DC_UnlockDc(Dc);
|
|
|
|
|
|
|
|
TextObj = RealizeFontInit(hFont);
|
|
|
|
ASSERT(TextObj != NULL);
|
|
|
|
fLen = wcslen(TextObj->logfont.elfEnumLogfontEx.elfLogFont.lfFaceName) + 1;
|
|
|
|
|
|
|
|
if (FaceName != NULL)
|
|
|
|
{
|
|
|
|
Count = min(Count, fLen);
|
|
|
|
Status = MmCopyToCaller(FaceName, TextObj->logfont.elfEnumLogfontEx.elfLogFont.lfFaceName, Count * sizeof(WCHAR));
|
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
TEXTOBJ_UnlockText(TextObj);
|
|
|
|
SetLastNtError(Status);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
/* Terminate if we copied only part of the font name */
|
|
|
|
if (Count > 0 && Count < fLen)
|
|
|
|
{
|
|
|
|
FaceName[Count - 1] = '\0';
|
|
|
|
}
|
|
|
|
ret = Count;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ret = fLen;
|
|
|
|
}
|
|
|
|
|
|
|
|
TEXTOBJ_UnlockText(TextObj);
|
|
|
|
return ret;
|
2008-10-30 01:32:44 +00:00
|
|
|
}
|
|
|
|
|
2008-10-30 10:46:27 +00:00
|
|
|
W32KAPI
|
|
|
|
BOOL
|
|
|
|
APIENTRY
|
|
|
|
NtGdiGetTextMetricsW(
|
|
|
|
IN HDC hDC,
|
|
|
|
OUT TMW_INTERNAL * pUnsafeTmwi,
|
2013-03-05 08:47:51 +00:00
|
|
|
IN ULONG cj)
|
2008-10-30 10:46:27 +00:00
|
|
|
{
|
2011-12-11 20:09:53 +00:00
|
|
|
TMW_INTERNAL Tmwi;
|
2008-10-30 10:46:27 +00:00
|
|
|
|
2011-12-11 20:09:53 +00:00
|
|
|
if ( cj <= sizeof(TMW_INTERNAL) )
|
|
|
|
{
|
|
|
|
if (ftGdiGetTextMetricsW(hDC, &Tmwi))
|
2008-10-30 10:46:27 +00:00
|
|
|
{
|
2011-12-11 20:09:53 +00:00
|
|
|
_SEH2_TRY
|
|
|
|
{
|
|
|
|
ProbeForWrite(pUnsafeTmwi, cj, 1);
|
|
|
|
RtlCopyMemory(pUnsafeTmwi, &Tmwi, cj);
|
|
|
|
}
|
|
|
|
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
|
|
|
|
{
|
2013-03-05 08:47:51 +00:00
|
|
|
SetLastNtError(_SEH2_GetExceptionCode());
|
2013-03-05 20:03:30 +00:00
|
|
|
_SEH2_YIELD(return FALSE);
|
2011-12-11 20:09:53 +00:00
|
|
|
}
|
|
|
|
_SEH2_END
|
|
|
|
|
|
|
|
return TRUE;
|
2008-10-30 10:46:27 +00:00
|
|
|
}
|
2011-12-11 20:09:53 +00:00
|
|
|
}
|
|
|
|
return FALSE;
|
2008-10-30 10:46:27 +00:00
|
|
|
}
|
|
|
|
|
2003-05-18 17:16:18 +00:00
|
|
|
/* EOF */
|