Support right-to-left scripts without requiring plugin
@ChrisLoer is already working on this.
Since Jan 18, 2017.
- Dominant language
- TypeScript
- Stars
- 12.4k
- Forks
- 2.4k
- PR merge metrics
- No merged PRs in 30d
Description
We use an Emscripten port of the ICU library to provide support for bidirectional text as well as shaping for Arabic text (https://github.com/mapbox/mapbox-gl-js/issues/3708). However, the Emscripten port ended up being so large that it would nearly double the size of the `mapbox-gl.js` bundle (see discussion in PR https://github.com/mapbox/mapbox-gl-js/pull/3758). Because right-to-left support wasn't critical to all of customers, we decided to split the RTL support out into a separate [RTL text plugin](https://github.com/mapbox/mapbox-gl-rtl-text).
This is a sub-optimal solution: we would prefer for RTL scripts to work out of the box. Possible solutions to this problem include:
- Accepting the bundle size increase and pulling the Emscriptified code into the main bundle
- Making and maintaining a (hopefully more lightweight) native JS implementation of both the bidirectional algorithm and arabic shaping. A [recent PR to the iD editor](https://github.com/openstreetmap/iD/pull/3707/) points in the direction we could go, but would require significant expansion to implement all of the ICU functionality. We might be able to identify some subset of current ICU functionality that can be dropped.
- Finding further ways to decrease size of the transpiled ICU code, perhaps by making modifications to Emscripten
The fix for this issue will be tightly coupled to whatever decisions we make as we implement further support for complex text rendering (indic scripts, ligatures, kerning, etc.). The current plan on `mapbox-gl-native` is to use Harfbuzz for client-side text shaping (https://github.com/mapbox/mapbox-gl-native/issues/7528). Directly porting those changes would require us to either double down on the Emscripten strategy or greatly expand the scope of any direct C++->JS port.
cc @1ec5 @lucaswoj @pveugen
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.