[cairo-commit] 2 commits - src/cairo-ft-font.c
src/cairo-scaled-font.c src/cairo-xlib-surface.c
Vladimir Vukicevic
vladimir at kemper.freedesktop.org
Wed Mar 1 11:27:02 PST 2006
src/cairo-ft-font.c | 22 +++++++++++++++++++++-
src/cairo-scaled-font.c | 6 +++---
src/cairo-xlib-surface.c | 4 ++--
3 files changed, 26 insertions(+), 6 deletions(-)
New commits:
diff-tree 2fb016c75b950b3b1fe077dc349713f61118fd7c (from parents)
Merge: 8176c93bc481414c1584bf4721ac1680ed827d97 3490ed989672eaf2c08468ba81e3376fa362e41f
Author: Vladimir Vukicevic <vladimir at pobox.com>
Date: Wed Mar 1 11:26:48 2006 +0100
Merge branch 'master' of git+ssh://git.cairographics.org/git/cairo
diff-tree 8176c93bc481414c1584bf4721ac1680ed827d97 (from f5566c9b20edf04b44f60bba164c226f2718a935)
Author: Vladimir Vukicevic <vladimir at pobox.com>
Date: Wed Mar 1 11:26:30 2006 +0100
Revert "Remove ft-font's usage of device offset surface fields for storing bearings"
Bogus fix; misunderstood the relationship between the font bearings
and the computed device offsets. Real fix on my device offsets branch.
This reverts 49b4fe10d0acdf6b9776d2908e98f2f0c596fbe5 commit.
diff --git a/src/cairo-ft-font.c b/src/cairo-ft-font.c
index 92b60c7..092838a 100644
--- a/src/cairo-ft-font.c
+++ b/src/cairo-ft-font.c
@@ -1021,6 +1021,14 @@ _render_glyph_outline (FT_Face
return status;
}
+ /*
+ * Note: the font's coordinate system is upside down from ours, so the
+ * Y coordinate of the control box needs to be negated.
+ */
+
+ (*surface)->base.device_x_offset = floor ((double) cbox.xMin / 64.0);
+ (*surface)->base.device_y_offset = floor (-(double) cbox.yMax / 64.0);
+
return CAIRO_STATUS_SUCCESS;
}
@@ -1059,7 +1067,19 @@ _render_glyph_bitmap (FT_Face fac
if (error)
return CAIRO_STATUS_NO_MEMORY;
- return _get_bitmap_surface (&glyphslot->bitmap, FALSE, font_options, surface);
+ status = _get_bitmap_surface (&glyphslot->bitmap, FALSE, font_options, surface);
+ if (status)
+ return status;
+
+ /*
+ * Note: the font's coordinate system is upside down from ours, so the
+ * Y coordinate of the control box needs to be negated.
+ */
+
+ (*surface)->base.device_x_offset = glyphslot->bitmap_left;
+ (*surface)->base.device_y_offset = -glyphslot->bitmap_top;
+
+ return status;
}
#if 0
diff --git a/src/cairo-scaled-font.c b/src/cairo-scaled-font.c
index cb0171b..a046904 100644
--- a/src/cairo-scaled-font.c
+++ b/src/cairo-scaled-font.c
@@ -858,7 +858,7 @@ _cairo_scaled_font_show_glyphs (cairo_sc
* they are implemented in terms of other operators in cairo-gstate.c
*/
assert (op != CAIRO_OPERATOR_SOURCE && op != CAIRO_OPERATOR_CLEAR);
-
+
if (scaled_font->status)
return scaled_font->status;
@@ -920,10 +920,10 @@ _cairo_scaled_font_show_glyphs (cairo_sc
/* round glyph locations to the nearest pixel */
x = (int) floor (glyphs[i].x +
- scaled_glyph->metrics.x_bearing +
+ glyph_surface->base.device_x_offset +
0.5);
y = (int) floor (glyphs[i].y +
- scaled_glyph->metrics.y_bearing +
+ glyph_surface->base.device_y_offset +
0.5);
_cairo_pattern_init_for_surface (&glyph_pattern, &glyph_surface->base);
diff --git a/src/cairo-xlib-surface.c b/src/cairo-xlib-surface.c
index a62afed..dc7d394 100644
--- a/src/cairo-xlib-surface.c
+++ b/src/cairo-xlib-surface.c
@@ -2119,8 +2119,8 @@ _cairo_xlib_surface_add_glyph (Display *
* sitting around for x and y.
*/
- glyph_info.x = -(int) floor(scaled_glyph->metrics.x_bearing + 0.5);
- glyph_info.y = -(int) floor(scaled_glyph->metrics.y_bearing + 0.5);
+ glyph_info.x = -(int) glyph_surface->base.device_x_offset;
+ glyph_info.y = -(int) glyph_surface->base.device_y_offset;
glyph_info.width = glyph_surface->width;
glyph_info.height = glyph_surface->height;
glyph_info.xOff = 0;
More information about the cairo-commit
mailing list