Skip to content
This repository was archived by the owner on Aug 8, 2023. It is now read-only.
This repository was archived by the owner on Aug 8, 2023. It is now read-only.

Full "complex text" support: indic scripts, ligatures, kerning, etc. #7774

Open

Description

@ChrisLoer

GL Native now uses the ICU library to support right-to-left (and bidirectional) text, along with text shaping for languages that use the Arabic script.

  • Bidirectional/right-to-left text support 🙌
  • Arabic script text shaping 🙌

There are a number of further features that fall under the category of "complex text" that remain to be addressed:

  • Shaping for Brahmic/Indic scripts
  • Shaping with basic OpenType support for ligatures and kerning in Latin fonts
  • Shaping with support for more advanced typographic features (possibly using Graphite or Apple Advanced Typography)
  • Language aware line-breaking algorithms. This is an improvement for languages like Chinese or Japanese, where current line breaking is sub-optimal in that it will easily break inside of compound words. Language aware line-breaking is much more important for languages like Thai or Lao where finding acceptable breaking points requires the use of a dictionary.

Harfbuzz for basic shaping

The first two items can be implemented using Harfbuzz. However, a number of changes to our font rendering architecture will be necessary:

  • https://github.com/mapbox/node-fontnik will need a new interface that serves glyphs based on a font-specific glyph ID instead of a generic Unicode codepoint (because complex shaping breaks the 1:1 relationship between codepoint and glyph we're currently relying on).
  • We will need to send font "shaping tables" down to the client for use by Harfbuzz
  • After performing shaping, the client will have to request appropriate glyphs from the server. If the glyphs are unavailable, the client will have to implement the fontstack fallback behavior.

Harfbuzz support is tracked as #7528

Advanced typography

