Skip to content

Commit ae7bdbe

Browse files
committed
[WIN32K] Add more font code
1 parent 1eeafc3 commit ae7bdbe

File tree

7 files changed

+287
-22
lines changed

7 files changed

+287
-22
lines changed

win32ss/gdi/font/dcfont.c

Lines changed: 100 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,31 +11,121 @@
1111
#define NDEBUG
1212
#include <debug.h>
1313

14+
PRFONT
15+
NTAPI
16+
LFONT_prfntFindRFONT(
17+
IN PLFONT plfnt)
18+
{
19+
20+
//if (!plfnt->hPFE) return NULL;
21+
22+
//ppfe = GDIOBJ_LockObject(plfnt->hPFE, 0);
23+
24+
//if (!ppfe) return NULL;
25+
26+
27+
return NULL;
28+
}
29+
30+
31+
PRFONT
32+
NTAPI
33+
RealizeFont()
34+
{
35+
36+
// 1. search for a realization that fits
37+
38+
//ppfe = PFT_ppfeFindBestMatch(ppft,
39+
40+
41+
//
42+
return NULL;
43+
}
44+
1445
PRFONT
1546
NTAPI
1647
DC_prfnt(PDC pdc)
1748
{
18-
PRFONT prfnt = 0;
49+
PRFONT prfnt = NULL;
50+
PLFONT plfnt;
51+
PPFE ppfe = NULL;
1952

2053
/* Select "current" font */
2154
DC_hSelectFont(pdc, pdc->pdcattr->hlfntNew);
2255

23-
/* Check if font is already realized */
24-
if (pdc->hlfntCur != pdc->dclevel.plfnt->baseobj.hHmgr)
56+
/* Get current LFONT */
57+
plfnt = pdc->dclevel.plfnt;
58+
59+
/* Check if the font is already realized */
60+
if (pdc->hlfntCur == plfnt->baseobj.hHmgr)
2561
{
26-
__debugbreak();
27-
//prfnt = LFONT_prfntRealizeFont(pdc->dclevel.plfnt);
62+
/* Return the RFONT */
63+
return pdc->prfnt;
2864

29-
/* Dereference the old RFONT */
30-
//RFONT_ShareUnlockFont(pdc->prfnt);
65+
}
3166

32-
pdc->prfnt = prfnt;
67+
/* Try to find a linked RFONT */
68+
prfnt = LFONT_prfntFindLinkedRFONT(plfnt, &pdc->dclevel.mxWorldToDevice);
3369

34-
/* Set as new active font */
35-
pdc->hlfntCur = pdc->pdcattr->hlfntNew;
70+
/* Check if we got one */
71+
if (!prfnt)
72+
{
73+
/* Check if the output device has fonts */
74+
if (pdc->ppdev->devinfo.cFonts != 0)
75+
{
76+
__debugbreak();
77+
// ppfe = PDEVOBJ_ppfe
78+
// if ppdev has no associated PFF
79+
// if cFonts == -1, call DrvQueryFont with iFile = 0, return is cFonts
80+
// create a PFF with cFonts PFEs
81+
// link the PFF to the PDEV
82+
// ppfe = PFF_pfeFindBestMatch(pff, ...)
83+
// loop all PFEs of the PFF
84+
// PFE_ulPenalty
85+
// set plfnt->hPFE
86+
}
87+
88+
/* Did we find a PFE yet? */
89+
if (!ppfe)
90+
{
91+
/* Get best matching PFE */
92+
ppfe = LFONT_ppfe(plfnt);
93+
}
94+
95+
/* Try to find a matching RFONT */
96+
prfnt = 0;//PFE_prfntFindRFONT(ppfe, plfnt->nSize, &pdc->dclevel.mxWorldToDevice);
97+
98+
/* Allocate a new RFONT */
99+
prfnt = RFONT_AllocRFONT();
100+
101+
/* Check if that succeeded */
102+
if (prfnt)
103+
{
104+
__debugbreak();
105+
}
106+
else
107+
{
108+
/* Fall back to the system font */
109+
if (!prfnt) prfnt = gprfntSystemTT;
110+
__debugbreak();
111+
}
36112
}
37113

38114
ASSERT(prfnt);
115+
116+
/* Reference the new and dereference the old RFONT */
117+
InterlockedIncrementUL(&prfnt->cSelected);
118+
if (InterlockedDecrementUL(&((PRFONT)pdc->prfnt)->cSelected) == 0)
119+
{
120+
/* Old RFONT is not in use anymore, delete it */
121+
//RFONT_vDeleteRFONT(pdc->prfnt);
122+
__debugbreak();
123+
}
124+
125+
/* Set as new active font */
126+
pdc->prfnt = prfnt;
127+
pdc->hlfntCur = pdc->dclevel.plfnt->baseobj.hHmgr;
128+
39129
return prfnt;
40130
}
41131

win32ss/gdi/font/font.h

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -260,15 +260,15 @@ typedef struct _RFONT
260260
POINTFX ptfxMaxDescent;
261261
TEXTMETRICW *ptmw;
262262
FD_GLYPHSET *pfdg;
263-
HGLYPH *phg;
263+
HGLYPH hgDefault;
264264
HGLYPH hgBreak;
265265
FIX fxBreak;
266266
void *wcgp;
267267

