[ft] Remap legacy Arabic PUA codepoints

Similar to what ot font finctions does, to support Support legacy
pre-OpenType Windows 3.1-era fonts.
This commit is contained in:
Khaled Hosny 2022-06-18 13:28:54 +02:00 committed by Behdad Esfahbod
parent 69cbd365cc
commit 189e8c326e
2 changed files with 31 additions and 18 deletions

View File

@ -37,6 +37,8 @@
#include "hb-font.hh" #include "hb-font.hh"
#include "hb-machinery.hh" #include "hb-machinery.hh"
#include "hb-cache.hh" #include "hb-cache.hh"
#include "hb-ot-os2-table.hh"
#include "hb-ot-shaper-arabic-pua.hh"
#include FT_ADVANCES_H #include FT_ADVANCES_H
#include FT_MULTIPLE_MASTERS_H #include FT_MULTIPLE_MASTERS_H
@ -298,7 +300,7 @@ hb_ft_font_unlock_face (hb_font_t *font)
static hb_bool_t static hb_bool_t
hb_ft_get_nominal_glyph (hb_font_t *font HB_UNUSED, hb_ft_get_nominal_glyph (hb_font_t *font,
void *font_data, void *font_data,
hb_codepoint_t unicode, hb_codepoint_t unicode,
hb_codepoint_t *glyph, hb_codepoint_t *glyph,
@ -310,14 +312,25 @@ hb_ft_get_nominal_glyph (hb_font_t *font HB_UNUSED,
if (unlikely (!g)) if (unlikely (!g))
{ {
if (unlikely (ft_font->symbol) && unicode <= 0x00FFu) if (unlikely (ft_font->symbol))
{ {
switch ((unsigned) font->face->table.OS2->get_font_page ()) {
default:
if (unicode <= 0x00FFu)
/* For symbol-encoded OpenType fonts, we duplicate the /* For symbol-encoded OpenType fonts, we duplicate the
* U+F000..F0FF range at U+0000..U+00FF. That's what * U+F000..F0FF range at U+0000..U+00FF. That's what
* Windows seems to do, and that's hinted about at: * Windows seems to do, and that's hinted about at:
* https://docs.microsoft.com/en-us/typography/opentype/spec/recom * https://docs.microsoft.com/en-us/typography/opentype/spec/recom
* under "Non-Standard (Symbol) Fonts". */ * under "Non-Standard (Symbol) Fonts". */
g = FT_Get_Char_Index (ft_font->ft_face, 0xF000u + unicode); g = FT_Get_Char_Index (ft_font->ft_face, 0xF000u + unicode);
break;
case OT::OS2::font_page_t::FONT_PAGE_SIMP_ARABIC:
g = FT_Get_Char_Index (ft_font->ft_face, _hb_remap_arabic_pua1 (unicode));
break;
case OT::OS2::font_page_t::FONT_PAGE_TRAD_ARABIC:
g = FT_Get_Char_Index (ft_font->ft_face, _hb_remap_arabic_pua2 (unicode));
break;
}
if (!g) if (!g)
return false; return false;
} }

View File

@ -1,11 +1,11 @@
../fonts/df768b9c257e0c9c35786c47cae15c46571d56be.ttf;;U+0633,U+064F,U+0644,U+064E,U+0651,U+0627,U+0651,U+0650,U+0645,U+062A,U+06CC;[uni06CC.fina=10+1655|uni062A.medi=9+868|uni0645.init=8+1098|uni0650=2@148,0+0|uni0651=2@187,736+0|uni064E=2@883,1259+0|uni0651=2@922,736+0|uni06440627.fina=2+1470|uni064F=0@629,-10+0|uni0633.init=0+1585] ../fonts/df768b9c257e0c9c35786c47cae15c46571d56be.ttf;;U+0633,U+064F,U+0644,U+064E,U+0651,U+0627,U+0651,U+0650,U+0645,U+062A,U+06CC;[uni06CC.fina=10+1655|uni062A.medi=9+868|uni0645.init=8+1098|uni0650=2@148,0+0|uni0651=2@187,736+0|uni064E=2@883,1259+0|uni0651=2@922,736+0|uni06440627.fina=2+1470|uni064F=0@629,-10+0|uni0633.init=0+1585]
../fonts/SimpArabicTest.ttf;--font-funcs=ot;U+0628,U+0650,U+0633,U+0652,U+0645,U+0650,U+0020,U+0020,U+0627,U+0644,U+0644,U+0647,U+0020,U+0627,U+0644,U+0631,U+0651,U+064E,U+062D,U+0652,U+0645,U+064E,U+0646,U+0650,U+0020,U+0627,U+0644,U+0631,U+062D,U+0650,U+064A,U+0645;[daggerdbl=31+584|c142=30+276|twosuperior=28@130,0+0|bracketleft=28+515|c=27+240|quotedblbase=26+216|J=25+289|parenright=24+391|twosuperior=22@166,-236+0|Eacute=22+587|logicalnot=20@127,-87+0|dagger=20+509|registered=18@137,-97+0|bracketleft=18+515|logicalnot=15@-7,261+0|plusminus=15@-49,-97+0|c=15+240|quotedblbase=14+216|J=13+289|parenright=12+391|guilsinglleft=11+599|quotedblbase=10+216|quotedblbase=9+216|J=8+289|parenright=7+391|parenright=6+391|twosuperior=4@165,-316+0|daggerdbl=4+584|registered=2@276,-102+0|j=2+793|twosuperior=0@-11,-196+0|R=0+232] ../fonts/SimpArabicTest.ttf;;U+0628,U+0650,U+0633,U+0652,U+0645,U+0650,U+0020,U+0020,U+0627,U+0644,U+0644,U+0647,U+0020,U+0627,U+0644,U+0631,U+0651,U+064E,U+062D,U+0652,U+0645,U+064E,U+0646,U+0650,U+0020,U+0627,U+0644,U+0631,U+062D,U+0650,U+064A,U+0645;[daggerdbl=31+584|c142=30+276|twosuperior=28@130,0+0|bracketleft=28+515|c=27+240|quotedblbase=26+216|J=25+289|parenright=24+391|twosuperior=22@166,-236+0|Eacute=22+587|logicalnot=20@127,-87+0|dagger=20+509|registered=18@137,-97+0|bracketleft=18+515|logicalnot=15@-7,261+0|plusminus=15@-49,-97+0|c=15+240|quotedblbase=14+216|J=13+289|parenright=12+391|guilsinglleft=11+599|quotedblbase=10+216|quotedblbase=9+216|J=8+289|parenright=7+391|parenright=6+391|twosuperior=4@165,-316+0|daggerdbl=4+584|registered=2@276,-102+0|j=2+793|twosuperior=0@-11,-196+0|R=0+232]
../fonts/SimpArabicTest.ttf;--font-funcs=ot;U+0020,U+0644,U+0627,U+0020,U+0644,U+0623,U+0020,U+0644,U+064E,U+0623,U+064E,U+0020,U+0623,U+064E,U+0646,U+062A;[U=15+693|DEL=14+227|logicalnot=12@17,307+0|L=12+289|parenright=11+391|logicalnot=7@41,267+0|logicalnot=7@378,267+0|brokenbar=7+674|parenright=6+391|brokenbar=4+674|parenright=3+391|yen=1+709|parenright=0+391] ../fonts/SimpArabicTest.ttf;;U+0020,U+0644,U+0627,U+0020,U+0644,U+0623,U+0020,U+0644,U+064E,U+0623,U+064E,U+0020,U+0623,U+064E,U+0646,U+062A;[U=15+693|DEL=14+227|logicalnot=12@17,307+0|L=12+289|parenright=11+391|logicalnot=7@41,267+0|logicalnot=7@378,267+0|brokenbar=7+674|parenright=6+391|brokenbar=4+674|parenright=3+391|yen=1+709|parenright=0+391]
../fonts/SimpArabicTest.ttf;--font-funcs=ot;U+0021,U+0022,U+00AB,U+00BB,U+0025,U+00D7,U+00F7,U+0028,U+0020,U+0029,U+002A,U+002B,U+060C,U+002E,U+002F,U+003A,U+061B,U+2018,U+003D,U+2019,U+061F,U+005B,U+005D,U+002D,U+0022;[asterisk=0+269|plus=1+408|comma=2+509|hyphen=3+509|period=4+573|slash=5+572|zero=6+572|one=7+300|parenright=8+391|two=9+300|three=10+551|four=11+572|five=12+283|seven=13+268|eight=14+372|C=15+268|D=16+295|E=17+175|F=18+572|G=19+175|H=20+485|d=21+329|f=22+329|six=23+322|plus=24+408] ../fonts/SimpArabicTest.ttf;;U+0021,U+0022,U+00AB,U+00BB,U+0025,U+00D7,U+00F7,U+0028,U+0020,U+0029,U+002A,U+002B,U+060C,U+002E,U+002F,U+003A,U+061B,U+2018,U+003D,U+2019,U+061F,U+005B,U+005D,U+002D,U+0022;[asterisk=0+269|plus=1+408|comma=2+509|hyphen=3+509|period=4+573|slash=5+572|zero=6+572|one=7+300|parenright=8+391|two=9+300|three=10+551|four=11+572|five=12+283|seven=13+268|eight=14+372|C=15+268|D=16+295|E=17+175|F=18+572|G=19+175|H=20+485|d=21+329|f=22+329|six=23+322|plus=24+408]
../fonts/SimpArabicTest.ttf;--font-funcs=ot;U+061F,U+003F,U+0640;[H=0+485|H=1+485|h=2+171] ../fonts/SimpArabicTest.ttf;;U+061F,U+003F,U+0640;[H=0+485|H=1+485|h=2+171]
../fonts/SimpArabicTest.ttf;--font-funcs=ot;U+0628,U+0644,U+0627,U+0020,U+0628,U+0644,U+0625;[ordfeminine=5+674|R=4+232|parenright=3+391|yen=1+709|R=0+232] ../fonts/SimpArabicTest.ttf;;U+0628,U+0644,U+0627,U+0020,U+0628,U+0644,U+0625;[ordfeminine=5+674|R=4+232|parenright=3+391|yen=1+709|R=0+232]
../fonts/TradArabicTest.ttf;--font-funcs=ot;U+0628,U+0650,U+0633,U+0652,U+0645,U+0650,U+0020,U+0020,U+0627,U+0644,U+0644,U+0647,U+0020,U+0627,U+0644,U+0631,U+0651,U+064E,U+062D,U+0652,U+0645,U+064E,U+0646,U+0650,U+0020,U+0627,U+0644,U+0631,U+062D,U+0650,U+064A,U+0645;[fnmeem=31+1069|midya=30+499|kasrah2=28@151,0+0|inhaa=28+1341|fnra=27+702|inlam=26+358|alef=25+444|righttoleftspace=24+468|kasrah2=22@110,-604+0|fnnoon=22+1259|fathah2=18@-145,-168+0|sukun2=18@760,-166+0|f29b=18+1497|fathah2=15@-168,56+0|shaddah2=15@-51,-416+0|fnra=15+702|inlam=14+358|alef=13+444|righttoleftspace=12+468|fnha=11+776|midlam=10+403|inlam=9+358|alef=8+444|righttoleftspace=7+468|righttoleftspace=6+468|kasrah2=4@15,-1102+0|fnmeem=4+1069|sukun2=2@220,-386+0|midseen=2+1163|kasrah2=0@-324,-403+0|inbaa=0+389] ../fonts/TradArabicTest.ttf;;U+0628,U+0650,U+0633,U+0652,U+0645,U+0650,U+0020,U+0020,U+0627,U+0644,U+0644,U+0647,U+0020,U+0627,U+0644,U+0631,U+0651,U+064E,U+062D,U+0652,U+0645,U+064E,U+0646,U+0650,U+0020,U+0627,U+0644,U+0631,U+062D,U+0650,U+064A,U+0645;[fnmeem=31+1069|midya=30+499|kasrah2=28@151,0+0|inhaa=28+1341|fnra=27+702|inlam=26+358|alef=25+444|righttoleftspace=24+468|kasrah2=22@110,-604+0|fnnoon=22+1259|fathah2=18@-145,-168+0|sukun2=18@760,-166+0|f29b=18+1497|fathah2=15@-168,56+0|shaddah2=15@-51,-416+0|fnra=15+702|inlam=14+358|alef=13+444|righttoleftspace=12+468|fnha=11+776|midlam=10+403|inlam=9+358|alef=8+444|righttoleftspace=7+468|righttoleftspace=6+468|kasrah2=4@15,-1102+0|fnmeem=4+1069|sukun2=2@220,-386+0|midseen=2+1163|kasrah2=0@-324,-403+0|inbaa=0+389]
../fonts/TradArabicTest.ttf;--font-funcs=ot;U+0020,U+0644,U+0627,U+0020,U+0644,U+0623,U+0020,U+0644,U+064E,U+0623,U+064E,U+0020,U+0623,U+064E,U+0646,U+062A;[fntaa=15+1808|innoon=14+389|fathah2=12@-279,883+0|hamzahonalef=12+479|righttoleftspace=11+468|fathah2=7@-190,862+0|fathah2=7@468,862+0|hamzahonlamelef=7+1316|righttoleftspace=6+468|hamzahonlamelef=4+1316|righttoleftspace=3+468|lamelef=1+1316|righttoleftspace=0+468] ../fonts/TradArabicTest.ttf;;U+0020,U+0644,U+0627,U+0020,U+0644,U+0623,U+0020,U+0644,U+064E,U+0623,U+064E,U+0020,U+0623,U+064E,U+0646,U+062A;[fntaa=15+1808|innoon=14+389|fathah2=12@-279,883+0|hamzahonalef=12+479|righttoleftspace=11+468|fathah2=7@-190,862+0|fathah2=7@468,862+0|hamzahonlamelef=7+1316|righttoleftspace=6+468|hamzahonlamelef=4+1316|righttoleftspace=3+468|lamelef=1+1316|righttoleftspace=0+468]
../fonts/TradArabicTest.ttf;--font-funcs=ot;U+0021,U+0022,U+00AB,U+00BB,U+0025,U+00D7,U+00F7,U+0028,U+0020,U+0029,U+002A,U+002B,U+060C,U+002E,U+002F,U+003A,U+061B,U+2018,U+003D,U+2019,U+061F,U+005B,U+005D,U+002D,U+0022;[greater=0+481|question=1+559|at=2+849|A=3+849|percentarabic=4+1353|C=5+927|D=6+1196|E=7+855|righttoleftspace=8+468|F=9+855|G=10+884|H=11+1083|commaarabic=12+755|K=13+649|L=14+704|W=15+450|semicolonarabic=16+755|.notdef=17+745|Z=18+1128|.notdef=19+745|questionarabic=20+845|x=21+739|z=22+739|J=23+753|question=24+559] ../fonts/TradArabicTest.ttf;;U+0021,U+0022,U+00AB,U+00BB,U+0025,U+00D7,U+00F7,U+0028,U+0020,U+0029,U+002A,U+002B,U+060C,U+002E,U+002F,U+003A,U+061B,U+2018,U+003D,U+2019,U+061F,U+005B,U+005D,U+002D,U+0022;[greater=0+481|question=1+559|at=2+849|A=3+849|percentarabic=4+1353|C=5+927|D=6+1196|E=7+855|righttoleftspace=8+468|F=9+855|G=10+884|H=11+1083|commaarabic=12+755|K=13+649|L=14+704|W=15+450|semicolonarabic=16+755|.notdef=17+745|Z=18+1128|.notdef=19+745|questionarabic=20+845|x=21+739|z=22+739|J=23+753|question=24+559]
../fonts/TradArabicTest.ttf;--font-funcs=ot;U+061F,U+003F,U+0640;[questionarabic=0+845|questionarabic=1+845|tatweelnarrow=2+378] ../fonts/TradArabicTest.ttf;;U+061F,U+003F,U+0640;[questionarabic=0+845|questionarabic=1+845|tatweelnarrow=2+378]
../fonts/TradArabicTest.ttf;--font-funcs=ot;U+0644,U+0645,U+0020,U+0628,U+0645,U+0627;[fnalef=5+468|f296=3+897|righttoleftspace=2+468|f205=0+903] ../fonts/TradArabicTest.ttf;;U+0644,U+0645,U+0020,U+0628,U+0645,U+0627;[fnalef=5+468|f296=3+897|righttoleftspace=2+468|f205=0+903]