[OS/2] Bug 404196: fix calculation of space width in GetMetrics, so that monospaced text always lines up nicely

git-svn-id: svn://10.0.0.236/trunk@240359 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
mozilla%weilbacher.org
2007-12-03 22:22:36 +00:00
parent cfba782e06
commit b5cd53438b

View File

@@ -112,16 +112,19 @@ const gfxFont::Metrics& gfxOS2Font::GetMetrics()
// properties of space
gid = FT_Get_Char_Index(face, ' ');
// load glyph into glyph slot, use no_scale to get font units
FT_Load_Glyph(face, gid, FT_LOAD_NO_SCALE);
// Load glyph into glyph slot. Use load_default here to get results in
// 26.6 fractional pixel format which is what is used for all other
// characters in gfxOS2FontGroup::CreateGlyphRunsFT.
FT_Load_Glyph(face, gid, FT_LOAD_DEFAULT);
// face->glyph->metrics.width doesn't work for spaces, use advance.x instead
mMetrics->spaceWidth = face->glyph->advance.x * xScale;
mMetrics->spaceWidth = face->glyph->advance.x >> 6;
// save the space glyph
mSpaceGlyph = gid;
// properties of 'x', also use its width as average width
gid = FT_Get_Char_Index(face, 'x'); // select the glyph
if (gid) {
// Load glyph into glyph slot. Here, use no_scale to get font units.
FT_Load_Glyph(face, gid, FT_LOAD_NO_SCALE);
mMetrics->xHeight = face->glyph->metrics.height * yScale;
mMetrics->aveCharWidth = face->glyph->metrics.width * xScale;