summaryrefslogtreecommitdiff
path: root/src/cairo-surface.c
diff options
context:
space:
mode:
authorBehdad Esfahbod <behdad@behdad.org>2006-07-14 21:42:41 -0400
committerBehdad Esfahbod <behdad@behdad.org>2006-07-14 21:42:41 -0400
commit84840e6bba6e72aa88fad7a0ee929e8955ba9051 (patch)
treee1775ec2ab0c1ebbfaa06ff86c12e15bb5bf01d7 /src/cairo-surface.c
parent47d3c5a2c63478288345235f26533f2d6059e815 (diff)
Use font matrix offset to reposition glyph origin instead of adjusting advance
As the font matrix includes translation, which is otherwise unused for glyph transformation, the interpretation of translation is fairly arbitrary. For 1.2.0, we choose to have this translation affect the glyph advance with the thought that it could be used to do letter spacing/kerning. That is fairly useless in practice, and a far more useful interpretation is to relocate the origin of each glyph. This patch uses the translation in the font matrix as an offset for the glyph origin in user space. It turns out glyph extents were already correctly shifted. The end result with this patch is to have cairo match the 1.0 behaviour for font matrix translations, but now we know why :-) Explanation above courtesy of Keith Packard.
Diffstat (limited to 'src/cairo-surface.c')
-rw-r--r--src/cairo-surface.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/cairo-surface.c b/src/cairo-surface.c
index e01c2c9e1..3ff1ae7c1 100644
--- a/src/cairo-surface.c
+++ b/src/cairo-surface.c
@@ -1705,6 +1705,7 @@ _cairo_surface_show_glyphs (cairo_surface_t *surface,
cairo_glyph_t *dev_glyphs = (cairo_glyph_t*) glyphs;
cairo_scaled_font_t *dev_scaled_font = scaled_font;
cairo_pattern_union_t dev_source;
+ cairo_matrix_t font_matrix;
assert (! surface->is_snapshot);
@@ -1718,7 +1719,9 @@ _cairo_surface_show_glyphs (cairo_surface_t *surface,
surface,
&dev_source.base);
- if (_cairo_surface_has_device_transform (surface))
+ cairo_scaled_font_get_font_matrix (scaled_font, &font_matrix);
+
+ if (_cairo_surface_has_device_transform (surface) || font_matrix.x0 != 0.0 || font_matrix.y0 != 0.0)
{
int i;
@@ -1728,8 +1731,8 @@ _cairo_surface_show_glyphs (cairo_surface_t *surface,
for (i = 0; i < num_glyphs; i++) {
dev_glyphs[i].index = glyphs[i].index;
- dev_glyphs[i].x = glyphs[i].x;
- dev_glyphs[i].y = glyphs[i].y;
+ dev_glyphs[i].x = glyphs[i].x + font_matrix.x0;
+ dev_glyphs[i].y = glyphs[i].y + font_matrix.y0;
cairo_matrix_transform_point (&surface->device_transform,
&dev_glyphs[i].x,
&dev_glyphs[i].y);
@@ -1737,11 +1740,10 @@ _cairo_surface_show_glyphs (cairo_surface_t *surface,
if (! _cairo_matrix_is_integer_translation (&surface->device_transform, NULL, NULL)) {
cairo_font_options_t *font_options;
- cairo_matrix_t font_matrix, dev_ctm;
+ cairo_matrix_t dev_ctm;
font_options = cairo_font_options_create ();
- cairo_scaled_font_get_font_matrix (scaled_font, &font_matrix);
cairo_scaled_font_get_ctm (scaled_font, &dev_ctm);
cairo_matrix_multiply (&dev_ctm, &dev_ctm, &surface->device_transform);
cairo_scaled_font_get_font_options (scaled_font, font_options);