Skip to content

A variant, script or region subtag never selects the language system HarfBuzz picks outside zh, e.g. el-polyton, ro-MD, yue #206

Description

@jakejackson1

OtlTags::language() (src/Shaper/OtlTags.php, upstream Otl::_getOTLLangTag() at src/Otl.php:6150) looks a tag up by its first subtag in Ucdn::$ot_languages. After #201 Chinese is the one exception. HarfBuzz 14.3.1 also maps several multi-subtag tags to a language system the first subtag doesn't give. They come from hb_ot_tags_from_complex_language() and the extended-language rule in hb_ot_tags_from_language():

  • Variants and scripts that apply to any language (hb-ot-tag-table.hh:1627-1689): -polytonPGR, -provencPRO, -fonipaIPPH, -fonnapaAPPH, -geokKGE, -syre/-syrj/-syrnSYRE/SYRJ/SYRN.
  • Language and script or region: ga-LatgIRT (:2252), mnw-THMONT (:2651), ro-MDMOL then ROM (:2741).
  • Chinese languages other than zh: cmn, yue, nan, hak, wuu, lzh, gan, hsn and a dozen more have no key in Ucdn::$ot_languages. HarfBuzz maps each to ZHS, except yueZHH and lzhZHT (:517-1141). It also gives each one the same script and region rules as zh (e.g. yue-HansZHS, cmn-Hant-TWZHT).
  • Extended language subtags (hb-ot-tag.cc, hb_ot_tags_from_language()): where the second subtag is three letters, HarfBuzz looks that up instead, so zh-yueZHH and zh-lzhZHT.
  • More than one tag for a language: the two-letter table lists gaIRI, IRT and nvNAV, ATH. HarfBuzz tries each in turn, and Ucdn has only the first.

I measured each case below with a font whose script offers only HarfBuzz's tag, with a locl lookup under it. hb-shape --language selected that tag in every case. mPDF is OtlTags::language($lang, …) with every tag offered:

lang mPDF HarfBuzz
el-polyton ELL PGR
ga-Latg IRI IRT
ro-MD ROM MOL
mnw-TH MON MONT
oc-provenc OCI PRO
syr-Syre SYR SYRE
en-fonipa DFLT IPPH
ka-Geok DFLT KGE
yue, yue-Hant-HK DFLT ZHH
cmn-Hans DFLT ZHS
lzh DFLT ZHT
zh-yue ZHS ZHH
zh-lzh ZHS ZHT

Expected: follow HarfBuzz for these. #201 adds the ordered-candidates shape (ZHTM then ZHH) that ro-MD and the multi-tag languages need.

Found while fixing #201, which covers only zh.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions