mirror of
https://github.com/FoggedLens/iD.git
synced 2026-02-13 09:12:52 +00:00
Split into utilDisplayName / utilDisplayNameForPath
This is because utilDisplayName gets called a bunch of places and we only want to add the Arabic reversal code for textpath labels
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import * as d3 from 'd3';
|
||||
import _ from 'lodash';
|
||||
import rbush from 'rbush';
|
||||
|
||||
import {
|
||||
geoExtent,
|
||||
geoEuclideanDistance,
|
||||
@@ -8,9 +9,15 @@ import {
|
||||
geoPolygonIntersectsPolygon,
|
||||
geoPathLength
|
||||
} from '../geo/index';
|
||||
|
||||
import { osmEntity } from '../osm/index';
|
||||
import { utilDetect } from '../util/detect';
|
||||
import { utilDisplayName, utilEntitySelector } from '../util/index';
|
||||
|
||||
import {
|
||||
utilDisplayName,
|
||||
utilDisplayNameForPath,
|
||||
utilEntitySelector
|
||||
} from '../util/index';
|
||||
|
||||
|
||||
export function svgLabels(projection, context) {
|
||||
@@ -134,7 +141,7 @@ export function svgLabels(projection, context) {
|
||||
.data(entities, osmEntity.key)
|
||||
.attr('startOffset', '50%')
|
||||
.attr('xlink:href', function(d) { return '#labelpath-' + d.id; })
|
||||
.text(utilDisplayName);
|
||||
.text(utilDisplayNameForPath);
|
||||
}
|
||||
|
||||
|
||||
@@ -313,9 +320,11 @@ export function svgLabels(projection, context) {
|
||||
entity = labelable[k][i];
|
||||
geometry = entity.geometry(graph);
|
||||
|
||||
var name = utilDisplayName(entity),
|
||||
var getName = (geometry === 'line') ? utilDisplayNameForPath : utilDisplayName,
|
||||
name = getName(entity),
|
||||
width = name && textWidth(name, fontSize),
|
||||
p;
|
||||
|
||||
if (geometry === 'point') {
|
||||
p = getPointLabel(entity, width, fontSize, geometry);
|
||||
} else if (geometry === 'vertex' && !lowZoom) {
|
||||
|
||||
@@ -3,6 +3,7 @@ export { utilEntitySelector } from './util';
|
||||
export { utilEntityOrMemberSelector } from './util';
|
||||
export { utilGetAllNodes } from './util';
|
||||
export { utilDisplayName } from './util';
|
||||
export { utilDisplayNameForPath } from './util';
|
||||
export { utilDisplayType } from './util';
|
||||
export { utilStringQs } from './util';
|
||||
export { utilQsString } from './util';
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
// see https://github.com/openstreetmap/iD/pull/3707
|
||||
// https://gist.github.com/mapmeld/556b09ddec07a2044c76e1ef45f01c60
|
||||
|
||||
var chars = {
|
||||
// madda above alef
|
||||
1570: { initial: 'آ', isolated: 'ﺁ', medial: 'ﺁ', final: 'ﺂ' },
|
||||
|
||||
@@ -69,9 +69,16 @@ export function utilDisplayName(entity) {
|
||||
}
|
||||
}
|
||||
|
||||
return name;
|
||||
}
|
||||
|
||||
|
||||
export function utilDisplayNameForPath(entity) {
|
||||
var name = utilDisplayName(entity);
|
||||
var isFirefox = utilDetect().browser.toLowerCase().indexOf('firefox') > -1;
|
||||
var arabicRegex = /[\u0600-\u06FF]/g;
|
||||
if (!isFirefox && name && (entity.tags.highway || entity.tags.railway) && arabicRegex.test(name)) {
|
||||
|
||||
if (!isFirefox && name && arabicRegex.test(name)) {
|
||||
name = fixArabicScriptTextForSvg(name);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user