# @mapbox/mapbox-gl-rtl-text

> Add support for RTL languages to mapbox-gl-js.

Latest version **1.0.0** (published 2026-10-05) · BSD-2-Clause license · 0 weekly downloads

## Install

```sh
npm install @mapbox/mapbox-gl-rtl-text
pnpm add @mapbox/mapbox-gl-rtl-text
yarn add @mapbox/mapbox-gl-rtl-text
bun add @mapbox/mapbox-gl-rtl-text
```

## Health

**Score 55/100 (C)** — status: active.

Positive: esm support; no vulnerabilities; has provenance; recently updated; high maintenance score.

Warnings: low downloads; no types.

Negative: declining downloads.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2026-10-05 |
| First published | 2017-02-01 |
| Weekly downloads | 0 |
| License | BSD-2-Clause |
| TypeScript types | none |
| Module format | ESM |
| Dependencies | 0 |
| Unpacked size | 54.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 65 |
| Author | Mapbox |
| Maintainers | mapbox-npm-01, mapbox-npm-02, mapbox-npm-07, mapbox-npm-03, mapbox-npm-04, mapbox-npm-09, mapbox-npm-05, mapbox-npm-06, mapbox-npm-08, mapbox-npm-advanced-actions, mapbox-npm-ci, mapbox-npm, mapbox-admin, mapbox-machine-user, mbx-npm-ci-staging, mbx-npm-ci-production, mbx-npm-01-production, mbx-npm-02-production, mbx-npm-03-production, mbx-npm-04-production, mbx-npm-05-production, mbx-npm-06-production, mbx-npm-07-production, mbx-npm-08-production, mbx-npm-09-production, mbx-npm-02-staging, mbx-npm-advanced-actions-staging, mbx-npm-advanced-actions-production |

## Links

- npm: https://www.npmjs.com/package/@mapbox/mapbox-gl-rtl-text
- Repository: https://github.com/mapbox/mapbox-gl-rtl-text
- Homepage: https://github.com/mapbox/mapbox-gl-rtl-text#readme
- Issues: https://github.com/mapbox/mapbox-gl-rtl-text/issues
- npm.io page: https://npm.io/package/@mapbox/mapbox-gl-rtl-text

## Recent versions

- 1.0.0 (latest) — 2026-10-05
- 0.4.0 — 2026-03-23
- 0.3.0 — 2024-07-24
- 0.2.3 — 2019-10-02
- 0.2.2 — 2019-07-11
- 0.2.1 — 2018-10-02
- 0.2.0 — 2018-07-27
- 0.1.2 — 2018-02-15
- 0.1.1 — 2017-06-16
- 0.1.0 — 2017-02-01

## README

# mapbox-gl-rtl-text

[![CI](https://github.com/mapbox/mapbox-gl-rtl-text/actions/workflows/ci.yml/badge.svg)](https://github.com/mapbox/mapbox-gl-rtl-text/actions/workflows/ci.yml)

A WebAssembly build of the parts of [ICU](https://icu.unicode.org/) that [Mapbox GL JS](https://github.com/mapbox/mapbox-gl-js) needs to render right-to-left text (Arabic and Hebrew): Arabic shaping and the [Unicode Bidirectional Algorithm](https://unicode.org/reports/tr9/). To show Arabic place names, combine it with a style that uses them or with [`mapbox-gl-language`](https://github.com/mapbox/mapbox-gl-language/).

## Usage

Input strings are in logical order (the order characters are typed), and output lines are in visual order (left to right, as displayed).

- `applyArabicShaping(input)` replaces Arabic characters with the presentation forms for their position in a word.
- `processBidirectionalText(input, lineBreakPoints)` splits the text into lines at the given break points (adding mandatory breaks such as `\n`) and returns the lines in visual order. Mirrored characters such as parentheses are flipped in right-to-left runs, and BiDi control characters are removed.
- `processStyledBidirectionalText(input, styleIndices, lineBreakPoints)` does the same, but takes a style index per input character and returns `[line, lineStyleIndices]` pairs with each index moved along with its character.

The main entry point loads `dist/mapbox-gl-rtl-text.wasm` with top-level await:

```js
import {applyArabicShaping, processBidirectionalText} from '@mapbox/mapbox-gl-rtl-text';

const lines = processBidirectionalText(applyArabicShaping('سلام'), []);
```

To choose where and when the wasm loads, use the factory:

```js
import {createRTL} from '@mapbox/mapbox-gl-rtl-text/rtl.js';

const {applyArabicShaping, processBidirectionalText} = await createRTL(fetch(wasmUrl));
```

Mapbox GL JS v3 loads the plugin with `setRTLTextPlugin` and needs the [v0.4.0 build](https://api.mapbox.com/mapbox-gl-js/plugins/mapbox-gl-rtl-text/v0.4.0/mapbox-gl-rtl-text.js).

## Development

Building the wasm requires [Emscripten](https://emscripten.org/docs/getting_started/downloads.html), the same version as CI (`EM_VERSION` in `.github/workflows/ci.yml`) for an identical build.

- `npm run build` (or `make`) builds `dist/mapbox-gl-rtl-text.wasm` from `src/*.c` and the ICU files they use, which it downloads into `build/` on first run.
- `npm test` builds if needed, then lints and runs `test.js`.
- `npm start` serves a demo at http://localhost:5173 (needs Python 3). Pass a Mapbox token with `?access_token=...` or enter it when asked.

## Deploying

```
npm test
npm version {patch|minor|major}
git push --follow-tags

mbx env
aws s3 cp --acl public-read --content-type application/wasm dist/mapbox-gl-rtl-text.wasm s3://mapbox-gl-js/rtl_text_v$(node -p "require('./package.json').version").wasm
mbx npm publish
```

---
_Source: https://npm.io/package/@mapbox/mapbox-gl-rtl-text · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
