Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove stringContainsRTLText dependency from within style-spec. #9088

Merged
merged 2 commits into from
Dec 9, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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