Skip to content

Commit

Permalink
Remove stringContainsRTLText dependency from within style-spec. (#9088
Browse files Browse the repository at this point in the history
)
  • Loading branch information
Arindam Bose authored Dec 9, 2019
1 parent c82a0b8 commit 2e53e7c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 13 deletions.
13 changes: 11 additions & 2 deletions src/data/bucket/symbol_bucket.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import {ProgramConfigurationSet} from '../program_configuration';
import {TriangleIndexArray, LineIndexArray} from '../index_array_type';
import transformText from '../../symbol/transform_text';
import mergeLines from '../../symbol/mergelines';
import {allowsVerticalWritingMode} from '../../util/script_detection';
import {allowsVerticalWritingMode, stringContainsRTLText} from '../../util/script_detection';
import {WritingMode} from '../../symbol/shaping';
import loadGeometry from '../load_geometry';
import mvt from '@mapbox/vector-tile';
Expand Down Expand Up @@ -131,6 +131,15 @@ function addDynamicAttributes(dynamicLayoutVertexArray: StructArray, p: Point, a
dynamicLayoutVertexArray.emplaceBack(p.x, p.y, angle);
}

function containsRTLText(formattedText: Formatted): boolean {
for (const section of formattedText.sections) {
if (stringContainsRTLText(section.text)) {
return true;
}
}
return false;
}

export class SymbolBuffers {
layoutVertexArray: SymbolLayoutArray;
layoutVertexBuffer: VertexBuffer;
Expand Down Expand Up @@ -423,7 +432,7 @@ class SymbolBucket implements Bucket {
// conversion here.
const resolvedTokens = layer.getValueAndResolveTokens('text-field', feature, availableImages);
const formattedText = Formatted.factory(resolvedTokens);
if (formattedText.containsRTLText()) {
if (containsRTLText(formattedText)) {
this.hasRTLText = true;
}
if (
Expand Down
11 changes: 0 additions & 11 deletions src/style-spec/expression/types/formatted.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
// @flow

import {stringContainsRTLText} from "../../../util/script_detection";
import type Color from '../../util/color';
import type ResolvedImage from '../types/resolved_image';

Expand Down Expand Up @@ -50,15 +48,6 @@ export default class Formatted {
return this.sections.map(section => section.text).join('');
}

containsRTLText(): boolean {
for (const section of this.sections) {
if (stringContainsRTLText(section.text)) {
return true;
}
}
return false;
}

serialize(): Array<mixed> {
const serialized: Array<mixed> = ["format"];
for (const section of this.sections) {
Expand Down

0 comments on commit 2e53e7c

Please sign in to comment.