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

Brian Ewins brianewins at kemper.freedesktop.org
Sun Jan 21 17:14:52 PST 2007


 src/cairo-atsui-font.c |   57 +++++++++++++++++++++++++++++++++++++------------
 1 files changed, 44 insertions(+), 13 deletions(-)

New commits:
diff-tree c316b7220dcd59653533a487d81c5e3d71729218 (from 49b9f0c082944029af8dab84da87f7746c5f72b9)
Author: Brian Ewins <Brian.Ewins at gmail.com>
Date:   Mon Jan 22 01:13:50 2007 +0000

    [ATSUI] Some glyph operations cannot be 'unsupported'. (#9530)
    
    The atsui font backend returned the internal 'unsupported' error 
    code for errors in operations that do not have fallbacks. Now that 
    the underlying cause, deleted glyphs, has been fixed, I'm changing 
    the status code returned to the public 'no memory' one; it should 
    be the only condition triggering the failure now.

diff --git a/src/cairo-atsui-font.c b/src/cairo-atsui-font.c
index 43cdff6..8d95b8e 100644
--- a/src/cairo-atsui-font.c
+++ b/src/cairo-atsui-font.c
@@ -515,7 +515,7 @@ _cairo_atsui_font_init_glyph_metrics (ca
 				     1, &theGlyph, 0, false,
 				     false, &metricsH);
     if (err != noErr)
-	return CAIRO_INT_STATUS_UNSUPPORTED;
+	return CAIRO_STATUS_NO_MEMORY;
 
     /* Scale down to font units.*/
     _cairo_matrix_compute_scale_factors (&scaled_font->base.scale,
@@ -544,11 +544,8 @@ _cairo_atsui_font_init_glyph_metrics (ca
 				  (void *)path, &callback_err);
 
     if (err != noErr) {
-	/* This could potentially happen for bitmap fonts, where
-	 * no paths are available.
-	 */
 	CGPathRelease (path);
-	return CAIRO_INT_STATUS_UNSUPPORTED;
+	return CAIRO_STATUS_NO_MEMORY;
     }
 
     rect = CGPathGetBoundingBox (path);
@@ -788,7 +785,7 @@ _cairo_atsui_scaled_font_init_glyph_surf
     drawingContext = CGBitmapContextCreateWithCairoImageSurface (surface);
     if (!drawingContext) {
 	cairo_surface_destroy ((cairo_surface_t *)surface);
-	return CAIRO_INT_STATUS_UNSUPPORTED;
+	return CAIRO_STATUS_NO_MEMORY;
     }
     
     atsFont = FMGetATSFontRefFromFont (scaled_font->fontID);
diff-tree 49b9f0c082944029af8dab84da87f7746c5f72b9 (from 4dfa5d33e451886b05cf767ae5a538e152ec534d)
Author: Brian Ewins <Brian.Ewins at gmail.com>
Date:   Mon Jan 22 01:10:52 2007 +0000

    [ATSUI] out-of-range glyphs should be treated as deleted. (#9530)
    
    Glyphs outside the range 0x0-0xffff are not valid in atsui, but
    scaled_glyph stores unsigned long. Ensure that invalid values do
    not cause errors.

diff --git a/src/cairo-atsui-font.c b/src/cairo-atsui-font.c
index 8a7c679..43cdff6 100644
--- a/src/cairo-atsui-font.c
+++ b/src/cairo-atsui-font.c
@@ -477,6 +477,14 @@ OSStatus _close_path_for_metrics(void *c
     return noErr;
 }
 
+static GlyphID 
+_cairo_atsui_scaled_glyph_index (cairo_scaled_glyph_t *scaled_glyph) {
+    unsigned long index = _cairo_scaled_glyph_index (scaled_glyph);
+    if (index > 0xffff) 
+	return kATSDeletedGlyphcode;
+    return index;
+}
+
 static cairo_status_t
 _cairo_atsui_font_init_glyph_metrics (cairo_atsui_font_t *scaled_font,
 				      cairo_scaled_glyph_t *scaled_glyph)
@@ -489,7 +497,7 @@ _cairo_atsui_font_init_glyph_metrics (ca
     static ATSCubicCurveToUPP curveProc = NULL;
     static ATSCubicClosePathUPP closePathProc = NULL;
     CGMutablePathRef path;
-    GlyphID theGlyph = _cairo_scaled_glyph_index (scaled_glyph);
+    GlyphID theGlyph = _cairo_atsui_scaled_glyph_index (scaled_glyph);
     double xscale, yscale;
     CGRect rect;
 
@@ -640,7 +648,7 @@ _cairo_atsui_scaled_font_init_glyph_path
     static ATSCubicLineToUPP lineProc = NULL;
     static ATSCubicCurveToUPP curveProc = NULL;
     static ATSCubicClosePathUPP closePathProc = NULL;
-    GlyphID theGlyph = _cairo_scaled_glyph_index (scaled_glyph);
+    GlyphID theGlyph = _cairo_atsui_scaled_glyph_index (scaled_glyph);
     OSStatus err;
     cairo_atsui_scaled_path_t scaled_path;
     cairo_matrix_t *font_to_device = &scaled_font->base.scale;
@@ -704,7 +712,7 @@ _cairo_atsui_scaled_font_init_glyph_surf
     cairo_scaled_font_t base = scaled_font->base;
     cairo_font_extents_t extents = base.extents;
 
-    GlyphID theGlyph = _cairo_scaled_glyph_index (scaled_glyph);
+    GlyphID theGlyph = _cairo_atsui_scaled_glyph_index (scaled_glyph);
     ATSGlyphScreenMetrics metricsH;
     double left, bottom, width, height;
     double xscale, yscale;
diff-tree 4dfa5d33e451886b05cf767ae5a538e152ec534d (from 1a9d3b5185f454a63bc96c2e570c931c3ecabbb5)
Author: Brian Ewins <Brian.Ewins at gmail.com>
Date:   Mon Jan 22 01:09:49 2007 +0000

    [ATSUI] Handle deleted glyphs correctly. (#9530)
    
    This code ensures that deleted glyphs are not drawn.

diff --git a/src/cairo-atsui-font.c b/src/cairo-atsui-font.c
index b359b2e..8a7c679 100644
--- a/src/cairo-atsui-font.c
+++ b/src/cairo-atsui-font.c
@@ -481,7 +481,7 @@ static cairo_status_t
 _cairo_atsui_font_init_glyph_metrics (cairo_atsui_font_t *scaled_font,
 				      cairo_scaled_glyph_t *scaled_glyph)
 {
-    cairo_text_extents_t extents;
+    cairo_text_extents_t extents = {0, 0, 0, 0, 0, 0};
     OSStatus err, callback_err;
     ATSGlyphScreenMetrics metricsH;
     static ATSCubicMoveToUPP moveProc = NULL;
@@ -493,6 +493,13 @@ _cairo_atsui_font_init_glyph_metrics (ca
     double xscale, yscale;
     CGRect rect;
 
+    if (theGlyph == kATSDeletedGlyphcode) {
+	_cairo_scaled_glyph_set_metrics (scaled_glyph,
+					 &scaled_font->base,
+					 &extents);
+	return CAIRO_STATUS_SUCCESS;
+    }
+
     /* We calculate the advance from the screen metrics. We
      * could probably take this from the glyph path.
      */
@@ -633,6 +640,7 @@ _cairo_atsui_scaled_font_init_glyph_path
     static ATSCubicLineToUPP lineProc = NULL;
     static ATSCubicCurveToUPP curveProc = NULL;
     static ATSCubicClosePathUPP closePathProc = NULL;
+    GlyphID theGlyph = _cairo_scaled_glyph_index (scaled_glyph);
     OSStatus err;
     cairo_atsui_scaled_path_t scaled_path;
     cairo_matrix_t *font_to_device = &scaled_font->base.scale;
@@ -640,6 +648,17 @@ _cairo_atsui_scaled_font_init_glyph_path
     double xscale;
     double yscale;
     
+    scaled_path.path = _cairo_path_fixed_create ();
+    if (!scaled_path.path)
+	return CAIRO_STATUS_NO_MEMORY;
+
+    if (theGlyph == kATSDeletedGlyphcode) {
+	_cairo_scaled_glyph_set_path (scaled_glyph, &scaled_font->base, 
+				      scaled_path.path);
+
+	return CAIRO_STATUS_SUCCESS;
+    }
+
     /* extract the rotation/shear component of the scale matrix. */
     _cairo_matrix_compute_scale_factors (font_to_device, &xscale, &yscale, 1);
     cairo_matrix_init (&unscaled_font_to_device, 
@@ -650,9 +669,6 @@ _cairo_atsui_scaled_font_init_glyph_path
     cairo_matrix_scale (&unscaled_font_to_device, 1.0/xscale, 1.0/yscale);
 
     scaled_path.scale = &unscaled_font_to_device;
-    scaled_path.path = _cairo_path_fixed_create ();
-    if (!scaled_path.path)
-	return CAIRO_STATUS_NO_MEMORY;
 
     if (moveProc == NULL) {
         moveProc = NewATSCubicMoveToUPP(_move_to);
@@ -662,7 +678,7 @@ _cairo_atsui_scaled_font_init_glyph_path
     }
 
     err = ATSUGlyphGetCubicPaths(scaled_font->style,
-				 _cairo_scaled_glyph_index (scaled_glyph),
+				 theGlyph,
 				 moveProc,
 				 lineProc,
 				 curveProc,
@@ -696,6 +712,16 @@ _cairo_atsui_scaled_font_init_glyph_surf
     CGAffineTransform transform;
 
 
+    if (theGlyph == kATSDeletedGlyphcode) {
+	surface = (cairo_image_surface_t *)cairo_image_surface_create (CAIRO_FORMAT_A8, 2, 2);
+	if (!surface)
+	    return CAIRO_STATUS_NO_MEMORY;
+	_cairo_scaled_glyph_set_surface (scaled_glyph,
+					 &base,
+					 surface);
+	return CAIRO_STATUS_SUCCESS;
+    }
+
     /* Compute a box to contain the glyph mask. The vertical
      * sizes come from the font extents; extra pixels are 
      * added to account for fractional sizes.


More information about the cairo-commit mailing list