<p>Thanks Behdad,</p>
<p>Very useful and informative. Thanks.</p>
<p>Enjoy your tacos.</p>
<p>Andrew</p>
<div class="gmail_quote">On 29/12/2012 5:41 PM, "Behdad Esfahbod" <<a href="mailto:behdad@behdad.org">behdad@behdad.org</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
On 12-12-26 08:02 PM, Andrew Cunningham wrote:<br>
> Hi Behdad,<br>
<br>
Hi Andrew, everyone,<br>
<br>
Sorry for being slow on the list or on fixing bugs.  I'm in Mexico City and<br>
exploring the amazing tacos around town.  Hopefully I'll get back to fixing<br>
all reported issues next week.<br>
<br>
<br>
> Will the approach of using DFLT script work with a multi a multiscript font?<br>
> I.e. if I need to support Arabic (Jawi), Western Cham and Khmer?<br>
><br>
> And if I need to support reordering and ligatures DFLT will be ok?<br>
><br>
> Are all OT features supported by DFLT or only some?<br>
<br>
Let me just explain what HarfBuzz exactly does:<br>
<br>
Based on the Unicode script of the text and a set of hardcoded rules, we<br>
choose which shaper to use.  The current rules are in this piece of code:<br>
<br>
<br>
<a href="http://cgit.freedesktop.org/harfbuzz/tree/src/hb-ot-shape-complex-private.hh#n143" target="_blank">http://cgit.freedesktop.org/harfbuzz/tree/src/hb-ot-shape-complex-private.hh#n143</a><br>
<br>
To summarize:<br>
<br>
  - For Arabic, Mongolian, Syriac, N'ko, 'Phags-pa, and Mandaic, we always use<br>
the Arabic shaper,<br>
<br>
  - For Thai and Lao we use the Thai shaper,<br>
<br>
  - For Brahmi-derived scripts that have a left-matra kind of character we use<br>
the Indic shaper if and only if a non-DFLT GSUB table is found,<br>
<br>
  - For Khmer we use the Indic shaper if and only if the GSUB table has a<br>
'pref' feature,<br>
<br>
  - For Myanmar we only use the Indic shaper if the 'mym2' OpenType script is<br>
present, and NOT if it's 'mymr',<br>
<br>
  - Otherwise, use the default shaper.<br>
<br>
<br>
After this, we do our custom normalization (which also handles Hangul Jamo<br>
(de)composition as well as matra decompositions.  Then we map to glyphs, and<br>
apply script-specific OpenType shaping.<br>
<br>
<br>
Now, here's what each shaper does:<br>
<br>
<br>
  - Default shaper does this:<br>
<br>
    * Enables these features, in both GSUB and GPOS: ccmp, liga, locl, mark,<br>
mkmk, rlig,<br>
<br>
    * Depending on the text direction, enable for horizontal: calt, clig,<br>
curs, kern, rclt, and for vertical: valt, vert, vkrn, vpal, vtrt2,<br>
<br>
    * For horizontal text, enable either ltra and ltrm, or rtla and rtlm<br>
depending on the direction,<br>
<br>
    * Enables a few features based on the script: For Hangul, enable ljmo,<br>
vjmo, and tjmo.  For Tibetan enable abvs, blws, abvm, and blvm,<br>
<br>
    * All these features are enabled globally except for rtlm which is only<br>
enabled for RTL runs and characters that do NOT have a Unicode mirroring<br>
character, and applied together.<br>
<br>
<br>
  - The Thai shaper does two things:<br>
<br>
    * Use PUA-encoded shaping (using MS and Mac Unicode encodings) if there is<br>
no GSUB found,<br>
<br>
    * Do SARA AM decomposition and reordering,<br>
<br>
    * Apply all features from the default shaper.<br>
<br>
<br>
  - The Arabic shaper does Arabic joining analysis and do:<br>
<br>
    * Apply ccmp and locl features together,<br>
<br>
    * Apply one of init, medi, fina, iso, med2, fin2, or fin3 based on the<br>
analysis result,<br>
<br>
    * Apply rlig, then calt, then the three of cswh, dlig, and mset together,<br>
as well as other features from the default shaper.<br>
<br>
<br>
  - The Indic shaper does a bunch of things, all based on the MS Indic<br>
OpenType spec, extended to support more scripts.  In particular, it breaks<br>
text into syllables based on a grammar, and for each syllable does:<br>
<br>
    * Apply these features globally: locl and ccmp,<br>
<br>
    * Do initial-reordering,<br>
<br>
    * Apply the following features in this order: nukt, akhn, rphf, rkrf,<br>
pref, half, blwf, abvf, pstf, cfar, cjct, and vatu.  Of which, these ones are<br>
applied globally: nukt, akhn, rkrf, cjct, and vatu, and the rest based on<br>
analysis does on the syllable (and the font tables),<br>
<br>
    * Do final-reordering,<br>
<br>
    * Apply the following features all at the same time: init, pres, abvs,<br>
blws, psts, haln, dist, abvm, blwm.  Of which, all are applied globally except<br>
for init, as well as other features from default shaper, except for liga which<br>
is turned off.<br>
<br>
<br>
Indic initial-reordering consists of (omitting lots of details):<br>
<br>
  - Find base character.  Different rules are used for different categories of<br>
scripts,<br>
<br>
  - Reorder characters based on their desired position in the syllable,<br>
<br>
  - Make Reph sequence to be reordered later.<br>
<br>
<br>
Indic final-reordering consists of (omitting lots of details):<br>
<br>
  - Reorder left matra to the desired position,<br>
<br>
  - Reorder formed Reph to the desired position after base,<br>
<br>
  - Reorder pre-base reordering consonants.<br>
<br>
<br>
<br>
That's about it, at a high level.  So, to answer your question, if you depend<br>
on Indic reordering, you cannot rely on the DFLT script.  If you do NOT depend<br>
on such reordering, it is best to use the DFLT script such that the reordering<br>
rules do NOT interfere with your GSUB rules.  It is fine to mix tables for<br>
multiple scripts all under DFLT as long as the shaper-selection rules above<br>
work for you.<br>
<br>
Hope that answers your questions.<br>
<br>
Cheers,<br>
behdad<br>
</blockquote></div>