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

Incorrect placement of bopomofo tone marks in vertical writing mode #532

Closed
kahsieh opened this issue Sep 4, 2017 · 16 comments
Closed

Incorrect placement of bopomofo tone marks in vertical writing mode #532

kahsieh opened this issue Sep 4, 2017 · 16 comments
Labels
Vertical Vertical text direction

Comments

@kahsieh
Copy link

kahsieh commented Sep 4, 2017

Neither Chrome nor Firefox correctly place bopomofo tone marks next to the annotations for the test case at https://bobbytung.github.io/BopomofoLayoutTest/case02/index.html, where the tone marks' positions are adjusted using vkrn.

Expected result:
image

Chrome:
image

Firefox:
image

Safari (gets the placement correct except there's extra space where the tone mark would be if its position were not adjusted):
image

Minimal testcase:
testcase.zip

See also:
https://bugzilla.mozilla.org/show_bug.cgi?id=1395774

behdad added a commit that referenced this issue Oct 3, 2017
This should affect mark attachment in vertical text.  I have no font to test,
but this sounds the right order.

Noticed while debugging #532
@jfkthame
Copy link
Collaborator

jfkthame commented Oct 3, 2017

The font uses mark attachment in the 'vkrn' feature to place the tone marks relative to the base glyphs. However, it looks to me like the GPOS attachment positions in the test font don't really make sense for the desired placement. We have anchors on the base glyphs such as

        <BaseRecord index="0">
          <BaseAnchor index="0" Format="1">
            <XCoordinate value="100"/>
            <YCoordinate value="-1500"/>
          </BaseAnchor>
        </BaseRecord>

where the y-coordinate suggests a mark placed well below the base character to which it is attached, and the x-coordinate shifts it just a bit to the right.

The desired result, OTOH, is for the mark to be raised up somewhat relative to the base, and shifted quite a long way to the right. And sure enough, if I modify the font to have base anchors that reflect this, e.g.:

        <BaseRecord index="0">
          <BaseAnchor index="0" Format="1">
            <XCoordinate value="800"/>
            <YCoordinate value="500"/>
          </BaseAnchor>
        </BaseRecord>

then the harfbuzz (hb-view) and Chrome results look a lot like the "expected" image. (Firefox currently has a bug in how it interprets the position offsets from harfbuzz, so it gets the horizontal offset wrong, but that's a separate issue for us to fix.)

Modifying the font in this way, then, will give the desired result in harfbuzz-based applications. Unfortunately, however, it breaks the result in Safari, which ends up with something similar to the "bad" Chrome result.

I think this means that Safari has a bug in how it applies mark attachment in vertical mode, such that it swaps vertical and horizontal offsets; this example font was developed by "trial and error" such that it works under Safari's misinterpretation of the attachments, but this results in bad rendering for harfbuzz-based apps. But we'll need to check this with Ned at Apple.

@behdad
Copy link
Member

behdad commented Oct 3, 2017

cc @nedley

@jfkthame
Copy link
Collaborator

jfkthame commented Oct 3, 2017

I also tried setting the BaseAnchor to (0, 0) on all the glyphs. The mark anchors are also at (0, 0). Hence, we'd expect to see the attached marks overlaying their base characters. And indeed, this is what happens in Chrome. But in Safari, the marks "attached" at (0, 0) appear to be about 1em below and to the right of their base characters. It looks like Safari is doing something quite weird with attachments in vertical mode.

@nedley
Copy link

nedley commented Oct 3, 2017

Have you checked Safari on High Sierra?

@jfkthame
Copy link
Collaborator

jfkthame commented Oct 3, 2017

No, I'm still on Sierra. If behavior has changed in HS, that could potentially be very good news.

@marklh9
Copy link

marklh9 commented Nov 18, 2017

Hi,
When running hb-shape with updated Bopomo GPOS font, I got the following result.
./hb-shape --direction t ~/Downloads/bopomo-new.otf ㄗㄠˇㄢ
[gid25=0@-500,-880+0,-1000|gid34=1@-500,-880+0,-1000|gid46=2@-500,-880+0|gid36=3@-500,-880+0,-1000]

The tone mark (gid46) has neither h advance nor v advance. Its y-offset does not look like it has been attached to an anchor. That makes the later character overlapped with the tone mark, as can be seen by hb-view. @jfkthame you mentioned that Firefox had the correct result except x-offset with updated font in #532 (comment) . How is that possible? Can you tell me how applications should render the tone mark in this case? Do I need information other than x and y offsets to render the tone mark correctly?

Sorry for these naive questions.
Best regards.

bopomo-gpos

@jfkthame
Copy link
Collaborator

I think you need to explicitly enable the 'vkrn' feature.

@jfkthame
Copy link
Collaborator

(and then add --margin 200 or something like that to the hb-view command, so the shifted tone mark is visible)

@jfkthame
Copy link
Collaborator

FWIW, here's a sample with a "hacked" version of the bopomofo font that renders as I'd expect in both Chrome and Firefox Beta (or Nightly) .... not in current release Firefox (57) due to a bug, but that's fixed for FF 58 and later.

bopomofo-test.zip

@marklh9
Copy link

marklh9 commented Nov 18, 2017

@jfkthame It also worked in LibreOffice with minor tweaks. Thank you!

@bobbytung
Copy link

Dr. Ken Lunde recommend to use OpenType GPOS 'vert' for long-term solution. So we updated test case here: https://bobbytung.github.io/BopomofoLayoutTest/

Works with Firefox 58 and Chrome 65.

Might work with LibreOffice as well. @marklh9

@marklh9
Copy link

marklh9 commented Mar 22, 2018

@bobbytung The new font works fine with LibreOffice 6.0. Users do not have to set vkrn feature manually now. Thank you!

@kahsieh
Copy link
Author

kahsieh commented Mar 22, 2018

@nedley It looks like both the old vkrn and new vert test cases work correctly in Chrome and Firefox but don't work correctly in Safari (11.0.3 / 13604.5.6) on High Sierra. Do you know what's going on with Safari's attachments?

@nedley
Copy link

nedley commented Mar 22, 2018

@kahsieh This isn’t the proper venue for discussing it. You can file a bug at bugreport.apple.com.

@kahsieh
Copy link
Author

kahsieh commented Mar 22, 2018

@nedley Thanks, will do

@behdad behdad added the Vertical Vertical text direction label Oct 15, 2018
@behdad
Copy link
Member

behdad commented Dec 5, 2019

Please reopen if anything is left to be done in HarfBuzz.

@behdad behdad closed this as completed Dec 5, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Vertical Vertical text direction
Projects
None yet
Development

No branches or pull requests

6 participants