Skip to content

Commit

Permalink
Fix bitmap-font XFAIL
Browse files Browse the repository at this point in the history
Images in PDF are scaled to a unit square. In PS we set the
ImageMatrix to do the same. When the image is painted we scale the
graphics state to paint the image at the right size. In the case of
Type 3 fonts consisting of bitmap images we want to paint the images
at their original size so we scale the graphics state by the image
width and height.

The bug was that we were scaling by the width/height in the glyph
metrics. For non rotated fonts this worked. However for rotated fonts
the width/height of the glyph images may be larger than the
width/height in the glyph metrics. This resulted in a Type 3 font
where the glyph images were scaled slightly smaller than they should
have been.
  • Loading branch information
Adrian Johnson committed Sep 26, 2008
1 parent f8542dc commit 907f550
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 8 deletions.
10 changes: 3 additions & 7 deletions src/cairo-type3-glyph-surface.c
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ _cairo_type3_glyph_surface_emit_fallback_image (cairo_type3_glyph_surface_t *sur
cairo_status_t status;
cairo_image_surface_t *image;
cairo_matrix_t mat;
double width, height, x, y;
double x, y;

status = _cairo_scaled_glyph_lookup (surface->scaled_font,
glyph_index,
Expand All @@ -361,14 +361,10 @@ _cairo_type3_glyph_surface_emit_fallback_image (cairo_type3_glyph_surface_t *sur

x = _cairo_fixed_to_double (scaled_glyph->bbox.p1.x);
y = _cairo_fixed_to_double (scaled_glyph->bbox.p2.y);
width = _cairo_fixed_to_double (scaled_glyph->bbox.p2.x) -
_cairo_fixed_to_double (scaled_glyph->bbox.p1.x);
height = _cairo_fixed_to_double (scaled_glyph->bbox.p2.y) -
_cairo_fixed_to_double (scaled_glyph->bbox.p1.y);
mat.xx = width;
mat.xx = image->width;
mat.xy = 0;
mat.yx = 0;
mat.yy = height;
mat.yy = image->height;
mat.x0 = x;
mat.y0 = y;
cairo_matrix_multiply (&mat, &mat, &surface->scaled_font->scale_inverse);
Expand Down
1 change: 0 additions & 1 deletion test/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -789,7 +789,6 @@ XFAIL_TESTS = \
alpha-similar$(EXEEXT) \
big-line$(EXEEXT) \
big-trap$(EXEEXT) \
bitmap-font$(EXEEXT) \
degenerate-path$(EXEEXT) \
device-offset-scale$(EXEEXT) \
extend-pad$(EXEEXT) \
Expand Down
Binary file removed test/bitmap-font-pdf-argb32-ref.png
Binary file not shown.

0 comments on commit 907f550

Please sign in to comment.