Skip to content

Add RTL text plugin support for Arabic/Hebrew languages#5

Open
yharby wants to merge 1 commit into
eoda-dev:mainfrom
yharby:feature/rtl-text-plugin
Open

Add RTL text plugin support for Arabic/Hebrew languages#5
yharby wants to merge 1 commit into
eoda-dev:mainfrom
yharby:feature/rtl-text-plugin

Conversation

@yharby

@yharby yharby commented Feb 1, 2026

Copy link
Copy Markdown

Summary

Initialize maplibregl.setRTLTextPlugin() in both JavaScript bundles to enable proper rendering of right-to-left languages (Arabic, Hebrew, etc.).

Changes

Source Files

  • src/pymaplibregl.js:
    • Import maplibre-gl module
    • Expose maplibregl globally for compatibility
    • Initialize RTL plugin with lazy loading
  • src/ipywidget.js:
    • Initialize RTL plugin with lazy loading

Built Bundles

  • py-bindings/pymaplibre.js - Rebuilt with RTL support
  • py-bindings/pymaplibre.ipywidget.js - Rebuilt with RTL support

Features

  • Lazy loading: Plugin only loads when RTL text is encountered (minimal performance impact)
  • Safe initialization: Gracefully handles if plugin is already set
  • CDN-based: Uses unpkg.com for the plugin, no bundling needed

Code Added

// Initialize RTL text plugin for Arabic/Hebrew support
try {
  maplibregl.setRTLTextPlugin(
    'https://unpkg.com/@mapbox/mapbox-gl-rtl-text@0.3.0/dist/mapbox-gl-rtl-text.js',
    true  // lazy loading
  );
} catch (e) {
  if (!e.message?.includes('already been set')) {
    console.warn('RTL text plugin:', e.message);
  }
}

Related

Test Plan

  • Jupyter notebook - Arabic text renders correctly
  • Marimo notebook - Arabic text renders correctly
  • Shiny app - Arabic text renders correctly

Initialize maplibregl.setRTLTextPlugin() in both bundles:
- ipywidget.js (for Jupyter/Marimo via anywidget)
- pymaplibregl.js (for Shiny and standalone HTML)

Changes:
- Import maplibre-gl in pymaplibregl.js and expose globally
- Bundle RTL plugin source for OFFLINE usage (no CDN dependency)
- Create blob URL from bundled plugin source
- Safe initialization with error handling

The RTL plugin (~150KB) is now bundled directly, enabling:
- Offline usage without internet connection
- No external CDN dependencies
- Consistent behavior across all environments

Closes eoda-dev#4
Related: eoda-dev/py-maplibregl#157, eoda-dev/py-maplibregl#159
@yharby yharby force-pushed the feature/rtl-text-plugin branch from 085de3e to 29741df Compare February 1, 2026 20:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

1 participant