Skip to content

Commit 873bce1

Browse files
committed
[WIN32K]
Implement NtGdiGetFontData / PFE_ulQueryTrueTypeTable svn path=/branches/GSoC_2011/GdiFontDriver/; revision=56062
1 parent e44b2f4 commit 873bce1

File tree

3 files changed

+117
-20
lines changed

3 files changed

+117
-20
lines changed

win32ss/gdi/font/fntdrvsup.c

Lines changed: 34 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -51,22 +51,6 @@ DetachCSRSS(KAPC_STATE *pApcState)
5151
gbAttachedCSRSS = FALSE;
5252
}
5353

54-
VOID
55-
NTAPI
56-
RFONT_vInitDeviceMetrics(
57-
PRFONT prfnt)
58-
{
59-
PPDEVOBJ ppdev = (PPDEVOBJ)prfnt->hdevProducer;
60-
61-
ppdev->pldev->pfn.QueryFontData(prfnt->dhpdev,
62-
&prfnt->fobj,
63-
QFD_MAXEXTENTS,
64-
-1,
65-
NULL,
66-
&prfnt->fddm,
67-
sizeof(FD_DEVICEMETRICS));
68-
}
69-
7054
static
7155
VOID
7256
PFE_vInitialize(
@@ -114,6 +98,40 @@ PFE_vInitialize(
11498

11599
}
116100

101+
ULONG
102+
NTAPI
103+
PFE_ulQueryTrueTypeTable(
104+
PPFE ppfe,
105+
ULONG ulTableTag,
106+
PTRDIFF dpStart,
107+
ULONG cjBuffer,
108+
PVOID pvBuffer)
109+
{
110+
PPDEVOBJ ppdev = (PDEVOBJ*)ppfe->pPFF->hdev;
111+
KAPC_STATE ApcState;
112+
ULONG ulResult;
113+
114+
/* Attach to CSRSS */
115+
AttachCSRSS(&ApcState);
116+
117+
/* Call the driver to copy the requested data */
118+
ulResult = ppdev->pfn.QueryTrueTypeTable(ppfe->pPFF->hff,
119+
ppfe->iFont,
120+
ulTableTag,
121+
dpStart,
122+
cjBuffer,
123+
pvBuffer,
124+
NULL,
125+
NULL);
126+
127+
/* Detach from CSRSS */
128+
DetachCSRSS(&ApcState);
129+
130+
/* Return the result */
131+
return ulResult;
132+
}
133+
134+
117135
static
118136
VOID
119137
CopyFileName(

win32ss/gdi/font/font.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,12 @@ PPFE
392392
NTAPI
393393
LFONT_ppfe(PLFONT plfnt);
394394

395+
PRFONT
396+
NTAPI
397+
LFONT_prfntFindLinkedRFONT(
398+
_In_ PLFONT plfnt,
399+
_In_ PMATRIX pmxWorldToDevice);
400+
395401
VOID
396402
NTAPI
397403
UpcaseString(
@@ -404,6 +410,15 @@ NTAPI
404410
CalculateNameHash(
405411
PWSTR pwszName);
406412

413+
ULONG
414+
NTAPI
415+
PFE_ulQueryTrueTypeTable(
416+
PPFE ppfe,
417+
ULONG ulTableTag,
418+
PTRDIFF dpStart,
419+
ULONG cjBuffer,
420+
PVOID pvBuffer);
421+
407422
BOOL
408423
NTAPI
409424
PFT_bInit(

win32ss/gdi/font/fontdata.c

Lines changed: 68 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,75 @@ NtGdiGetFontData(
1818
IN HDC hdc,
1919
IN DWORD dwTable,
2020
IN DWORD dwOffset,
21-
OUT OPTIONAL PVOID pvBuf,
22-
IN ULONG cjBuf)
21+
OUT OPTIONAL PVOID pvBuffer,
22+
IN ULONG cjBuffer)
2323
{
24-
ASSERT(FALSE);
25-
return 0;
24+
PDC pdc;
25+
PRFONT prfnt;
26+
PVOID pvTempBuffer;
27+
ULONG ulResult;
28+
29+
/* Check if the caller provides a buffer */
30+
if (cjBuffer)
31+
{
32+
/* Must have a buffer */
33+
if (!pvBuffer) return GDI_ERROR;
34+
35+
/* Allocate a temp buffer */
36+
pvTempBuffer = ExAllocatePoolWithTag(PagedPool, cjBuffer, GDITAG_TEMP);
37+
if (!pvTempBuffer)
38+
{
39+
return GDI_ERROR;
40+
}
41+
}
42+
else
43+
{
44+
/* Don't provide a buffer */
45+
pvTempBuffer = NULL;
46+
}
47+
48+
/* Lock the DC */
49+
pdc = DC_LockDc(hdc);
50+
if (!pdc)
51+
{
52+
ulResult = GDI_ERROR;
53+
goto leave;
54+
}
55+
56+
/* Get the RFONT from the DC */
57+
prfnt = DC_prfnt(pdc);
58+
59+
/* Query the table data */
60+
ulResult = PFE_ulQueryTrueTypeTable(prfnt->ppfe,
61+
dwTable,
62+
dwOffset,
63+
cjBuffer,
64+
pvTempBuffer);
65+
66+
/* Copy the data back, if requested */
67+
if (cjBuffer && (ulResult != GDI_ERROR))
68+
{
69+
_SEH2_TRY
70+
{
71+
/* Probe and copy the data */
72+
ProbeForWrite(pvBuffer, cjBuffer, 1);
73+
RtlCopyMemory(pvBuffer, pvTempBuffer, cjBuffer);
74+
}
75+
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
76+
{
77+
ulResult = GDI_ERROR;
78+
}
79+
_SEH2_END;
80+
}
81+
82+
/* Unlock the DC */
83+
DC_UnlockDc(pdc);
84+
85+
leave:
86+
/* Free the temp buffer */
87+
if (pvTempBuffer) ExFreePoolWithTag(pvTempBuffer, GDITAG_TEMP);
88+
89+
return ulResult;
2690
}
2791

2892
W32KAPI

0 commit comments

Comments
 (0)