268268

269269
MATRIX mxWorldToDevice;
270270
MATRIX mxForDDI;
271-
//EXFORMOBJ xoForDDI;
271+
EXFORMOBJ xoForDDI;
272272

273273
POINTEF pteUnitAscent;
274274
FLOATOBJ efWtoDAscent;
@@ -391,6 +391,25 @@ LFONT_prfntFindLinkedRFONT(
391391
_In_ PLFONT plfnt,
392392
_In_ PMATRIX pmxWorldToDevice);
393393

394+
VOID
395+
NTAPI
396+
RFONT_vXlateGlpyhs(
397+
PRFONT prfnt,
398+
ULONG cwc,
399+
WCHAR *pwc,
400+
HGLYPH *phg);
401+
402+
FORCEINLINE
403+
HGLYPH
404+
RFONT_hgXlate(
405+
PRFONT prfnt,
406+
WCHAR wc)
407+
{
408+
HGLYPH hg;
409+
RFONT_vXlateGlpyhs(prfnt, 1, &wc, &hg);
410+
return hg;
411+
}
412+
394413
VOID
395414
NTAPI
396415
UpcaseString(

win32ss/gdi/font/fontdata.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -147,8 +147,7 @@ RFONT_vXlateGlpyhs(
147147
PRFONT prfnt,
148148
ULONG cwc,
149149
WCHAR *pwc,
150-
HGLYPH *phg,
151-
HGLYPH hgDefault)
150+
HGLYPH *phg)
152151
{
153152
FD_GLYPHSET *pfdg = prfnt->ppfe->pfdg;
154153
WCRUN *pwcrun;
@@ -160,7 +159,7 @@ RFONT_vXlateGlpyhs(
160159
while (cwc--)
161160
{
162161
wc = *pwc++;
163-
hg = hgDefault;
162+
hg = prfnt->hgDefault;
164163

165164
/* Loop all WCHAR runs */
166165
for (pwcrun = &pfdg->awcrun[0];

win32ss/gdi/font/fontrsrc.c

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,30 @@ PFE_ulPenalty(
305305
return ulPenalty;
306306
}
307307

308+
PPFE
309+
NTAPI
310+
PFF_ppfeFindBestMatch(
311+
PPFF ppff,
312+
LOGFONTW *plf,
313+
ULONG *pulPenalty)
314+
{
315+
ULONG ulPenalty, ulBestMatch = *pulPenalty;
316+
PPFE ppfeBestMatch;
317+
ULONG i;
318+
319+
/* Loop all PFEs */
320+
for (i = 0; i < ppff->cFonts; i++)
321+
{
322+
ulPenalty = PFE_ulPenalty(&ppff->apfe[i], plf, ulBestMatch);
323+
if (ulPenalty < ulBestMatch)
324+
{
325+
ppfeBestMatch = &ppff->apfe[i];
326+
ulBestMatch = ulPenalty;
327+
}
328+
}
329+
330+
return ppfeBestMatch;
331+
}
308332

309333
static
310334
PPFE
@@ -507,7 +531,9 @@ PFT_ppfeFindBestMatch(
507531
PHASHBUCKET pbkt;
508532
ULONG ulPenalty = *pulPenalty;
509533
PFONTSUBSTITUTE pfs = NULL;
534+
PPFF ppff;
510535
PPFE ppfe;
536+
ULONG iListIndex;
511537

512538
/* Acquire PFT lock for reading */
513539
EngAcquireSemaphoreShared(ppft->hsem);
@@ -538,7 +564,26 @@ PFT_ppfeFindBestMatch(
538564
else
539565
{
540566
TRACE("Font with face name '%ls' was not found!\n", pwszCapName);
541-
ulPenalty = PENALTY_FaceName;
567+
568+
/* Loop all slots in the font table */
569+
for (iListIndex = 0; iListIndex < ppft->cBuckets; iListIndex++)
570+
{
571+
/* Loop all font files (PFFs) in the slot */
572+
for (ppff = ppft->apPFF[iListIndex]; ppff; ppff = ppff->pPFFNext)
573+
{
574+
/* Find the best match in this PFF */
575+
ppfe = PFF_ppfeFindBestMatch(ppff, plf, &ulPenalty);
576+
577+
/* Bail out on an exact match */
578+
if (ulPenalty == 0) break;
579+
}
580+
581+
/* Bail out on an exact match */
582+
if (ulPenalty == 0) break;
583+
}
584+
585+
586+
ulPenalty += PENALTY_FaceName;
542587
}
543588

544589

win32ss/gdi/font/lfont.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,14 @@ LFONT_ppfe(PLFONT plfnt)
8484

8585
PRFONT
8686
NTAPI
87-
LFONT_prfntFindRFONT(
88-
IN PLFONT plfnt)
87+
LFONT_prfntFindLinkedRFONT(
88+
_In_ PLFONT plfnt,
89+
_In_ PMATRIX pmxWorldToDevice)
8990
{
90-
91+
// share lock plfnt->hsemRFONTList
92+
// loop plfnt->leRFONTList
93+
// compare each RFONT's world-to-device transformation
94+
// unlock plfnt->hsemRFONTList
9195
__debugbreak();
9296

9397
return NULL;

0 commit comments

Comments
 (0)