diff options
-rw-r--r-- | base/gstype42.c | 22 | ||||
-rw-r--r-- | psi/zfapi.c | 13 |
2 files changed, 13 insertions, 22 deletions
diff --git a/base/gstype42.c b/base/gstype42.c index 4a82606ed..7f21a8415 100644 --- a/base/gstype42.c +++ b/base/gstype42.c | |||
@@ -267,19 +267,6 @@ gs_type42_font_init(gs_font_type42 * pfont, int subfontID) | |||
267 | loca_size >>= pfont->data.indexToLocFormat + 1; | 267 | loca_size >>= pfont->data.indexToLocFormat + 1; |
268 | pfont->data.numGlyphs = (loca_size == 0 ? 0 : loca_size - 1); | 268 | pfont->data.numGlyphs = (loca_size == 0 ? 0 : loca_size - 1); |
269 | if (pfont->data.numGlyphs > pfont->data.trueNumGlyphs) { | 269 | if (pfont->data.numGlyphs > pfont->data.trueNumGlyphs) { |
270 | /* Some fonts have excessive data at end of 'loca' table - | ||
271 | see bug 688467. | ||
272 | We're not sure why old versions of Ghostscript maintain | ||
273 | two different fileds - numGlyphs and trueNumGlyphs. | ||
274 | (A related comment in gxfont42.h isn't explanatory about important cases.) | ||
275 | Our reading of TrueType specification and FreeType experience | ||
276 | is that only trueNumGlyphs should be used. | ||
277 | Maybe (I guess) sometimes somebody observed a font, | ||
278 | in which trueNumGlyphs counts real glyphs, | ||
279 | and numGlyphs counts all subglyphs ? | ||
280 | Continue using trueNumGlyphs since the document of | ||
281 | the bug 688467 fails otherwise. | ||
282 | */ | ||
283 | /* pfont->key_name.chars is ASCIIZ due to copy_font_name. */ | 270 | /* pfont->key_name.chars is ASCIIZ due to copy_font_name. */ |
284 | char buf[gs_font_name_max + 2]; | 271 | char buf[gs_font_name_max + 2]; |
285 | 272 | ||
@@ -307,13 +294,12 @@ gs_type42_font_init(gs_font_type42 * pfont, int subfontID) | |||
307 | if (glyph_offset < glyph_size) | 294 | if (glyph_offset < glyph_size) |
308 | break; | 295 | break; |
309 | } | 296 | } |
310 | if (i > pfont->data.trueNumGlyphs) { | 297 | if (i > pfont->data.numGlyphs) { |
311 | /* loca contains more good offsets, fix maxp.numGlyphs. | 298 | /* loca contains more good offsets . |
312 | Note a code below will fix bad offsets if any. */ | 299 | Note a code below will fix bad offsets if any. */ |
313 | pfont->data.numGlyphs = pfont->data.trueNumGlyphs = loca_size - 1; | 300 | pfont->data.numGlyphs = loca_size - 1; |
314 | } | 301 | } |
315 | } | 302 | } |
316 | pfont->data.numGlyphs = pfont->data.trueNumGlyphs; | ||
317 | loca_size = pfont->data.numGlyphs + 1; | 303 | loca_size = pfont->data.numGlyphs + 1; |
318 | } | 304 | } |
319 | 305 | ||
@@ -630,7 +616,7 @@ default_get_outline(gs_font_type42 * pfont, uint glyph_index, | |||
630 | uint glyph_length; | 616 | uint glyph_length; |
631 | int code; | 617 | int code; |
632 | 618 | ||
633 | if (glyph_index >= pfont->data.trueNumGlyphs) | 619 | if (glyph_index >= pfont->data.numGlyphs) |
634 | return_error(gs_error_invalidfont); | 620 | return_error(gs_error_invalidfont); |
635 | glyph_start = get_glyph_offset(pfont, glyph_index); | 621 | glyph_start = get_glyph_offset(pfont, glyph_index); |
636 | if (pfont->data.len_glyphs) | 622 | if (pfont->data.len_glyphs) |
diff --git a/psi/zfapi.c b/psi/zfapi.c index 3448423ef..8d8715332 100644 --- a/psi/zfapi.c +++ b/psi/zfapi.c | |||
@@ -1033,11 +1033,16 @@ sfnt_get_glyph_offset(ref *pdr, gs_font_type42 *pfont42, int index, | |||
1033 | sfnts_reader r; | 1033 | sfnts_reader r; |
1034 | int glyf_elem_size = (pfont42->data.indexToLocFormat) ? 4 : 2; | 1034 | int glyf_elem_size = (pfont42->data.indexToLocFormat) ? 4 : 2; |
1035 | 1035 | ||
1036 | sfnts_reader_init(&r, pdr); | 1036 | if (index < pfont42->data.trueNumGlyphs) { |
1037 | r.seek(&r, pfont42->data.loca + index * glyf_elem_size); | 1037 | sfnts_reader_init(&r, pdr); |
1038 | *offset0 = | 1038 | r.seek(&r, pfont42->data.loca + index * glyf_elem_size); |
1039 | pfont42->data.glyf + (glyf_elem_size == | 1039 | *offset0 = |
1040 | pfont42->data.glyf + (glyf_elem_size == | ||
1040 | 2 ? r.rword(&r) * 2 : r.rlong(&r)); | 1041 | 2 ? r.rword(&r) * 2 : r.rlong(&r)); |
1042 | } | ||
1043 | else { | ||
1044 | r.error = true; | ||
1045 | } | ||
1041 | return (r.error); | 1046 | return (r.error); |
1042 | } | 1047 | } |
1043 | 1048 | ||