Skip to content

Commit de41ca8

Browse files
committed
[GDI FONT DRIVER]
- Set FM_INFO_OPTICALLY_FIXED_PITCH for fixed width fonts - Fix calculation of fixed width. Fixes display of fixed width fonts, like Lucida Console svn path=/branches/GSoC_2011/GdiFontDriver/; revision=53238
1 parent 5afe1fb commit de41ca8

File tree

3 files changed

+52
-32
lines changed

3 files changed

+52
-32
lines changed

win32ss/drivers/font/ftfd/font.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,8 @@ FtfdInitIfiMetrics(
111111
pifi->flInfo |= FM_INFO_NOT_CONTIGUOUS;
112112
if (pface->ulFontFormat != FMT_FNT)
113113
pifi->flInfo |= /*FM_INFO_RETURNS_OUTLINES |*/ FM_INFO_ARB_XFORMS;
114+
if (ftface->face_flags & FT_FACE_FLAG_FIXED_WIDTH)
115+
pifi->flInfo |= FM_INFO_OPTICALLY_FIXED_PITCH;
114116
pifi->flInfo |= FM_INFO_RIGHT_HANDED; // FIXME: how to determine?
115117

116118
/* Font resolution */

win32ss/drivers/font/ftfd/ftfd.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ typedef struct _POINTEF
141141
FLOATOBJ y;
142142
} POINTEF, *PPOINTEF;
143143

144-
typedef struct
144+
typedef struct _FTFD_FONT
145145
{
146146
FONTOBJ *pfo;
147147
PFTFD_FILE pfile;

win32ss/drivers/font/ftfd/glyph.c

Lines changed: 49 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,34 @@ FtfdGetFontInstance(
305305
return pfont;
306306
}
307307

308+
static
309+
BOOL
310+
FtfdLoadGlyph(
311+
PFTFD_FONT pfont,
312+
HGLYPH hg,
313+
ULONG iFormat) // 0 = bitmap, 1 = outline
314+
{
315+
FT_Error fterror;
316+
317+
/* Check if the glyph needs to be updated */
318+
if (pfont->hgSelected != hg)
319+
{
320+
/* Load the glyph into the freetype face slot */
321+
fterror = FT_Load_Glyph(pfont->ftface, hg, 0);
322+
if (fterror)
323+
{
324+
WARN("Couldn't load glyph 0x%lx\n", hg);
325+
pfont->hgSelected = -1;
326+
return FALSE;
327+
}
328+
329+
/* Update the selected glyph */
330+
pfont->hgSelected = hg;
331+
}
332+
333+
return TRUE;
334+
}
335+
308336
ULONG
309337
NTAPI
310338
FtfdQueryMaxExtents(
@@ -331,11 +359,28 @@ FtfdQueryMaxExtents(
331359
/* Accelerator flags (ignored atm) */
332360
pfddm->flRealizedType = 0;
333361

334-
/* Set fixed width advance */
362+
/* Check for fixed width font */
335363
if (FT_IS_FIXED_WIDTH(ftface))
336-
pfddm->lD = ftface->max_advance_width;
364+
{
365+
/* Make sure a glyph is loaded */
366+
if ((pfont->hgSelected != -1) ||
367+
FtfdLoadGlyph(pfont, 0, 0))
368+
{
369+
/* Convert advance from 26.6 fixpoint to pixel format */
370+
pfddm->lD = pface->ftface->glyph->advance.x >> 6;
371+
}
372+
else
373+
{
374+
/* Fall back to dynamic pitch */
375+
WARN("Couldn't load a glyph\n");
376+
pfddm->lD = 0;
377+
}
378+
}
337379
else
380+
{
381+
/* Variable pitch */
338382
pfddm->lD = 0;
383+
}
339384

340385
/* Copy some values from the font structure */
341386
pfddm->fxMaxAscender = pfont->metrics.fxMaxAscender;
@@ -380,33 +425,6 @@ FtfdQueryMaxExtents(
380425
return sizeof(FD_DEVICEMETRICS);
381426
}
382427

383-
static
384-
BOOL
385-
FtfdLoadGlyph(
386-
PFTFD_FONT pfont,
387-
HGLYPH hg,
388-
ULONG iFormat) // 0 = bitmap, 1 = outline
389-
{
390-
FT_Error fterror;
391-
392-
/* Check if the glyph needs to be updated */
393-
if (pfont->hgSelected != hg)
394-
{
395-
/* Load the glyph into the freetype face slot */
396-
fterror = FT_Load_Glyph(pfont->ftface, hg, 0);
397-
if (fterror)
398-
{
399-
WARN("Couldn't load glyph 0x%lx\n", hg);
400-
pfont->hgSelected = -1;
401-
return FALSE;
402-
}
403-
404-
/* Update the selected glyph */
405-
pfont->hgSelected = hg;
406-
}
407-
408-
return TRUE;
409-
}
410428

411429
static
412430
VOID
@@ -436,8 +454,8 @@ FtfdQueryGlyphData(
436454
pgd->fxAB = pgd->fxA + ftglyph->metrics.height;
437455
}
438456

439-
/* D is the glyph advance width */
440-
pgd->fxD = ftglyph->advance.x / 4; // FIXME: should be projected on the x-axis
457+
/* D is the glyph advance width. Convert it from 26.6 to 28.4 fixpoint format */
458+
pgd->fxD = ftglyph->advance.x >> 2; // FIXME: should be projected on the x-axis
441459

442460
/* Get the bitnmap size */
443461
sizlBitmap.cx = ftglyph->bitmap.width;

0 commit comments

Comments
 (0)