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

Orient CJK glyphs vertically along vertically oriented lines #1246

Closed
1ec5 opened this issue Jun 3, 2015 · 7 comments · Fixed by #3438
Closed

Orient CJK glyphs vertically along vertically oriented lines #1246

1ec5 opened this issue Jun 3, 2015 · 7 comments · Fixed by #3438
Assignees

Comments

@1ec5
Copy link
Contributor

1ec5 commented Jun 3, 2015

For consistency with mapbox/mapbox-gl-native#1682, CJK labels running along north-south roads (or roads that go from top to bottom due to map rotation) should orient glyphs vertically.

/cc @ansis @nickidlugash @mikemorris

@lucaswoj lucaswoj changed the title Vertical CJK labels Orient CJK glyphs along north-south lines vertically Jul 28, 2016
@yhahn
Copy link
Member

yhahn commented Aug 3, 2016

Braindumping notes from discussion today:


Currently

  • Symbol bucket generates 2 orientations of quads (upright, flipped) for line labels

Proposal

  • Generate all 4 orientations of quads when condition X is met (???)
    • a label is in CJK ?
    • by some style spec property?
    • Ref:
      labelMinScale = getSegmentGlyphs(glyphInstances, anchor, centerX, line, anchor.segment, true);
      if (keepUpright) {
      labelMinScale = Math.min(labelMinScale, getSegmentGlyphs(glyphInstances, anchor, centerX, line, anchor.segment, false));
      }
  • Assumption: the vertical-label orientation of quads can use the same placement as normal labels with a quad-centric rotation (assumes CJK-ish characters)
  • Add logic to symbol_bucket to select right set of quads based on 4 quadrants of rotation
    • Ref:
      // drop upside down versions of glyphs
      var a = (symbol.anchorAngle + placementAngle + Math.PI) % (Math.PI * 2);
      if (keepUpright && alongLine && (a <= Math.PI / 2 || a > Math.PI * 3 / 2)) continue;

Probably: no shader changes, little affect on performance/data except other than symbol buffer transferred between workers.

Other questions

  • How to handle mixed characterset scenarios, examples from @nickidlugash:
    • 汉字 McDonald's
      • when rotated shows vertical quads for 汉字 and upright quads for McDonald's
    • 汉字A
      • when rotated shows vertical quads for 汉字A

@lucaswoj
Copy link
Contributor

lucaswoj commented Aug 3, 2016

Also, thanks to @mikemorris for pointing us towards a paper on robust vertical layout in unicode http://unicode.org/notes/tn22/RobustVerticalLayout.pdf

@1ec5
Copy link
Contributor Author

1ec5 commented Sep 26, 2016

Since I can’t find a better place for this little nugget of knowledge, this Wiktionary module contains character ranges for all the CJK writing systems. Of particular interest are Hang, Hani/Hans/Hant, Hira, Kana, Kore, Jpan, Yiii, and Mong (which is vertical but FYI isn’t broken like the others).

/cc @xrwang @nickidlugash

@1ec5 1ec5 changed the title Orient CJK glyphs along north-south lines vertically Orient CJK glyphs vertically Oct 18, 2016
@1ec5 1ec5 changed the title Orient CJK glyphs vertically Orient CJK glyphs vertically along vertically oriented lines Oct 22, 2016
@1ec5
Copy link
Contributor Author

1ec5 commented Oct 22, 2016

How to handle mixed characterset scenarios

On OpenStreetMap, and therefore in Mapbox Streets, mixed CJK/romanized labels are ubiquitous on roads in Hong Kong, Macao, and Shenzhen. For example, this way is tagged name=海底隧道 Cross-Harbour Tunnel. Unless we take care to rotate the Latin glyphs and advance them by the normal horizontal advance (rather than the glyph height), the label will become much longer when oriented vertically and stand a much higher chance of getting collided out.

@lucaswoj
Copy link
Contributor

Unless we take care to rotate the Latin glyphs and advance them by the normal horizontal advance (rather than the glyph height), the label will become much longer when oriented vertically and stand a much higher chance of getting collided out.

This should be fairly easy the way #3438 is now written. I'll move this into that PR's launch checklist.

@1ec5
Copy link
Contributor Author

1ec5 commented Oct 26, 2016

#3470 tracks vertical text layout for point-placed labels.

@1ec5
Copy link
Contributor Author

1ec5 commented Nov 1, 2016

Unless we take care to rotate the Latin glyphs and advance them by the normal horizontal advance (rather than the glyph height), the label will become much longer when oriented vertically and stand a much higher chance of getting collided out.

#3506

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment