Bug 71615

Summary: Arabic fallback shaper is not used when it needs to be
Product: HarfBuzz Reporter: Eli Fidler <efidler>
Component: srcAssignee: Behdad Esfahbod <freedesktop>
Status: RESOLVED WONTFIX QA Contact:
Severity: major    
Priority: medium CC: freedesktop, jfkthame
Version: unspecified   
Hardware: Other   
OS: All   
Whiteboard:
i915 platform: i915 features:
Attachments: output of "hb-view --direction=rtl --language=ar --features=-liga /usr/share/fonts/truetype/msttcorefonts/Arial.ttf 'لا' "
potential fix

Description Eli Fidler 2013-11-14 16:20:51 UTC
The version of Arial that comes with msttcorefonts on Ubuntu is 2.82. That version of Arial has init, medi, fina, and liga features in GSUB (for Arabic script).

Notably missing is rlig. The lam-alef ligatures are in liga.

I think HarfBuzz should use the fallback shaper (at least) for rlig when rendering lam-alef with this font, but it currently doesn't because it's only used if all of init, medi, fina, and isol are missing.

The specific case I have is for https://code.google.com/p/chromium/issues/detail?id=41990, where I want to disable optional ligatures in the Blink complex text path by default, but I want lam-alef to keep working. I know this font is "broken", but it's not going away any time soon.
Comment 1 Eli Fidler 2013-11-14 16:25:23 UTC
Created attachment 89202 [details]
output of "hb-view --direction=rtl --language=ar --features=-liga /usr/share/fonts/truetype/msttcorefonts/Arial.ttf 'لا' "
Comment 2 Eli Fidler 2013-11-14 16:55:32 UTC
Created attachment 89205 [details] [review]
potential fix

Maybe something like this would be acceptable, although it might be nice to separate out the forms substitution fallbacks from the ligature fallbacks.
Comment 3 Behdad Esfahbod 2013-11-15 16:35:51 UTC
I'm hesitant to make this change.  In fact, I'm leaning towards changing the current fallback logic to only kick in if there is no Arab script in GSUB.

Jonathan, what do you think?
Comment 4 Eli Fidler 2013-11-15 16:46:50 UTC
Is there something really bad about the fallback shaper you're trying to avoid?

This font is very common, and users often install the msttcorefonts and put them at the top of their fallback list.
Comment 5 Behdad Esfahbod 2013-11-15 16:58:16 UTC
(In reply to comment #4)
> Is there something really bad about the fallback shaper you're trying to
> avoid?

Yes, it deviates us further from the standard.  I'm sure there's someone out there making a alternative Arabic font that doesn't have init/medi/fina/isol forms as we know them...  I agree that the fallback shaper typically won't break things, but ti's not something we should promote either.

> This font is very common, and users often install the msttcorefonts and put
> them at the top of their fallback list.

That's fine, as long as they don't go out of their way to turn liga off.
Comment 6 Jonathan Kew 2013-11-15 19:49:30 UTC
(In reply to comment #3)
> I'm hesitant to make this change.

Yeah, I'm not keen on this either.

>  In fact, I'm leaning towards changing the
> current fallback logic to only kick in if there is no Arab script in GSUB.

I think that makes sense. If a font has a GSUB table that supports Arabic, we should simply use that and assume that the font designer has provided whatever features are appropriate.

(In reply to comment #0)
> The specific case I have is for
> https://code.google.com/p/chromium/issues/detail?id=41990, where I want to
> disable optional ligatures in the Blink complex text path by default

Why would you want to do this? Ligatures in 'liga' should be enabled by default, and only disabled if the user explicitly chooses to disable them.

(At which point, the fact that this disables lam-alef in that particular font is simply something the user has to accept as a consequence of their decision to override the default behavior.)
Comment 7 Eli Fidler 2013-11-15 20:49:00 UTC
Does it change your mind at all that all Arabic fonts from Windows XP have this same structure, where lam-alef is in liga? I checked arial.ttf, simpo.ttf, and trado.ttf. Later versions of these fonts (Windows 7, I guess) changed to using rlig for lam-alef.

I know disabling liga is not a totally standard use case, but it seems like a reasonable thing to want to do. Microsoft's OpenType page says: The 'liga' feature is used to map glyphs to their optional ligated form. To me, this means disabling liga should be "safe". Since not ligating lam-alef isn't "safe", it seems we can fix these fonts for the cost of a minor code change.
Comment 8 Behdad Esfahbod 2013-11-15 20:54:05 UTC
(In reply to comment #7)
> Does it change your mind at all that all Arabic fonts from Windows XP have
> this same structure, where lam-alef is in liga? I checked arial.ttf,
> simpo.ttf, and trado.ttf. Later versions of these fonts (Windows 7, I guess)
> changed to using rlig for lam-alef.
> 
> I know disabling liga is not a totally standard use case, but it seems like
> a reasonable thing to want to do. Microsoft's OpenType page says: The 'liga'
> feature is used to map glyphs to their optional ligated form. To me, this
> means disabling liga should be "safe". Since not ligating lam-alef isn't
> "safe", it seems we can fix these fonts for the cost of a minor code change.

We know all of that.  The combination of XP fonts, on Free Software systems, with liga turned off and for a good reason, really is not interesting enough to us.  And as I replied to you on the Chromium issue, your usecase is also broken.
Comment 9 Eli Fidler 2013-11-15 20:59:20 UTC
Ok, thanks for the feedback. I'll resolve WONTFIX.
Comment 10 Jonathan Kew 2013-11-15 21:06:29 UTC
FWIW, the description of the 'liga' feature in the registry[1] says: "This feature serves a critical function in some contexts, and should be active by default."

So I stand by the position that Blink should not be disabling it by default. It should only be disabled if a user explicitly chooses to disable it; and if this causes lam-alef breakage with some fonts, so be it.

[1] http://www.microsoft.com/typography/otspec/features_ko.htm#liga

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.