Skip to content
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

Best-fit Bidi_Mirroring_Glyph could be better #7

Open
dscorbett opened this issue Feb 14, 2019 · 5 comments
Open

Best-fit Bidi_Mirroring_Glyph could be better #7

dscorbett opened this issue Feb 14, 2019 · 5 comments

Comments

@dscorbett
Copy link

dscorbett commented Feb 14, 2019

Font

NotoSansMath-Regular.ttf

Where the font came from, and when

Site: https://github.com/googlei18n/noto-fonts/blob/c30307083469f0c05e216ac75216fd454a517858/hinted/NotoSansMath-Regular.ttf
Date: 2019-02-04

Font version

Version 2.000

Issue

Characters whose bidi-mirrored glyphs are marked [BEST FIT] in BidiMirroring.txt are mirrored to their best fits, but it would be better to mirror them fully. For example, U+2272 LESS-THAN OR EQUIVALENT TO has a Bidi_Mirroring_Glyph of U+2273 GREATER-THAN OR EQUIVALENT TO, so the shaper replaces U+2272 with U+2273 in RTL text. However, this is just a best fit because, ideally, the tilde part of the glyph would be mirrored too.

According to the OpenType spec, this would only be true for characters in the OpenType Mirroring Pairs List, but HarfBuzz by default uses the full latest list from Unicode (harfbuzz/harfbuzz#492). That means that, for example, HarfBuzz mirrors uni2A85 to uni2A86, bypassing the intended uni2A85.aalt.

Character data

≲⪅
U+2272 LESS-THAN OR EQUIVALENT TO
U+2A85 LESS-THAN OR APPROXIMATE

Screenshot

Left-to-right:
≲⪅
Right-to-left in HarfBuzz:
⁧≲⪅⁩
Right-to-left in HarfBuzz modified to use the OMPL:
⁧≲⪅⁩

@marekjez86
Copy link

per MT fixed

@dscorbett
Copy link
Author

This issue should be reopened.

I see that you’ve added a new glyph, uni2272.mir, to the font. That has no effect and does not address this bug. The shaper replaces uni2272 with uni2273 because U+2272 appears in the OMPL. 'rtlm' is not applied and uni2272.mir is unused. To override the OMPL, use 'rtla' instead.

Another problem is that this attempted fix only applies to U+2272. That was just one example. There are plenty of other characters with best-fit mirrorings.

@marekjez86 marekjez86 reopened this May 18, 2019
@simoncozens simoncozens transferred this issue from notofonts/noto-fonts Jun 20, 2022
@simoncozens
Copy link
Contributor

'rtlm' is not applied and uni2272.mir is unused. To override the OMPL, use 'rtla' instead.

(I was told this was fixed in the latest version, but it's not.) I tried using rtla, but it makes no difference; Harfbuzz still does the mirroring itself. Indeed, it looks like the mirroring happens before we hit GSUB:

$ shape -V master_ttf/NotoSansMath-Regular.ttf -u 2272 --direction=rtl
trace: start table GSUB  buffer: [greaterorequivalent=0]

But I'm confused. I would then expect Harfbuzz to then do something in rtla, presumably to substitute it for greaterorequivalent.rtlm, but nothing happens:

trace: start lookup 6 feature 'rtla'    buffer: [greaterorequivalent=0]
trace: end lookup 6 feature 'rtla'      buffer: [greaterorequivalent=0]

(Maybe because the mirroring happens already?)

If that's the case, then I'm not sure this is something we can fix in the font.

@dscorbett
Copy link
Author

All you need to do is add a mapping in 'rtla' from uni2273 to uni2272.rtlm. Other mirroring pairs can be fixed similarly.

I tried using rtla, but it makes no difference; Harfbuzz still does the mirroring itself. Indeed, it looks like the mirroring happens before we hit GSUB

Exactly. 'rtla' doesn’t replace HarfBuzz’s default mirroring: it supplements it, by being applied in a later step.

I would then expect Harfbuzz to then do something in rtla, presumably to substitute it for greaterorequivalent.rtlm, but nothing happens

Nothing happens because this font’s 'rtla' lookup has no rule for uni2273.

@khaledhosny
Copy link
Contributor

I’m questioning many of the best fit and entries without encoded mirrors in BidiMirroring.txt. I’m checking Arabic math book and slashes/solidi/etc, or tildes are not mirrored, unlike other symbols. So I think the file needs to be checked against actual usage of these symbols, and feedback should be submitted to Unicode to revise this file.

khaledhosny added a commit to khaledhosny/noto-math that referenced this issue Apr 13, 2024
Make them consistent with the base glyphs, but I’ve my doubts about many
of them notofonts#7 (comment).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants