mirror of
https://github.com/storytold/harfbuzz.git
synced 2026-11-25 08:51:07 +01:00
[ot] Support legacy Hebrew cmap mappings
Use the OS/2 Windows 3.1 Hebrew font-page marker to fall back from Unicode characters to legacy F0xx cmap slots. Apply remapping for both symbol and Unicode-labeled Windows cmaps in the OpenType and FreeType font-function paths. Add 3/0 and 3/1 regression fonts, and preserve direct Unicode cmap entries ahead of remapping. Fixes: https://github.com/harfbuzz/harfbuzz/issues/6159 Assisted-by: OpenAI Codex <noreply@openai.com>
This commit is contained in:
1 parent
dfdc088c4d
commit
6a1ac28ceb
8 files changed
+89
-23
No files matched your search
+9
-8
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
+30
-15
@@ -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<CmapSubtableFormat4::accelerator_t, _hb_hebrew_pua_map>);
|
||||
else
|
||||
this->get_glyph_funcZ = get_glyph_from_symbol<CmapSubtable, _hb_hebrew_pua_map>;
|
||||
}
|
||||
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<CmapSubtableFormat4::accelerator_t, _hb_arabic_pua_simp_map>);
|
||||
else
|
||||
this->get_glyph_funcZ = get_glyph_from_symbol<CmapSubtable, _hb_arabic_pua_simp_map>;
|
||||
}
|
||||
else if (unlikely (font_page == OS2::font_page_t::FONT_PAGE_TRAD_ARABIC))
|
||||
{
|
||||
if (is_format4)
|
||||
set_format4_getter (get_glyph_from_symbol<CmapSubtableFormat4::accelerator_t, _hb_arabic_pua_trad_map>);
|
||||
else
|
||||
this->get_glyph_funcZ = get_glyph_from_symbol<CmapSubtable, _hb_arabic_pua_trad_map>;
|
||||
}
|
||||
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<CmapSubtableFormat4::accelerator_t, _hb_symbol_pua_map>);
|
||||
else
|
||||
this->get_glyph_funcZ = get_glyph_from_symbol<CmapSubtable, _hb_symbol_pua_map>;
|
||||
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<CmapSubtableFormat4::accelerator_t, _hb_arabic_pua_simp_map>);
|
||||
else
|
||||
this->get_glyph_funcZ = get_glyph_from_symbol<CmapSubtable, _hb_arabic_pua_simp_map>;
|
||||
break;
|
||||
case OS2::font_page_t::FONT_PAGE_TRAD_ARABIC:
|
||||
if (is_format4)
|
||||
set_format4_getter (get_glyph_from_symbol<CmapSubtableFormat4::accelerator_t, _hb_arabic_pua_trad_map>);
|
||||
else
|
||||
this->get_glyph_funcZ = get_glyph_from_symbol<CmapSubtable, _hb_arabic_pua_trad_map>;
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
if (is_format4)
|
||||
set_format4_getter (get_glyph_from<CmapSubtableFormat4::accelerator_t>);
|
||||
|
||||
@@ -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 */
|
||||
@@ -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',
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -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',
|
||||
|
||||
@@ -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]
|
||||
Reference in new issue
Block a user