diff --git a/src/hb-ft.cc b/src/hb-ft.cc index b8c0c8519..e1cac3fd9 100644 --- a/src/hb-ft.cc +++ b/src/hb-ft.cc @@ -39,6 +39,7 @@ #include "hb-machinery.hh" #include "hb-ot-os2-table.hh" #include "hb-ot-shaper-arabic-pua.hh" +#include "hb-ot-shaper-hebrew-pua.hh" #include "hb-paint.hh" #include FT_MODULE_H @@ -397,11 +398,9 @@ hb_ft_get_nominal_glyph (hb_font_t *font, if (unlikely (!g)) { - if (unlikely (ft_font->symbol)) - { - switch ((unsigned) font->face->table.OS2->get_font_page ()) { + switch ((unsigned) font->face->table.OS2->get_font_page ()) { case OT::OS2::font_page_t::FONT_PAGE_NONE: - if (unicode <= 0x00FFu) + if (unlikely (ft_font->symbol) && unicode <= 0x00FFu) /* For symbol-encoded OpenType fonts, we duplicate the * U+F000..F0FF range at U+0000..U+00FF. That's what * Windows seems to do, and that's hinted about at: @@ -409,6 +408,11 @@ hb_ft_get_nominal_glyph (hb_font_t *font, * under "Non-Standard (Symbol) Fonts". */ g = FT_Get_Char_Index (ft_font->ft_face, 0xF000u + unicode); break; +#ifndef HB_NO_OT_SHAPER_HEBREW_FALLBACK + case OT::OS2::font_page_t::FONT_PAGE_HEBREW: + g = FT_Get_Char_Index (ft_font->ft_face, _hb_hebrew_pua_map (unicode)); + break; +#endif #ifndef HB_NO_OT_SHAPER_ARABIC_FALLBACK case OT::OS2::font_page_t::FONT_PAGE_SIMP_ARABIC: g = FT_Get_Char_Index (ft_font->ft_face, _hb_arabic_pua_simp_map (unicode)); @@ -419,11 +423,8 @@ hb_ft_get_nominal_glyph (hb_font_t *font, #endif default: break; - } - if (!g) - return false; } - else + if (!g) return false; } diff --git a/src/hb-ot-cmap-table.hh b/src/hb-ot-cmap-table.hh index 91be90fe5..6aa9a0062 100644 --- a/src/hb-ot-cmap-table.hh +++ b/src/hb-ot-cmap-table.hh @@ -29,6 +29,7 @@ #include "hb-ot-os2-table.hh" #include "hb-ot-shaper-arabic-pua.hh" +#include "hb-ot-shaper-hebrew-pua.hh" #include "hb-open-type.hh" #include "hb-set.hh" #include "hb-cache.hh" @@ -2083,29 +2084,43 @@ struct cmap this->get_glyph_data = &this->format4_accel; this->get_glyph_funcZ = func; }; + auto font_page = face->table.OS2->get_font_page (); +#ifndef HB_NO_OT_SHAPER_HEBREW_FALLBACK + if (unlikely (font_page == OS2::font_page_t::FONT_PAGE_HEBREW)) + { + if (is_format4) + set_format4_getter (get_glyph_from_symbol); + else + this->get_glyph_funcZ = get_glyph_from_symbol; + } + else +#endif +#ifndef HB_NO_OT_SHAPER_ARABIC_FALLBACK + if (unlikely (font_page == OS2::font_page_t::FONT_PAGE_SIMP_ARABIC)) + { + if (is_format4) + set_format4_getter (get_glyph_from_symbol); + else + this->get_glyph_funcZ = get_glyph_from_symbol; + } + else if (unlikely (font_page == OS2::font_page_t::FONT_PAGE_TRAD_ARABIC)) + { + if (is_format4) + set_format4_getter (get_glyph_from_symbol); + else + this->get_glyph_funcZ = get_glyph_from_symbol; + } + else +#endif if (unlikely (symbol)) { - switch ((unsigned) face->table.OS2->get_font_page ()) { + switch ((unsigned) font_page) { case OS2::font_page_t::FONT_PAGE_NONE: if (is_format4) set_format4_getter (get_glyph_from_symbol); else this->get_glyph_funcZ = get_glyph_from_symbol; break; -#ifndef HB_NO_OT_SHAPER_ARABIC_FALLBACK - case OS2::font_page_t::FONT_PAGE_SIMP_ARABIC: - if (is_format4) - set_format4_getter (get_glyph_from_symbol); - else - this->get_glyph_funcZ = get_glyph_from_symbol; - break; - case OS2::font_page_t::FONT_PAGE_TRAD_ARABIC: - if (is_format4) - set_format4_getter (get_glyph_from_symbol); - else - this->get_glyph_funcZ = get_glyph_from_symbol; - break; -#endif default: if (is_format4) set_format4_getter (get_glyph_from); diff --git a/src/hb-ot-shaper-hebrew-pua.hh b/src/hb-ot-shaper-hebrew-pua.hh new file mode 100644 index 000000000..a9e3b648e --- /dev/null +++ b/src/hb-ot-shaper-hebrew-pua.hh @@ -0,0 +1,45 @@ +#ifndef HB_OT_SHAPER_HEBREW_PUA_HH +#define HB_OT_SHAPER_HEBREW_PUA_HH + +#include "hb.hh" + + +static inline uint16_t +_hb_hebrew_pua_map (unsigned u) +{ + if ((u >= 0x0020u && u <= 0x0040u) || + (u >= 0x005Bu && u <= 0x005Fu) || + (u >= 0x007Bu && u <= 0x007Eu)) + return 0xF000u + u; + + if ((u >= 0x05B0u && u <= 0x05C3u) || + (u >= 0x05D0u && u <= 0x05EAu)) + return 0xEB10u + u; + + if (u >= 0x2074u && u <= 0x2079u) + return 0xD010u + u; + + switch (u) + { + case 0x00A3u: return 0xF0A3u; + case 0x00A7u: return 0xF0A7u; + case 0x00B0u: return 0xF0B0u; + case 0x00B2u: return 0xF082u; + case 0x00B3u: return 0xF083u; + case 0x00B7u: return 0xF0B7u; + case 0x00B9u: return 0xF081u; + case 0x00BCu: return 0xF0BCu; + case 0x00BDu: return 0xF0BDu; + case 0x00BEu: return 0xF0BEu; + case 0x00D7u: return 0xF0AAu; + case 0x00F7u: return 0xF0BAu; + case 0x200Eu: return 0xF0FDu; + case 0x200Fu: return 0xF0FEu; + case 0x2070u: return 0xF080u; + case 0x20AAu: return 0xF0A4u; + default: return 0; + } +} + + +#endif /* HB_OT_SHAPER_HEBREW_PUA_HH */ diff --git a/src/meson.build b/src/meson.build index 035bed87b..1ca7bde60 100644 --- a/src/meson.build +++ b/src/meson.build @@ -217,6 +217,7 @@ hb_base_sources = files( 'hb-ot-shaper-arabic.hh', 'hb-ot-shaper-default.cc', 'hb-ot-shaper-hangul.cc', + 'hb-ot-shaper-hebrew-pua.hh', 'hb-ot-shaper-hebrew.cc', 'hb-ot-shaper-indic-table.cc', 'hb-ot-shaper-indic.cc', diff --git a/test/shape/data/in-house/fonts/LegacyHebrew3-0.ttf b/test/shape/data/in-house/fonts/LegacyHebrew3-0.ttf new file mode 100644 index 000000000..a1e848260 Binary files /dev/null and b/test/shape/data/in-house/fonts/LegacyHebrew3-0.ttf differ diff --git a/test/shape/data/in-house/fonts/LegacyHebrew3-1.ttf b/test/shape/data/in-house/fonts/LegacyHebrew3-1.ttf new file mode 100644 index 000000000..9b853a0c6 Binary files /dev/null and b/test/shape/data/in-house/fonts/LegacyHebrew3-1.ttf differ diff --git a/test/shape/data/in-house/meson.build b/test/shape/data/in-house/meson.build index 1253b08e5..af831def5 100644 --- a/test/shape/data/in-house/meson.build +++ b/test/shape/data/in-house/meson.build @@ -26,6 +26,7 @@ in_house_tests = [ 'hangul-jamo.tests', 'harfbust.tests', 'hebrew-diacritics.tests', + 'hebrew-legacy.tests', 'hyphens.tests', 'indic-consonant-with-stacker.tests', 'indic-decompose.tests', diff --git a/test/shape/data/in-house/tests/hebrew-legacy.tests b/test/shape/data/in-house/tests/hebrew-legacy.tests new file mode 100644 index 000000000..c79d0d9c1 --- /dev/null +++ b/test/shape/data/in-house/tests/hebrew-legacy.tests @@ -0,0 +1,3 @@ +@font-funcs=ot,ft +../fonts/LegacyHebrew3-0.ttf;--direction=ltr --no-positions --preserve-default-ignorables;U+0020,U+0021,U+00A3,U+00A7,U+00B0,U+00B2,U+00B3,U+00B7,U+00B9,U+00BC,U+00BD,U+00BE,U+00D7,U+00F7,U+05B0,U+05C3,U+05D0,U+05D1,U+05D2,U+05EA,U+200E,U+200F,U+2070,U+2074,U+2079,U+20AA;[space=0|exclam=1|sterling=2|section=3|degree=4|suptwo=5|supthree=6|middot=7|supone=8|quarter=9|half=10|threequarters=11|multiply=12|sheva=13|divide=13|sofpasuq=15|alef=16|bet=17|unicode-gimel=18|tav=19|lrm=20|rlm=21|supzero=22|supfour=23|supnine=24|sheqel=25] +../fonts/LegacyHebrew3-1.ttf;--direction=ltr --no-positions --preserve-default-ignorables;U+0020,U+0021,U+00A3,U+00A7,U+00B0,U+00B2,U+00B3,U+00B7,U+00B9,U+00BC,U+00BD,U+00BE,U+00D7,U+00F7,U+05B0,U+05C3,U+05D0,U+05D1,U+05D2,U+05EA,U+200E,U+200F,U+2070,U+2074,U+2079,U+20AA;[space=0|exclam=1|sterling=2|section=3|degree=4|suptwo=5|supthree=6|middot=7|supone=8|quarter=9|half=10|threequarters=11|multiply=12|sheva=13|divide=13|sofpasuq=15|alef=16|bet=17|unicode-gimel=18|tav=19|lrm=20|rlm=21|supzero=22|supfour=23|supnine=24|sheqel=25]