-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use mapbox-rtl-text-plugin to support right-to-left scripts.
- Full support for Unicode Bidirectional Algorithm - Supports shaping Arabic script
- Loading branch information
Showing
20 changed files
with
183 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
--- | ||
layout: example | ||
category: example | ||
title: Add support for Right-to-Left scripts | ||
description: 'Use the <a target="_blank" href="https://github.com/mapbox/mapbox-gl-rtl-text">mapbox-gl-rtl-text</a> plugin to support scripts that use right-to-left layout (such as Arabic or Hebrew).' | ||
tags: | ||
- internationalization | ||
--- | ||
<div id='map'></div> | ||
|
||
<script> | ||
mapboxgl.setRTLTextPlugin('https://api.mapbox.com/mapbox-gl-js/plugins/mapbox-gl-rtl-text/v{{site.data.plugins.mapbox-gl-rtl-text.latest}}/mapbox-gl-rtl-text.js'); | ||
|
||
var map = new mapboxgl.Map({ | ||
container: 'map', | ||
style: 'mapbox://styles/mapbox/streets-v9', | ||
center: [44.3763, 33.2788], | ||
zoom: 11 | ||
}); | ||
|
||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
--- | ||
layout: default | ||
categories: plugin | ||
title: mapbox-gl-rtl-text | ||
prefix: mapbox-gl-rtl-text | ||
description: Enable rendering of right-to-left scripts (such as Arabic and Hebrew) | ||
tags: | ||
- isc | ||
code: https://github.com/mapbox/mapbox-gl-rtl-text | ||
license: BSD | ||
suffix: rtl-text | ||
css: false | ||
js: false | ||
--- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
'use strict'; | ||
|
||
const ajax = require('../util/ajax'); | ||
const window = require('../util/window'); | ||
|
||
const pluginAvailableCallbacks = []; | ||
let pluginRequested = false; | ||
let pluginBlobURL = null; | ||
|
||
module.exports.registerForPluginAvailability = function(callback) { | ||
if (pluginBlobURL) { | ||
callback(pluginBlobURL); | ||
} else { | ||
pluginAvailableCallbacks.push(callback); | ||
} | ||
}; | ||
|
||
module.exports.errorCallback = null; | ||
|
||
module.exports.setRTLTextPlugin = function(pluginURL, callback) { | ||
if (pluginRequested) { | ||
throw new Error('setRTLTextPlugin cannot be called multiple times.'); | ||
} | ||
pluginRequested = true; | ||
module.exports.errorCallback = callback; | ||
ajax.getArrayBuffer(pluginURL, (err, response) => { | ||
if (err) { | ||
callback(err); | ||
} else { | ||
pluginBlobURL = | ||
window.URL.createObjectURL(new window.Blob([response]), {type: "text/javascript"}); | ||
|
||
for (const pluginAvailableCallback of pluginAvailableCallbacks) { | ||
pluginAvailableCallback(pluginBlobURL); | ||
} | ||
} | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
plugins/src/mapbox-gl-rtl-text/v0.1.0/mapbox-gl-rtl-text.js
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters