Changeset 44268 in webkit


Ignore:
Timestamp:
May 29, 2009 12:53:41 PM (15 years ago)
Author:
bfulgham@webkit.org
Message:

2009-05-29 Alexander Macdonald <alexmac@adobe.com>

Reviewed by Darin Adler.

Added support for synthetic bold/oblique font rendering
on platforms that use cairo.

  • platform/graphics/SimpleFontData.h:
  • platform/graphics/cairo/FontCairo.cpp: (WebCore::Font::drawGlyphs):
  • platform/graphics/gtk/SimpleFontDataGtk.cpp: (WebCore::SimpleFontData::platformInit):
  • platform/graphics/gtk/SimpleFontDataPango.cpp: (WebCore::SimpleFontData::platformInit):
  • platform/graphics/win/SimpleFontDataCairoWin.cpp: (WebCore::SimpleFontData::platformInit):
Location:
trunk/WebCore
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r44266 r44268  
     12009-05-29  Alexander Macdonald  <alexmac@adobe.com>
     2
     3        Reviewed by Darin Adler.
     4
     5        Added support for synthetic bold/oblique font rendering
     6        on platforms that use cairo.
     7
     8        * platform/graphics/SimpleFontData.h:
     9        * platform/graphics/cairo/FontCairo.cpp:
     10        (WebCore::Font::drawGlyphs):
     11        * platform/graphics/gtk/SimpleFontDataGtk.cpp:
     12        (WebCore::SimpleFontData::platformInit):
     13        * platform/graphics/gtk/SimpleFontDataPango.cpp:
     14        (WebCore::SimpleFontData::platformInit):
     15        * platform/graphics/win/SimpleFontDataCairoWin.cpp:
     16        (WebCore::SimpleFontData::platformInit):
     17
    1182009-05-29  Chris Fleizach  <cfleizach@apple.com>
    219
  • trunk/WebCore/platform/graphics/SimpleFontData.h

    r43007 r44268  
    184184    mutable SimpleFontData* m_smallCapsFontData;
    185185
    186 #if PLATFORM(CG) || PLATFORM(WIN)
     186#if PLATFORM(CG) || PLATFORM(CAIRO)
    187187    float m_syntheticBoldOffset;
    188188#endif
  • trunk/WebCore/platform/graphics/cairo/FontCairo.cpp

    r41279 r44268  
    3737#include "TransformationMatrix.h"
    3838
     39#define SYNTHETIC_OBLIQUE_ANGLE 14
     40
    3941namespace WebCore {
    4042
     
    4951    GlyphBufferGlyph* glyphs = (GlyphBufferGlyph*)glyphBuffer.glyphs(from);
    5052
    51     float offset = point.x();
     53    float offset = 0.0f;
    5254    for (int i = 0; i < numGlyphs; i++) {
    5355        glyphs[i].x = offset;
    54         glyphs[i].y = point.y();
     56        glyphs[i].y = 0.0f;
    5557        offset += glyphBuffer.advanceAt(from + i);
    5658    }
    5759
    5860    Color fillColor = context->fillColor();
     61
     62    // Synthetic Oblique
     63    if(font->platformData().syntheticOblique()) {
     64        cairo_matrix_t mat = {1, 0, -tanf(SYNTHETIC_OBLIQUE_ANGLE * acosf(0) / 90), 1, point.x(), point.y()};
     65        cairo_transform(cr, &mat);
     66    } else {
     67        cairo_translate(cr, point.x(), point.y());
     68    }
    5969
    6070    // Text shadow, inspired by FontMac
     
    7888        cairo_translate(cr, shadowSize.width(), shadowSize.height());
    7989        cairo_show_glyphs(cr, glyphs, numGlyphs);
     90        if (font->m_syntheticBoldOffset) {
     91            cairo_save(cr);
     92            cairo_translate(cr, font->m_syntheticBoldOffset, 0);
     93            cairo_show_glyphs(cr, glyphs, numGlyphs);
     94            cairo_restore(cr);
     95        }
    8096
    8197        cairo_restore(cr);
     
    104120        }
    105121        cairo_show_glyphs(cr, glyphs, numGlyphs);
     122        if (font->m_syntheticBoldOffset) {
     123            cairo_save(cr);
     124            cairo_translate(cr, font->m_syntheticBoldOffset, 0);
     125            cairo_show_glyphs(cr, glyphs, numGlyphs);
     126            cairo_restore(cr);
     127        }
    106128    }
    107129
  • trunk/WebCore/platform/graphics/gtk/SimpleFontDataGtk.cpp

    r43007 r44268  
    6666    m_spaceWidth =  static_cast<int>(text_extents.x_advance);
    6767    m_lineGap = m_lineSpacing - m_ascent - m_descent;
     68    m_syntheticBoldOffset = m_font.syntheticBold() ? 1.0f : 0.f;
    6869}
    6970
  • trunk/WebCore/platform/graphics/gtk/SimpleFontDataPango.cpp

    r43007 r44268  
    6565    m_spaceWidth =  static_cast<int>(text_extents.x_advance);
    6666    m_lineGap = m_lineSpacing - m_ascent - m_descent;
     67    m_syntheticBoldOffset = m_font.syntheticBold() ? 1.0f : 0.f;
    6768}
    6869
  • trunk/WebCore/platform/graphics/win/SimpleFontDataCairoWin.cpp

    r43007 r44268  
    4949    m_isSystemFont = false;
    5050    m_syntheticBoldOffset = 0;
     51
     52    m_syntheticBoldOffset = m_font.syntheticBold() ? 1.0f : 0.f;
    5153
    5254    if (m_font.useGDI())
Note: See TracChangeset for help on using the changeset viewer.