Show
Ignore:
Timestamp:
12/19/07 11:24:10 (12 months ago)
Author:
hyatt@apple.com
Message:

Add support for GDI text on Windows.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/platform/graphics/win/FontDataWin.cpp

    r28641 r28867  
    6060{     
    6161    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    } 
    6291 
    6392    CGFontRef font = m_font.cgFont(); 
     
    71100    float fLineGap = scaleEmToUnits(iLineGap, m_unitsPerEm) * pointSize; 
    72101 
    73     m_isSystemFont = false; 
    74102    if (!isCustomFont()) { 
    75103        HDC dc = GetDC(0); 
     
    116144        m_xHeight = scaleEmToUnits(iXHeight, m_unitsPerEm) * pointSize; 
    117145    } 
    118  
    119     m_scriptCache = 0; 
    120     m_scriptFontProperties = 0; 
    121146} 
    122147 
     
    146171            LOGFONT winfont; 
    147172            GetObject(m_font.hfont(), sizeof(LOGFONT), &winfont); 
    148             winfont.lfHeight = -lroundf(smallCapsHeight * 32); 
     173            winfont.lfHeight = -lroundf(smallCapsHeight * m_font.useGDI() ? 1 : 32); 
    149174            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())); 
    151176        } 
    152177    } 
     
    167192        return false; 
    168193 
    169     HDC dc = GetDC((HWND)0); 
     194    HDC dc = GetDC(0); 
    170195     
    171196    DWORD acpCodePages; 
     
    198223 
    199224    // TEXTMETRICS have this.  Set m_treatAsFixedPitch based off that. 
    200     HDC dc = GetDC((HWND)0); 
     225    HDC dc = GetDC(0); 
    201226    SaveDC(dc); 
    202227    SelectObject(dc, m_font.hfont()); 
     
    214239float FontData::platformWidthForGlyph(Glyph glyph) const 
    215240{ 
     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 
    216251    CGFontRef font = m_font.cgFont(); 
    217252    float pointSize = m_font.size();