-
Notifications
You must be signed in to change notification settings - Fork 43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
kern pairs between Arabic numerals missing from kern feature #198
Comments
ping @behdad |
Actually I’m not even sure that the correct place for Arabic numerals is in the kern_ltr lookup. @khaledhosny could you advise? |
I used to kern my Arabic numbers in LTR direction, but I’m not sure any more. I think HarfBuzz will apply the kerning in RTL direction (the script native direction) while MS implementation(s) will apply it in LTR direction (the text direction). That is one of the big annoying incompatibilities between HarfBuzz and MS implementation(s). If this is the case (needs testing) then I think we need to duplicate the kerning in both LTR and RTL lookups (this also needs testing to see if each engine will not apply both). |
more info on the difference between harfbuzz and MS as regards kerning of arabic numbers harfbuzz/harfbuzz#501 (comment) i'm not sure what to do... Khaled suggested to "duplicate the kerning in both LTR and RTL lookups". Do we do that only for Arabic numerals (i.e. bidi class "AN") or for other characters too? Let me summarise how ufo2ft currently splits the kerning.plist into two LTR and RTL groups, so we are on the same page:
From these, it writes two standalone kern lookups, Following the above logic, Arabic numerals are being left in the LTR group (because their bidi class is nether "R" nor "AL"). However (from commit 9757f20) the LTR lookup is only written if the languagesystem declaration contains any LTR script (and I'd appreciate if anyone could help here. |
anybody has examples of kerning.plist being used for kerning Arabic letters or another RTL script? I'd like to use for my tests, but can't find much. |
cc @typoman Btw how does glyphs handle the arabic numerals kerning? does it do the "duplicate the kerning in both LTR and RTL lookups" thing? |
Looking at the features.fea generated by Glyphs.app in ~/Library/Application Support/Glyphs/Temp when exporting the Noto Sans Arabic, it appears that the arabic numerals are placed in a Although it's not consistent. As soon as I add a right-to-left kerning pair between two arabic non-numbers, and export again, I can see a new Another thing I noticed is that, if the font has some kern feature already defined, as is the case for Noto Sans Arabic (it's got some contextual pos rules), then the kern_DFLT is placed above and the kern_arbic below the pre-existing kern snippet. So it's neither "append" nor "prepend" (see #202), but a mix of both... It would be great if @schriftgestalt could give us some clue as to how Glyphs.app |
@belluzj pointed this is related to unified-font-object/ufo-spec#16 (comment) |
Thanks for reminding me of that link, with all the related links and discussions! From #8, it seems that @graphicore first, and then @jamesgk (in #45) tried to apply the euristic @behdad suggested here. I'll write some tests to convince myself that ufo2ft is doing exactly that. But the conclusion regarding arabic numbers' kerning is a little bit disappointing...
That would mean scrap the entire kerning.plist in NotoSansArabic, which is only made of pairs between Arabic figures. |
Indeed. For reasons that I describe in: Let's also talk about that issue. Khaled, any suggestions? |
Kerning between Arabic numerals is fine. What can’t be done is kerning between letters and numerals. There is a layout direction change between them and that means numbers and letters are layer out separately. Things get interesting with punctuation. It has no inherited direction so there is some heuristic to determine if they are RTL or LTR. Things like the default script and what letters are next to it play a role. But you never know what will happen. Glyphs sorts the pairs by the script of the first glyph. So arabic numbers are LTR and thous end up in the default group (with all the latin numbers). Most cross script pairs are ignored so arabic letter + arabic numbers should be ignored but you already saw that it is complicated... |
I'm thinking that when a font contains both LTR and RTL kerning, we should divide the pairs into three main groups:
Then we produce two kern lookup:
This is what the current ufo2ft kern writer does: if a RTL script is present in languagesystems statements, separate from the generic kerning dictionary all the RTL pairs (defined as "if any character in the pair has strong R or AL bidi type", thus excluding pairs between arabic numbers), then make a separate RTL lookup (with format B value records) and only register it under RTL scripts; the remainder (anything not RTL as defined above) is registered implicitly for all the languagesystems. Any comments are highly appreciated, thanks. |
ok, what I'm saying is exactly the same that Behdad wrote here
|
Sorry to join late. RTL/RTL works in HarfBuzz, LTR/LTR Arabic numerals doesn't work, although it works in CoreText. I remember LTR/LTR Arabic numerals worked in inDesign too despite its bad reputation, can't confirm. LTR/RTL is better to be put in a RTL lookup, because punctuation and Arabic letter is an example although I can't seem to find a case that a LTR Arabic numeral kerned to an RTL letter works in either CoreText or Harfbuzz atm, considering that the positioning is inside a RTL lookup. Below is the structure of a sample feature file I write.
haft and hasht are LTR Arabic numerals, reh.isol and alef.isol are Arabic RTL letters. |
Maybe an issue should be opened on LTR/LTR Arabic numerals kerning that doesn't work in Harfbuzz? |
My experience is that the pair should be in the lookup that fits the first letter. So ‘pos one-ar alef-ar 20;’ would need to go in a LTR lookup. |
Just to summarize the situation:
I don’t obviously have an answer to this incompatibility other than for HarfBuzz to find a way to handle this in a compatible way. As for ufo2ft I guess it should just kern the Arabic digits LTR and want users this will give the wrong result in HarfBuzz and let them decide if dropping the kerns entirely is a better trade off (by editing the fonts obviously, ufo2ft does not nee to be too smart here). |
BTW, Arabic numbers kerning in HarfBuzz works if you set the script to |
Also, |
I don't think dropping the LTR/LTR Arabic numerals pairs would be a solution just because Harfbuzz doesn't do it, since most of the text engines do shape it correctly. In my experience Arabic numerals need kerning especially this pair: ۷۸. |
Depends on your audience, HarfBuzz might be what the majority of your users are using so it doesn't matter whose bug it is until it is fixed. Anyway, I’m not suggesting ufo2ft drop anything, just warn it's users i.e. the type designers and let them decide for themselves what they want. Personally I always default to tabular figure because they work in more situations than proportional ones, so digit kerning is limited to a non-default case making it a not so important issue. |
I definitely want to fix HarfBuzz to do similar to Uniscribe. But I want everyone to understand the issue completely: the LTR kern pair for digits GO INTO THE RTL KERNING TABLE! That's the problem. |
Ok I want to understand this correctly. Does it mean typical compilers like FDK puts the digits in the RTL table, so it's better that the compilers change? |
If the number kerning is in a RTL lookup, then is doesn't work in Indesign and Safari. In a LTR lookup, it works as expected. Chrome applies the kerning to the wrong pair. So, if I have the text |
I just realised that while fixing the problem of LTR Arabic numerals, I have overlooked the rest of the RTL scripts that use the common digits, like Hebrew. The new KernFeatureWriter only creates two LTR and RTL lookups, and register the former only to the LTR scripts, and the latter only to the RTL scripts. Which means that digits (whose script is "Zyyy", i.e. Common) will end up in the LTR lookup, and kerning between them will not display when, say, Hebrew is active. |
This 'kern_dflt' lookup includes all the pairs for the neutral-direction glyphs (Common or Inherited script), which as such do not belong to neither the LTR scripts' group, nor the RTL one. The lookup is included in all defined languagesystems. If we are not splitting up LTR/RTL lookups, then we do not need to create a separate kern_dflt lookup. Note that this lookup is only registered for the kern feature, and does not affect the dist feature (if any). #198 (comment)
ok I think this should be fixed now.. Phew. |
The kerning.plist in the UFOs generated from noto-source/NotoSansArabic-MM.glyphs only contains kerning pairs between Arabic numerals. These are written left-to-right, have special bidirectional class "AN".
Our
_glyphIsRtl
method correctly return False. So these kern pairs are not moved to the RTL kern lookup.The problem is the current KernFeatureWriter doesn't output any kerning for them, not even in the LTR kern lookup...
I believe it has to do with this commit, whereby we only output LTR lookup if the
ltrScripts
list is not empty, or if the latter is empty and thertlScripts
list is empty:9757f20
But the font's features.fea has
languagesytem DFLT dftl; languagesystem arab dflt;
, so theltrScripts
list is empty andrtlScripts
is non empty.This is also related:
#112
I'll follow up with a failing test case
The text was updated successfully, but these errors were encountered: