Changeset 28867 for trunk/WebCore/platform/graphics/win/FontDataWin.cpp
- Timestamp:
- 12/19/07 11:24:10 (12 months ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/platform/graphics/win/FontDataWin.cpp
r28641 r28867 60 60 { 61 61 m_syntheticBoldOffset = m_font.syntheticBold() ? 1.0f : 0.f; 62 m_scriptCache = 0; 63 m_scriptFontProperties = 0; 64 m_isSystemFont = false; 65 66 if (m_font.useGDI()) { 67 HDC hdc = GetDC(0); 68 HGDIOBJ oldFont = SelectObject(hdc, m_font.hfont()); 69 OUTLINETEXTMETRIC metrics; 70 GetOutlineTextMetrics(hdc, sizeof(metrics), &metrics); 71 TEXTMETRIC& textMetrics = metrics.otmTextMetrics; 72 m_ascent = textMetrics.tmAscent; 73 m_descent = textMetrics.tmDescent; 74 m_lineGap = textMetrics.tmExternalLeading; 75 m_lineSpacing = m_ascent + m_descent + m_lineGap; 76 m_xHeight = m_ascent * 0.56f; // Best guess for xHeight if no x glyph is present. 77 78 GLYPHMETRICS gm; 79 MAT2 mat = { 1, 0, 0, 1 }; 80 DWORD len = GetGlyphOutline(hdc, 'x', GGO_METRICS, &gm, 0, 0, &mat); 81 if (len != GDI_ERROR && gm.gmptGlyphOrigin.y > 0) 82 m_xHeight = gm.gmptGlyphOrigin.y; 83 84 m_unitsPerEm = metrics.otmEMSquare; 85 86 SelectObject(hdc, oldFont); 87 ReleaseDC(0, hdc); 88 89 return; 90 } 62 91 63 92 CGFontRef font = m_font.cgFont(); … … 71 100 float fLineGap = scaleEmToUnits(iLineGap, m_unitsPerEm) * pointSize; 72 101 73 m_isSystemFont = false;74 102 if (!isCustomFont()) { 75 103 HDC dc = GetDC(0); … … 116 144 m_xHeight = scaleEmToUnits(iXHeight, m_unitsPerEm) * pointSize; 117 145 } 118 119 m_scriptCache = 0;120 m_scriptFontProperties = 0;121 146 } 122 147 … … 146 171 LOGFONT winfont; 147 172 GetObject(m_font.hfont(), sizeof(LOGFONT), &winfont); 148 winfont.lfHeight = -lroundf(smallCapsHeight * 32);173 winfont.lfHeight = -lroundf(smallCapsHeight * m_font.useGDI() ? 1 : 32); 149 174 HFONT hfont = CreateFontIndirect(&winfont); 150 m_smallCapsFontData = new FontData(FontPlatformData(hfont, smallCapsHeight, fontDescription.bold(), fontDescription.italic() ));175 m_smallCapsFontData = new FontData(FontPlatformData(hfont, smallCapsHeight, fontDescription.bold(), fontDescription.italic(), m_font.useGDI())); 151 176 } 152 177 } … … 167 192 return false; 168 193 169 HDC dc = GetDC( (HWND)0);194 HDC dc = GetDC(0); 170 195 171 196 DWORD acpCodePages; … … 198 223 199 224 // TEXTMETRICS have this. Set m_treatAsFixedPitch based off that. 200 HDC dc = GetDC( (HWND)0);225 HDC dc = GetDC(0); 201 226 SaveDC(dc); 202 227 SelectObject(dc, m_font.hfont()); … … 214 239 float FontData::platformWidthForGlyph(Glyph glyph) const 215 240 { 241 if (m_font.useGDI()) { 242 HDC hdc = GetDC(0); 243 HGDIOBJ oldFont = SelectObject(hdc, m_font.hfont()); 244 int width; 245 GetCharWidthI(hdc, glyph, 1, 0, &width); 246 SelectObject(hdc, oldFont); 247 ReleaseDC(0, hdc); 248 return width; 249 } 250 216 251 CGFontRef font = m_font.cgFont(); 217 252 float pointSize = m_font.size();