- Update Font types. Finish GetKerningPairs. Minor code cleanup.

svn path=/trunk/; revision=37201
This commit is contained in:
James Tabor 2008-11-05 13:02:15 +00:00
parent bf15620dbe
commit 0f59670d6e
4 changed files with 91 additions and 16 deletions

View file

@ -102,6 +102,11 @@ typedef struct _UMPDEV
WCHAR String[188];
} UMPDEV, *PUMPDEV;
#define LOCALFONT_COUNT 10
typedef struct _LOCALFONT
{
FONT_ATTR lfa[LOCALFONT_COUNT];
} LOCALFONT, *PLOCALFONT;
/* FUNCTIONS *****************************************************************/

View file

@ -330,8 +330,8 @@ typedef struct _BRUSH_ATTR // Used with pen too.
typedef struct _FONT_ATTR
{
DWORD dwUnknown;
void *pCharWidthData;
BOOL bSlowWidths;
PCFONT pCharWidthData;
} FONT_ATTR, *PFONT_ATTR;

View file

@ -402,8 +402,69 @@ NtGdiGetKerningPairs(HDC hDC,
ULONG NumPairs,
LPKERNINGPAIR krnpair)
{
UNIMPLEMENTED;
return 0;
PDC dc;
PDC_ATTR Dc_Attr;
PTEXTOBJ TextObj;
PFONTGDI FontGDI;
DWORD Count;
KERNINGPAIR *pKP;
NTSTATUS Status = STATUS_SUCCESS;
dc = DC_LockDc(hDC);
if (!dc)
{
SetLastWin32Error(ERROR_INVALID_HANDLE);
return 0;
}
Dc_Attr = dc->pDc_Attr;
if(!Dc_Attr) Dc_Attr = &dc->Dc_Attr;
TextObj = RealizeFontInit(Dc_Attr->hlfntNew);
DC_UnlockDc(dc);
if (!TextObj)
{
SetLastWin32Error(ERROR_INVALID_HANDLE);
return 0;
}
FontGDI = ObjToGDI(TextObj->Font, FONT);
TEXTOBJ_UnlockText(TextObj);
Count = ftGdiGetKerningPairs(FontGDI,0,NULL);
if ( Count && krnpair )
{
if (Count > NumPairs)
{
SetLastWin32Error(ERROR_INSUFFICIENT_BUFFER);
return 0;
}
pKP = ExAllocatePoolWithTag(PagedPool, Count * sizeof(KERNINGPAIR), TAG_GDITEXT);
if (!pKP)
{
SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY);
return 0;
}
ftGdiGetKerningPairs(FontGDI,Count,pKP);
_SEH_TRY
{
ProbeForWrite(krnpair, Count * sizeof(KERNINGPAIR), 1);
RtlCopyMemory(krnpair, pKP, Count * sizeof(KERNINGPAIR));
}
_SEH_HANDLE
{
Status = _SEH_GetExceptionCode();
}
_SEH_END
if (!NT_SUCCESS(Status))
{
SetLastWin32Error(ERROR_INVALID_PARAMETER);
Count = 0;
}
ExFreePoolWithTag(pKP,TAG_GDITEXT);
}
return Count;
}
/*
@ -424,7 +485,7 @@ NtGdiGetOutlineTextMetricsInternalW (HDC hDC,
HFONT hFont = 0;
ULONG Size;
OUTLINETEXTMETRICW *potm;
NTSTATUS Status;
NTSTATUS Status = STATUS_SUCCESS;
dc = DC_LockDc(hDC);
if (!dc)
@ -460,12 +521,21 @@ NtGdiGetOutlineTextMetricsInternalW (HDC hDC,
IntGetOutlineTextMetrics(FontGDI, Size, potm);
if (otm)
{
Status = MmCopyToCaller(otm, potm, Size);
if (! NT_SUCCESS(Status))
_SEH_TRY
{
ProbeForWrite(otm, Size, 1);
RtlCopyMemory(otm, potm, Size);
}
_SEH_HANDLE
{
Status = _SEH_GetExceptionCode();
}
_SEH_END
if (!NT_SUCCESS(Status))
{
SetLastWin32Error(ERROR_INVALID_PARAMETER);
ExFreePoolWithTag(potm,TAG_GDITEXT);
return 0;
Size = 0;
}
}
ExFreePoolWithTag(potm,TAG_GDITEXT);

View file

@ -2208,8 +2208,7 @@ ftGdiGetTextCharsetInfo(
TT_OS2 *pOS2;
FT_Face Face;
CHARSETINFO csi;
DWORD cp;
DWORD fs0;
DWORD cp, fs0;
USHORT usACP, usOEM;
Dc_Attr = Dc->pDc_Attr;
@ -2942,6 +2941,7 @@ ftGdiRealizationInfo(PFONTGDI Font, PREALIZATION_INFO Info)
return TRUE;
}
DWORD
FASTCALL
ftGdiGetKerningPairs( PFONTGDI Font,
@ -2949,22 +2949,20 @@ ftGdiGetKerningPairs( PFONTGDI Font,
LPKERNINGPAIR pKerningPair)
{
DWORD Count = 0;
FT_Face face;
face = Font->face;
INT i = 0;
FT_Face face = Font->face;
if (FT_HAS_KERNING(face) && face->charmap->encoding == FT_ENCODING_UNICODE)
{
FT_UInt previous_index = 0, glyph_index = 0;
FT_ULong char_code, char_previous;
FT_Vector delta;
int i;
char_previous = char_code = FT_Get_First_Char(face, &glyph_index);
IntUnLockFreeType;
for (i = 0; i < face->num_glyphs; i++)
while (glyph_index)
{
if (previous_index && glyph_index)
{
@ -2975,6 +2973,8 @@ ftGdiGetKerningPairs( PFONTGDI Font,
pKerningPair[i].wFirst = char_previous;
pKerningPair[i].wSecond = char_code;
pKerningPair[i].iKernAmount = delta.x;
i++;
if (i == cPairs) break;
}
Count++;
}