[cairo-commit] src/cairo-atsui-font.c

Behdad Esfahbod behdad at kemper.freedesktop.org
Sun Dec 17 19:26:06 PST 2006


 src/cairo-atsui-font.c |   30 ++++++++++++++++--------------
 1 files changed, 16 insertions(+), 14 deletions(-)

New commits:
diff-tree f3b9f486cd763c7805ec041319817cfb8c51128a (from c6ec6ed696f55f65abbcfccb1e9d2c5678cf491a)
Author: Brian Ewins <Brian.Ewins at gmail.com>
Date:   Sun Dec 17 22:26:02 2006 -0500

    [ATSUI] Use screen metrics instead of ideal metrics to compute glyph extents
    
    The glyph extent computation was totally busted.  It was using "logical"
    extents and it was not correctly handling rotations, etc.  It all looks a lot
    better now.

diff --git a/src/cairo-atsui-font.c b/src/cairo-atsui-font.c
index 6ba9c2e..eaca0a7 100644
--- a/src/cairo-atsui-font.c
+++ b/src/cairo-atsui-font.c
@@ -363,28 +363,30 @@ _cairo_atsui_font_init_glyph_metrics (ca
    cairo_text_extents_t extents;
    OSStatus err;
    GlyphID theGlyph = _cairo_scaled_glyph_index (scaled_glyph);
-   ATSGlyphIdealMetrics metricsH, metricsV;
-   ATSUStyle style;
+   ATSGlyphScreenMetrics metricsH, metricsV;
+   ATSUStyle style,style1;
    ATSUVerticalCharacterType verticalType = kATSUStronglyVertical;
    const ATSUAttributeTag theTag[] = { kATSUVerticalCharacterTag };
    const ByteCount theSizes[] = { sizeof(verticalType) };
    ATSUAttributeValuePtr theValues[] = { &verticalType };
+   double xscale;
+   double yscale;
 
-   ATSUCreateAndCopyStyle(font->unscaled_style, &style);
+   _cairo_matrix_compute_scale_factors(&font->base.scale, &xscale, &yscale, 1);
 
-   err = ATSUGlyphGetIdealMetrics(style,
-				  1, &theGlyph, 0, &metricsH);
+   ATSUCreateAndCopyStyle(font->style, &style);
+
+   err = ATSUGlyphGetScreenMetrics(style,
+				   1, &theGlyph, 0, false, false, &metricsH);
    err = ATSUSetAttributes(style, 1, theTag, theSizes, theValues);
-   err = ATSUGlyphGetIdealMetrics(style,
-				  1, &theGlyph, 0, &metricsV);
+   err = ATSUGlyphGetScreenMetrics(style,
+				   1, &theGlyph, 0, false, false, &metricsV);
 
-   extents.x_bearing = metricsH.sideBearing.x;
-   extents.y_bearing = metricsV.advance.y;
-   extents.width =
-      metricsH.advance.x - metricsH.sideBearing.x - metricsH.otherSideBearing.x;
-   extents.height =
-     -metricsV.advance.y - metricsV.sideBearing.y - metricsV.otherSideBearing.y;
-   extents.x_advance = metricsH.advance.x;
+   extents.width = metricsH.width/xscale;
+   extents.height = metricsH.height/yscale;
+   extents.x_bearing = metricsH.sideBearing.x/xscale;
+   extents.y_bearing = metricsV.sideBearing.y/yscale - extents.height;
+   extents.x_advance = metricsH.deviceAdvance.x/xscale;
    extents.y_advance = 0;
 
   _cairo_scaled_glyph_set_metrics (scaled_glyph,


More information about the cairo-commit mailing list