diff --git a/src/hb-ot-glyf-table.hh b/src/hb-ot-glyf-table.hh index ce7ffa9d1..dc15ff1d6 100644 --- a/src/hb-ot-glyf-table.hh +++ b/src/hb-ot-glyf-table.hh @@ -716,7 +716,6 @@ struct glyf if (unlikely (!SimpleGlyph (*header, bytes).get_contour_points (points, phantom_only))) return false; break; - default: return false; /* empty glyph */ } hb_face_t *face = font->face; @@ -787,7 +786,8 @@ struct glyf all_points.extend (phantoms); } break; - default: return false; + default: + all_points.extend (phantoms); } if (depth == 0) /* Apply at top level */ @@ -860,6 +860,8 @@ struct glyf template bool get_points (hb_font_t *font, hb_codepoint_t gid, T consumer) const { + if (gid >= num_glyphs) return false; + /* Making this alloc free is not that easy https://github.com/harfbuzz/harfbuzz/issues/2095 mostly because of gvar handling in VF fonts, diff --git a/src/hb-ot-var-gvar-table.hh b/src/hb-ot-var-gvar-table.hh index 97bad818c..92cb3adc3 100644 --- a/src/hb-ot-var-gvar-table.hh +++ b/src/hb-ot-var-gvar-table.hh @@ -540,6 +540,8 @@ struct gvar /* num_coords should exactly match gvar's axisCount due to how GlyphVariationData tuples are aligned */ if (!font->num_coords || font->num_coords != table->axisCount) return true; + if (unlikely (glyph >= table->glyphCount)) return false; + hb_bytes_t var_data_bytes = table->get_glyph_var_data_bytes (table.get_blob (), glyph); if (!var_data_bytes.as ()->has_data ()) return true; hb_vector_t shared_indices; diff --git a/test/shaping/data/in-house/Makefile.sources b/test/shaping/data/in-house/Makefile.sources index 6ed565756..93b212d10 100644 --- a/test/shaping/data/in-house/Makefile.sources +++ b/test/shaping/data/in-house/Makefile.sources @@ -57,6 +57,7 @@ TESTS = \ tests/use.tests \ tests/variations-rounding.tests \ tests/variations-rvrn.tests \ + tests/variations-space.tests \ tests/vertical.tests \ tests/zero-width-marks.tests \ $(NULL) diff --git a/test/shaping/data/in-house/fonts/ab40c89624a6104e5d0a2308e448a989302f515b.ttf b/test/shaping/data/in-house/fonts/ab40c89624a6104e5d0a2308e448a989302f515b.ttf new file mode 100644 index 000000000..a82aa2165 Binary files /dev/null and b/test/shaping/data/in-house/fonts/ab40c89624a6104e5d0a2308e448a989302f515b.ttf differ diff --git a/test/shaping/data/in-house/meson.build b/test/shaping/data/in-house/meson.build index ccbdec115..20b5773e8 100644 --- a/test/shaping/data/in-house/meson.build +++ b/test/shaping/data/in-house/meson.build @@ -57,6 +57,7 @@ in_house_tests = [ 'use.tests', 'variations-rounding.tests', 'variations-rvrn.tests', + 'variations-space.tests', 'vertical.tests', 'zero-width-marks.tests', ] diff --git a/test/shaping/data/in-house/tests/variations-space.tests b/test/shaping/data/in-house/tests/variations-space.tests new file mode 100644 index 000000000..b5b5deb28 --- /dev/null +++ b/test/shaping/data/in-house/tests/variations-space.tests @@ -0,0 +1,2 @@ +../fonts/ab40c89624a6104e5d0a2308e448a989302f515b.ttf:--variations=wdth=60:U+0020:[space=0+266] +../fonts/ab40c89624a6104e5d0a2308e448a989302f515b.ttf:--variations=wdth=402:U+0020:[space=0+639]