[config] Add HB_NO_BORING_EXPANSION

This commit is contained in:
Behdad Esfahbod 2022-02-15 17:17:49 -06:00
parent 197ed8f592
commit 67eb9acf79
5 changed files with 13 additions and 1 deletions

View File

@ -85,6 +85,7 @@
#ifdef HB_MINI #ifdef HB_MINI
#define HB_NO_AAT #define HB_NO_AAT
#define HB_NO_LEGACY #define HB_NO_LEGACY
#define HB_NO_BORING_EXPANSION
#endif #endif
#if defined(HAVE_CONFIG_OVERRIDE_H) || defined(HB_CONFIG_OVERRIDE_H) #if defined(HAVE_CONFIG_OVERRIDE_H) || defined(HB_CONFIG_OVERRIDE_H)

View File

@ -261,6 +261,10 @@ struct hmtxvmtx
if (unlikely (!num_advances)) if (unlikely (!num_advances))
return default_advance; return default_advance;
#ifdef HB_NO_BORING_EXPANSION
return 0;
#endif
if (unlikely (glyph >= num_glyphs)) if (unlikely (glyph >= num_glyphs))
return 0; return 0;

View File

@ -102,7 +102,10 @@ hb_face_t::load_num_glyphs () const
{ {
unsigned ret = 0; unsigned ret = 0;
ret = load_num_glyphs_from_loca (this); #ifndef HB_NO_BORING_EXPANSION
if (!ret)
ret = load_num_glyphs_from_loca (this);
#endif
if (!ret) if (!ret)
ret = load_num_glyphs_from_maxp (this); ret = load_num_glyphs_from_maxp (this);

View File

@ -77,9 +77,11 @@ test_maxp_and_hmtx (void)
g_assert_cmpuint (hb_font_get_glyph_h_advance (font, 2), ==, 3); g_assert_cmpuint (hb_font_get_glyph_h_advance (font, 2), ==, 3);
g_assert_cmpuint (hb_font_get_glyph_h_advance (font, 3), ==, 3); g_assert_cmpuint (hb_font_get_glyph_h_advance (font, 3), ==, 3);
g_assert_cmpuint (hb_font_get_glyph_h_advance (font, 4), ==, 3); g_assert_cmpuint (hb_font_get_glyph_h_advance (font, 4), ==, 3);
#ifndef HB_NO_BORING_EXPANSION
g_assert_cmpuint (hb_font_get_glyph_h_advance (font, 5), ==, 8); g_assert_cmpuint (hb_font_get_glyph_h_advance (font, 5), ==, 8);
g_assert_cmpuint (hb_font_get_glyph_h_advance (font, 6), ==, 9); g_assert_cmpuint (hb_font_get_glyph_h_advance (font, 6), ==, 9);
g_assert_cmpuint (hb_font_get_glyph_h_advance (font, 7), ==, 9); g_assert_cmpuint (hb_font_get_glyph_h_advance (font, 7), ==, 9);
#endif
g_assert_cmpuint (hb_font_get_glyph_h_advance (font, 8), ==, 0); g_assert_cmpuint (hb_font_get_glyph_h_advance (font, 8), ==, 0);
g_assert_cmpuint (hb_font_get_glyph_h_advance (font, 9), ==, 0); g_assert_cmpuint (hb_font_get_glyph_h_advance (font, 9), ==, 0);
g_assert_cmpuint (hb_font_get_glyph_h_advance (font,10), ==, 0); g_assert_cmpuint (hb_font_get_glyph_h_advance (font,10), ==, 0);

View File

@ -45,6 +45,7 @@ test_maxp_and_loca (void)
g_assert_cmpuint (hb_face_get_glyph_count (face), ==, 5); g_assert_cmpuint (hb_face_get_glyph_count (face), ==, 5);
hb_face_destroy (face); hb_face_destroy (face);
#ifndef HB_NO_BORING_EXPANSION
face = hb_face_builder_create (); face = hb_face_builder_create ();
HB_FACE_ADD_TABLE (face, "maxp", maxp_data); HB_FACE_ADD_TABLE (face, "maxp", maxp_data);
HB_FACE_ADD_TABLE (face, "loca", loca_data); HB_FACE_ADD_TABLE (face, "loca", loca_data);
@ -55,6 +56,7 @@ test_maxp_and_loca (void)
HB_FACE_ADD_TABLE (face, "loca", loca_data); HB_FACE_ADD_TABLE (face, "loca", loca_data);
g_assert_cmpuint (hb_face_get_glyph_count (face), ==, 8); g_assert_cmpuint (hb_face_get_glyph_count (face), ==, 8);
hb_face_destroy (face); hb_face_destroy (face);
#endif
} }