summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTor Andersson <tor.andersson@artifex.com>2017-05-25 12:10:47 +0200
committerTor Andersson <tor.andersson@artifex.com>2017-05-25 13:53:39 +0200
commit0287ff8ba2779274914f0509c9325f881c6634f2 (patch)
tree7513d9a174002387a0a2a5395c7428a92f64a159
parent32599868df1b3ecd553a0c1bc3e2521dd11b288a (diff)
downloadmupdf-0287ff8ba2779274914f0509c9325f881c6634f2.tar.xz
Update Type 3 font bbox with glyph bboxes if the former is invalid.
Fix for bug 697943. Set the initial replacement font bbox to the empty rectangle for type3 fonts, and let the type3 glyph loading initialize by taking the union of all glyph bboxes. Set the replacement font bbox for non-Type3 fonts to the unit rectangle. Also remove unused flag from fz_font struct.
-rw-r--r--include/mupdf/fitz/font.h1
-rw-r--r--source/fitz/font.c27
2 files changed, 20 insertions, 8 deletions
diff --git a/include/mupdf/fitz/font.h b/include/mupdf/fitz/font.h
index 7d655222..7c71ca05 100644
--- a/include/mupdf/fitz/font.h
+++ b/include/mupdf/fitz/font.h
@@ -75,7 +75,6 @@ typedef struct
unsigned int force_hinting : 1; /* force hinting for DynaLab fonts */
unsigned int has_opentype : 1; /* has opentype shaping tables */
unsigned int invalid_bbox : 1;
- unsigned int use_glyph_bbox : 1;
} fz_font_flags_t;
/*
diff --git a/source/fitz/font.c b/source/fitz/font.c
index ebf66f45..65e06f43 100644
--- a/source/fitz/font.c
+++ b/source/fitz/font.c
@@ -64,7 +64,6 @@ fz_new_font(fz_context *ctx, const char *name, int use_glyph_bbox, int glyph_cou
font->glyph_count = glyph_count;
- font->flags.use_glyph_bbox = !!use_glyph_bbox;
if (use_glyph_bbox && glyph_count <= MAX_BBOX_TABLE_SIZE)
{
font->bbox_table = fz_malloc_array(ctx, glyph_count, sizeof(fz_rect));
@@ -171,12 +170,17 @@ fz_set_font_bbox(fz_context *ctx, fz_font *font, float xmin, float ymin, float x
{
if (xmin >= xmax || ymin >= ymax)
{
- /* Invalid bbox supplied. It would be prohibitively slow to
- * measure the true one, so make one up. */
- font->bbox.x0 = -1;
- font->bbox.y0 = -1;
- font->bbox.x1 = 2;
- font->bbox.y1 = 2;
+ /* Invalid bbox supplied. */
+ if (font->t3procs)
+ {
+ /* For type3 fonts we use the union of all the glyphs' bboxes. */
+ font->bbox = fz_empty_rect;
+ }
+ else
+ {
+ /* For other fonts it would be prohibitively slow to measure the true one, so make one up. */
+ font->bbox = fz_unit_rect;
+ }
font->flags.invalid_bbox = 1;
}
else
@@ -1168,6 +1172,10 @@ fz_bound_t3_glyph(fz_context *ctx, fz_font *font, int gid)
{
fz_rethrow(ctx);
}
+
+ /* Update font bbox with glyph's computed bbox if the font bbox is invalid */
+ if (font->flags.invalid_bbox)
+ fz_union_rect(&font->bbox, &font->bbox_table[gid]);
}
void
@@ -1225,6 +1233,11 @@ fz_prepare_t3_glyph(fz_context *ctx, fz_font *font, int gid, int nested_depth)
fz_bound_t3_glyph(ctx, font, gid);
}
}
+ else
+ {
+ /* No bbox has been defined for this glyph, so compute it. */
+ fz_bound_t3_glyph(ctx, font, gid);
+ }
}
void