summaryrefslogtreecommitdiff
path: root/source/pdf/pdf-font.c
diff options
context:
space:
mode:
authorTor Andersson <tor.andersson@artifex.com>2015-09-29 12:05:09 +0200
committerRobin Watts <robin.watts@artifex.com>2015-10-02 16:36:34 +0100
commit903a9154f80ccf8d4badb7102d60a3c543896c5c (patch)
tree428d574a6f49c31de13678493f4180f32817db86 /source/pdf/pdf-font.c
parentf0f90683d3ae5d8655eb1e02c2412fd35bc96257 (diff)
downloadmupdf-903a9154f80ccf8d4badb7102d60a3c543896c5c.tar.xz
Fix 696148: Always create a glyph width table.
Respect default widths when creating the glyph width table.
Diffstat (limited to 'source/pdf/pdf-font.c')
-rw-r--r--source/pdf/pdf-font.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/source/pdf/pdf-font.c b/source/pdf/pdf-font.c
index 35e61f93..38dd2b58 100644
--- a/source/pdf/pdf-font.c
+++ b/source/pdf/pdf-font.c
@@ -1187,13 +1187,17 @@ pdf_make_width_table(fz_context *ctx, pdf_font_desc *fontdesc)
if (gid > n)
n = gid;
}
- };
+ }
font->width_count = n + 1;
font->width_table = fz_malloc_array(ctx, font->width_count, sizeof(int));
memset(font->width_table, 0, font->width_count * sizeof(int));
fontdesc->size += font->width_count * sizeof(int);
+ font->width_default = fontdesc->dhmtx.w;
+ for (i = 0; i < font->width_count; i++)
+ font->width_table[i] = -1;
+
for (i = 0; i < fontdesc->hmtx_len; i++)
{
for (k = fontdesc->hmtx[i].lo; k <= fontdesc->hmtx[i].hi; k++)
@@ -1204,6 +1208,10 @@ pdf_make_width_table(fz_context *ctx, pdf_font_desc *fontdesc)
font->width_table[gid] = fz_maxi(fontdesc->hmtx[i].w, font->width_table[gid]);
}
}
+
+ for (i = 0; i < font->width_count; i++)
+ if (font->width_table[i] == -1)
+ font->width_table[i] = font->width_default;
}
pdf_font_desc *
@@ -1254,9 +1262,8 @@ pdf_load_font(fz_context *ctx, pdf_document *doc, pdf_obj *rdb, pdf_obj *dict, i
fontdesc = pdf_load_simple_font(ctx, doc, dict);
}
- /* Save the widths to stretch non-CJK substitute fonts */
- if (fontdesc->font->ft_substitute && !fontdesc->to_ttf_cmap)
- pdf_make_width_table(ctx, fontdesc);
+ /* Create glyph width table for stretching substitute fonts and text extraction. */
+ pdf_make_width_table(ctx, fontdesc);
pdf_store_item(ctx, dict, fontdesc, fontdesc->size);