Supporting some advanced typography features will require passing through to system libraries (such as Apple's Core Text) or linking in libraries like Graphite. Using advanced typography features would open up some interesting (and possibly unique) options for creating beautiful maps, for instance by using calligraphic typefaces such as a Nastaliq script or Zapfino. Harfbuzz has support for passing shaping calls through to Core Text, so enabling some of these features on iOS might not be too difficult, but any support we added would likely remain highly platform-dependent.

Many advanced typographical features require explicit typographical instructions in addition to the basic Unicode input. Supporting these features would require changes to the style spec and Mapbox Studio to enable designers to take advantage of them. They are beyond the scope of the changes we are currently planning.

Line breaking

Line-breaking can be implemented using ICU, but a standard implementation would require client-side line breaking dictionaries which are likely to be prohibitively large. The proposed implementation is tracked as #7362.

Mapbox Classic parity

Mapbox Classic supports basic shaping using Harfbuzz via Mapnik, but I don't believe it has support for language-aware line breaking or advanced typographical features.

Resources

mapbox/mapbox-gl-js#4009 is a paired ticket that tracks making these changes in GL-JS.

@1ec5 @lucaswoj @pveugen

Activity

  1. added
    Google Maps parity
    MapKit parity
    on Jan 18, 2017
  2. Kashian commented on Jan 18, 2017

    @Kashian

    Thank you for this great en-devour. Bravo. ..This is long waited news... Could you please mention, when would it be ready for public to use? when is the publish date? Can you post some screenshots of final rendering in Arabic lang? I am more interested in Persian Language which is similar to Arabic. RTL and almost similar alphabets.

  3. ChrisLoer commented on Jan 18, 2017

    @ChrisLoer
    ContributorAuthor

    @Kashian happy to oblige with a screenshot from Iran:

    before-after-mashhad

    Planned availability of Arabic/Bidirectional support:

    • As a plugin for gl-js in v0.32.1 (released Jan 26 2017)
    • In iOS SDK 3.5.0 (no firm date, but should be early 2017)
    • In Android SDK 5.0.0 (no firm date, but should be early 2017)

    The changes are not yet available in the Mapbox GL Qt Submodule (#7777).

    If you’re interested in trying out this functionality ahead of time on a mobile or desktop platform, check out our instructions for building the SDKs yourself:

    https://github.com/mapbox/mapbox-gl-native/tree/master/platform/android#contributing-to-the-sdk
    https://github.com/mapbox/mapbox-gl-native/blob/master/platform/ios/INSTALL.md
    https://github.com/mapbox/mapbox-gl-native/blob/master/platform/macos/INSTALL.md

    For trying out the functionality in gl-js, see mapbox/mapbox-gl-js#3758 (comment)

  4. 1ec5 commented on Jan 19, 2017

    @1ec5
    Contributor

    Note that either Harfbuzz and Core Text would get us support for Unicode supplementary planes (mapbox/mapbox-gl-js#4001) almost for free. (Support for full-color emoji would likely require significant work beyond the scope of this ticket.)

  5. khaledhosny commented on Jan 21, 2017

    @khaledhosny

    HarfBuzz do support advanced typography through its support for OpenType. Apple Advanced Typography (AAT) is an alternative technology to OpenType that is only supported by Apple, and thus not widely used outside of Apple own fonts. HarfBuzz actually can support AAT on Apple platforms by using Core Text API, so using HarfBuzz should give you OpenType support on all platforms and additionally AAT support on Apple ones.

  6. ChrisLoer commented on Jan 25, 2017

    @ChrisLoer
    ContributorAuthor

    @khaledhosny You know way more than I do about HarfBuzz and text shaping, so please forgive my imprecise description of "advanced typography". I haven't yet worked on the problem enough to know how to describe it properly! I'm using "advanced typography" as kind of a placeholder term for "nice to have" functionality like support for AAT. Some things HarfBuzz supports out of the box still might not get picked up in our initial implementation since we're going to try to work with a subset of font tables (I'm thinking of the MATH table as an example: something relatively straightforward to support with HarfBuzz but still something that we might not support in a first pass).

  7. khaledhosny commented on Jan 25, 2017

    @khaledhosny

    I just wanted to make sure things are clear :)

    The biggest OpenType tables (after glyf and CFF ) are usually GPOS an GSUB, I don’t think there will be that much gain dropping most of the other tables. AAT tables are very unlikely to be seen in the wild (unless one is dealing with Apple system fonts), so I’d not bother with them. Graphite are unlikely to be seen either, but when a font have them they are usually required, so I’d keep them unless Graphite support in HarfBuzz is not enabled. MATH is actually one of the tables that are good to go, math support in HarfBuzz is low level building blocks that are only usable by dedicated math layout engine, HarfBuzz itself does not do any math layout. Just my 2 Egyptian piastres.

  8. added
    Core
    on May 30, 2017
  9. 1ec5 commented on Feb 3, 2018

    @1ec5
    Contributor

    @ChrisLoer and I paired on the coretext-hack branch to perform complex text shaping using system fonts on iOS and macOS:

    before after

    before after

    Compare the before and after with the system-rendered text in the popover.

  10. behdad commented on Feb 4, 2018

    @behdad

    HarfBuzz should do that as well, you don't need separate CoreText backend.

  11. 1ec5 commented on Feb 4, 2018

    @1ec5
    Contributor

    Yes, we’re also exploring HarfBuzz + FreeType versus TinySDF + Core Text: #7862 (comment) #7528.

  12. tallytalwar commented on Feb 25, 2018

    @tallytalwar

    As @behdad mentioned in #7774 (comment), we are also using harfbuzz coretext context here.

  13. nafis042 commented on Mar 18, 2018

    @nafis042

    @1ec5 I tried to implement this on my app. I cloned coretext hack branch. Now I have a tile server running. Now how to tell to use system font? I have style.json file. what should be the font name written in style.json?

  14. ChrisLoer commented on Mar 19, 2018

    @ChrisLoer
    ContributorAuthor

    @nafis042 Although I'm excited you're playing around with it, unfortunately we can't really support the "coretext hack" branch -- it was a proof-of-concept, but there are many things on that branch that are simply broken. It would not be appropriate for any production app. For what it's worth, the demo is meant to work with the macosapp build target (from xcode with make xproj), and shouldn't require special configuration beyond that.

  15. mdakram commented on May 10, 2018

    @mdakram

    any timeline for indic language support?

  16. ChrisLoer commented on May 10, 2018

    @ChrisLoer
    ContributorAuthor

    any timeline for indic language support?

    Unfortunately, no. It's still on our backlog, but no specific plans.

    If you have a cool project that's blocked by the lack of Indic language support, it'd be great to hear a quick description. Although it's clearly functionality we want to support, we don't have a library of concrete examples of what kinds of maps/apps this would unlock.

  17. hakimelek commented on Oct 21, 2018

    @hakimelek

    Any updates on this? I still see the issue happening:
    image

  18. ChrisLoer commented on Oct 22, 2018

    @ChrisLoer
    ContributorAuthor

    @hakimelek Is that screenshot taken from Mapbox GL JS? If so you need to enable the RTL text plugin, example is here: https://www.mapbox.com/mapbox-gl-js/example/mapbox-gl-rtl-text/

  19. hakimelek commented on Oct 22, 2018

    @hakimelek

    @ChrisLoer Thanks! I will give a shot. I am using react-mapbox-gl but it seems like it's easy to support RTL in there with the plugin.

  20. toton6868 commented on Feb 3, 2019

    @toton6868
  21. added
    archived
    on Aug 3, 2019
  22. stale commented on Aug 3, 2019

    @stale

    This issue has been automatically detected as stale because it has not had recent activity and will be archived. Thank you for your contributions.

  23. reopened this on Sep 19, 2019
  24. removed
    archived
    on Sep 19, 2019
  25. toton6868 commented on Sep 19, 2019

    @toton6868

    @1ec5 Hopefully some good news is coming from mapbox regarding complex indic language visualization

  26. dyaacov commented on Sep 25, 2019

    @dyaacov

    Hi Guys,
    While I was able to use the plugin for RTL, I still unable to see hebrew for street/city names.
    like this one for example:
    https://www.madlan.co.il/local/תל%20אביב%20יפו/FOR_SALE?source=source_search

    appriciate your tips
    DY

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    CoreGoogle Maps parityMapKit paritytext rendering

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions