summaryrefslogtreecommitdiffstats
path: root/WebCore/platform/graphics/cairo/FontCairo.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'WebCore/platform/graphics/cairo/FontCairo.cpp')
-rw-r--r--WebCore/platform/graphics/cairo/FontCairo.cpp26
1 files changed, 24 insertions, 2 deletions
diff --git a/WebCore/platform/graphics/cairo/FontCairo.cpp b/WebCore/platform/graphics/cairo/FontCairo.cpp
index b23182d..0f7ae79 100644
--- a/WebCore/platform/graphics/cairo/FontCairo.cpp
+++ b/WebCore/platform/graphics/cairo/FontCairo.cpp
@@ -36,6 +36,8 @@
#include "SimpleFontData.h"
#include "TransformationMatrix.h"
+#define SYNTHETIC_OBLIQUE_ANGLE 14
+
namespace WebCore {
void Font::drawGlyphs(GraphicsContext* context, const SimpleFontData* font, const GlyphBuffer& glyphBuffer,
@@ -48,15 +50,23 @@ void Font::drawGlyphs(GraphicsContext* context, const SimpleFontData* font, cons
GlyphBufferGlyph* glyphs = (GlyphBufferGlyph*)glyphBuffer.glyphs(from);
- float offset = point.x();
+ float offset = 0.0f;
for (int i = 0; i < numGlyphs; i++) {
glyphs[i].x = offset;
- glyphs[i].y = point.y();
+ glyphs[i].y = 0.0f;
offset += glyphBuffer.advanceAt(from + i);
}
Color fillColor = context->fillColor();
+ // Synthetic Oblique
+ if(font->platformData().syntheticOblique()) {
+ cairo_matrix_t mat = {1, 0, -tanf(SYNTHETIC_OBLIQUE_ANGLE * acosf(0) / 90), 1, point.x(), point.y()};
+ cairo_transform(cr, &mat);
+ } else {
+ cairo_translate(cr, point.x(), point.y());
+ }
+
// Text shadow, inspired by FontMac
IntSize shadowSize;
int shadowBlur = 0;
@@ -77,6 +87,12 @@ void Font::drawGlyphs(GraphicsContext* context, const SimpleFontData* font, cons
cairo_translate(cr, shadowSize.width(), shadowSize.height());
cairo_show_glyphs(cr, glyphs, numGlyphs);
+ if (font->syntheticBoldOffset()) {
+ cairo_save(cr);
+ cairo_translate(cr, font->syntheticBoldOffset(), 0);
+ cairo_show_glyphs(cr, glyphs, numGlyphs);
+ cairo_restore(cr);
+ }
cairo_restore(cr);
}
@@ -103,6 +119,12 @@ void Font::drawGlyphs(GraphicsContext* context, const SimpleFontData* font, cons
cairo_set_source_rgba(cr, red, green, blue, alpha * context->getAlpha());
}
cairo_show_glyphs(cr, glyphs, numGlyphs);
+ if (font->syntheticBoldOffset()) {
+ cairo_save(cr);
+ cairo_translate(cr, font->syntheticBoldOffset(), 0);
+ cairo_show_glyphs(cr, glyphs, numGlyphs);
+ cairo_restore(cr);
+ }
}
if (context->textDrawingMode() & cTextStroke) {