- Move functions out of freetype. Implemented FT: GetKerningPairs and RealizationInfo. Other misc changes.

svn path=/trunk/; revision=37148
This commit is contained in:
James Tabor 2008-11-02 12:17:15 +00:00
parent 8e1c35ecc1
commit 174ffe7d8c
5 changed files with 1506 additions and 1313 deletions

View file

@ -67,8 +67,18 @@ typedef struct _FLOATGDI {
ULONG Dummy;
} FLOATGDI;
#define FDM_TYPE_TEXT_METRIC 0x80000000
typedef struct _FONTGDI {
FONTOBJ FontObj;
ULONG iUnique;
FLONG flType;
union{
DHPDEV dhpdev;
FT_Face face;
};
FLONG flRealizedType;
LONG lMaxNegA;
LONG lMaxNegC;
@ -76,7 +86,6 @@ typedef struct _FONTGDI {
TEXTMETRICW TextMetric;
LPWSTR Filename;
FT_Face face;
BYTE Underline;
BYTE StrikeOut;
} FONTGDI, *PFONTGDI;

View file

@ -94,6 +94,10 @@ BOOL FASTCALL ftGdiGetTextMetricsW(HDC,PTMW_INTERNAL);
DWORD FASTCALL ftGetFontLanguageInfo(PDC);
INT FASTCALL ftGdiGetTextCharsetInfo(PDC,PFONTSIGNATURE,DWORD);
DWORD FASTCALL ftGetFontUnicodeRanges(PFONTGDI, PGLYPHSET);
DWORD FASTCALL ftGdiGetFontData(PFONTGDI,DWORD,DWORD,PVOID,DWORD);
BOOL FASTCALL IntGdiGetFontResourceInfo(PUNICODE_STRING,PVOID,DWORD*,DWORD);
BOOL FASTCALL ftGdiRealizationInfo(PFONTGDI,PREALIZATION_INFO);
DWORD FASTCALL ftGdiGetKerningPairs(PFONTGDI,DWORD,LPKERNINGPAIR);
#define IntLockProcessPrivateFonts(W32Process) \
ExEnterCriticalRegionAndAcquireFastMutexUnsafe(&W32Process->PrivateFontListLock)

View file

@ -13,6 +13,48 @@
#define NDEBUG
#include <debug.h>
/** Internal ******************************************************************/
INT
FASTCALL
FontGetObject(PTEXTOBJ TFont, INT Count, PVOID Buffer)
{
if( Buffer == NULL ) return sizeof(LOGFONTW);
switch (Count)
{
case sizeof(ENUMLOGFONTEXDVW):
RtlCopyMemory( (LPENUMLOGFONTEXDVW) Buffer,
&TFont->logfont,
sizeof(ENUMLOGFONTEXDVW));
break;
case sizeof(ENUMLOGFONTEXW):
RtlCopyMemory( (LPENUMLOGFONTEXW) Buffer,
&TFont->logfont.elfEnumLogfontEx,
sizeof(ENUMLOGFONTEXW));
break;
case sizeof(EXTLOGFONTW):
case sizeof(ENUMLOGFONTW):
RtlCopyMemory((LPENUMLOGFONTW) Buffer,
&TFont->logfont.elfEnumLogfontEx.elfLogFont,
sizeof(ENUMLOGFONTW));
break;
case sizeof(LOGFONTW):
RtlCopyMemory((LPLOGFONTW) Buffer,
&TFont->logfont.elfEnumLogfontEx.elfLogFont,
sizeof(LOGFONTW));
break;
default:
SetLastWin32Error(ERROR_BUFFER_OVERFLOW);
return 0;
}
return Count;
}
/** Functions ******************************************************************/
INT
@ -62,6 +104,66 @@ NtGdiAddFontResourceW(
return Ret;
}
DWORD
STDCALL
NtGdiGetFontData(
HDC hDC,
DWORD Table,
DWORD Offset,
LPVOID Buffer,
DWORD Size)
{
PDC Dc;
PDC_ATTR Dc_Attr;
HFONT hFont;
PTEXTOBJ TextObj;
PFONTGDI FontGdi;
DWORD Result = GDI_ERROR;
NTSTATUS Status = STATUS_SUCCESS;
if (Buffer && Size)
{
_SEH_TRY
{
ProbeForRead(Buffer, Size, 1);
}
_SEH_HANDLE
{
Status = _SEH_GetExceptionCode();
}
_SEH_END
}
if (!NT_SUCCESS(Status)) return Result;
Dc = DC_LockDc(hDC);
if (Dc == NULL)
{
SetLastWin32Error(ERROR_INVALID_HANDLE);
return GDI_ERROR;
}
Dc_Attr = Dc->pDc_Attr;
if(!Dc_Attr) Dc_Attr = &Dc->Dc_Attr;
hFont = Dc_Attr->hlfntNew;
TextObj = TEXTOBJ_LockText(hFont);
DC_UnlockDc(Dc);
if (TextObj == NULL)
{
SetLastWin32Error(ERROR_INVALID_HANDLE);
return GDI_ERROR;
}
FontGdi = ObjToGDI(TextObj->Font, FONT);
Result = ftGdiGetFontData(FontGdi, Table, Offset, Buffer, Size);
TEXTOBJ_UnlockText(TextObj);
return Result;
}
/*
* @implemented
*/
@ -298,6 +400,107 @@ NtGdiGetOutlineTextMetricsInternalW (HDC hDC,
return Size;
}
W32KAPI
BOOL
APIENTRY
NtGdiGetFontResourceInfoInternalW(
IN LPWSTR pwszFiles,
IN ULONG cwc,
IN ULONG cFiles,
IN UINT cjIn,
OUT LPDWORD pdwBytes,
OUT LPVOID pvBuf,
IN DWORD dwType)
{
NTSTATUS Status = STATUS_SUCCESS;
DWORD dwBytes;
UNICODE_STRING SafeFileNames;
BOOL bRet = FALSE;
ULONG cbStringSize;
union
{
LOGFONTW logfontw;
WCHAR FullName[LF_FULLFACESIZE];
} Buffer;
/* FIXME: handle cFiles > 0 */
/* Check for valid dwType values
dwType == 4 seems to be handled by gdi32 only */
if (dwType == 4 || dwType > 5)
{
SetLastWin32Error(ERROR_INVALID_PARAMETER);
return FALSE;
}
/* Allocate a safe unicode string buffer */
cbStringSize = cwc * sizeof(WCHAR);
SafeFileNames.MaximumLength = SafeFileNames.Length = cbStringSize - sizeof(WCHAR);
SafeFileNames.Buffer = ExAllocatePoolWithTag(PagedPool,
cbStringSize,
TAG('R','T','S','U'));
if (!SafeFileNames.Buffer)
{
SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY);
return FALSE;
}
/* Check buffers and copy pwszFiles to safe unicode string */
_SEH_TRY
{
ProbeForRead(pwszFiles, cbStringSize, 1);
ProbeForWrite(pdwBytes, sizeof(DWORD), 1);
ProbeForWrite(pvBuf, cjIn, 1);
RtlCopyMemory(SafeFileNames.Buffer, pwszFiles, cbStringSize);
}
_SEH_HANDLE
{
Status = _SEH_GetExceptionCode();
}
_SEH_END
if(!NT_SUCCESS(Status))
{
SetLastNtError(Status);
/* Free the string buffer for the safe filename */
ExFreePool(SafeFileNames.Buffer);
return FALSE;
}
/* Do the actual call */
bRet = IntGdiGetFontResourceInfo(&SafeFileNames, &Buffer, &dwBytes, dwType);
/* Check if succeeded and the buffer is big enough */
if (bRet && cjIn >= dwBytes)
{
/* Copy the data back to caller */
_SEH_TRY
{
/* Buffers are already probed */
RtlCopyMemory(pvBuf, &Buffer, dwBytes);
*pdwBytes = dwBytes;
}
_SEH_HANDLE
{
Status = _SEH_GetExceptionCode();
}
_SEH_END
if(!NT_SUCCESS(Status))
{
SetLastNtError(Status);
bRet = FALSE;
}
}
/* Free the string for the safe filenames */
ExFreePool(SafeFileNames.Buffer);
return bRet;
}
HFONT
STDCALL
NtGdiHfontCreate(

File diff suppressed because it is too large Load diff

View file

@ -750,21 +750,34 @@ EngDitherColor(
}
/*
* @unimplemented
* @implemented
*/
BOOL APIENTRY
EngQuerySystemAttribute(
IN ENG_SYSTEM_ATTRIBUTE CapNum,
OUT PDWORD pCapability)
{
SYSTEM_BASIC_INFORMATION sbi;
SYSTEM_PROCESSOR_INFORMATION spi;
switch (CapNum)
{
case EngNumberOfProcessors:
*pCapability = 1;
NtQuerySystemInformation(
SystemBasicInformation,
&sbi,
sizeof(SYSTEM_BASIC_INFORMATION),
NULL);
*pCapability = sbi.NumberOfProcessors;
return TRUE;
case EngProcessorFeature:
*pCapability = 0;
NtQuerySystemInformation(
SystemProcessorInformation,
&spi,
sizeof(SYSTEM_PROCESSOR_INFORMATION),
NULL);
*pCapability = spi.ProcessorFeatureBits;
return TRUE;
default: