Skip to content

Add RTL (Right-to-Left) text plugin support #157

Description

@yharby

Summary

Add support for the MapLibre RTL text plugin to enable proper rendering of right-to-left languages like Arabic and Hebrew.

Problem

Currently, maps with Arabic or Hebrew labels render incorrectly - characters appear disconnected or in reverse order.

Solution

Bundle the @mapbox/mapbox-gl-rtl-text plugin with the package and automatically initialize it for all maps. This provides:

  • Offline support: Plugin is bundled, no CDN dependency
  • Zero configuration: Works automatically, no API changes needed
  • Lazy loading: Plugin only activates when RTL text is encountered

Implementation

  1. Bundle mapbox-gl-rtl-text.js in maplibre/srcjs/
  2. Patch pywidget.js to expose maplibregl globally
  3. Modify to_html() to inject RTL plugin as blob URL before map initialization
  4. Call maplibregl.setRTLTextPlugin(blobUrl, true) before pymaplibregl(data)

Scope

This PR adds RTL support for standalone HTML rendering (Map.to_html() and Map.save()).
Shiny/Jupyter widget paths may require changes to the maplibre-bindings repo.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions