From 6225a8cfb33ee54f9fa83134ff57fd9cf8253db8 Mon Sep 17 00:00:00 2001 From: Arindam Bose Date: Mon, 9 Dec 2019 14:05:01 -0800 Subject: [PATCH 1/2] Fix style=spec package importing module from outside style-spec directory --- src/data/bucket/symbol_bucket.js | 13 +++++++++++-- src/style-spec/expression/types/formatted.js | 11 ----------- 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/src/data/bucket/symbol_bucket.js b/src/data/bucket/symbol_bucket.js index 4c712968c00..9a2d16b0953 100644 --- a/src/data/bucket/symbol_bucket.js +++ b/src/data/bucket/symbol_bucket.js @@ -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'; @@ -131,6 +131,15 @@ function addDynamicAttributes(dynamicLayoutVertexArray: StructArray, p: Point, a dynamicLayoutVertexArray.emplaceBack(p.x, p.y, angle); } +function containsRTLText(text: Formatted): boolean { + for (const section of test.sections) { + if (stringContainsRTLText(section.text)) { + return true; + } + } + return false; +} + export class SymbolBuffers { layoutVertexArray: SymbolLayoutArray; layoutVertexBuffer: VertexBuffer; @@ -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 ( diff --git a/src/style-spec/expression/types/formatted.js b/src/style-spec/expression/types/formatted.js index 726242ea30f..378a0a2bd5d 100644 --- a/src/style-spec/expression/types/formatted.js +++ b/src/style-spec/expression/types/formatted.js @@ -1,6 +1,4 @@ // @flow - -import {stringContainsRTLText} from "../../../util/script_detection"; import type Color from '../../util/color'; import type ResolvedImage from '../types/resolved_image'; @@ -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 { const serialized: Array = ["format"]; for (const section of this.sections) { From 104034110510eaefcd0195eac11bbadf4e6f1f3c Mon Sep 17 00:00:00 2001 From: Arindam Bose Date: Mon, 9 Dec 2019 14:11:48 -0800 Subject: [PATCH 2/2] Fix typo --- src/data/bucket/symbol_bucket.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/data/bucket/symbol_bucket.js b/src/data/bucket/symbol_bucket.js index 9a2d16b0953..728d6ee1056 100644 --- a/src/data/bucket/symbol_bucket.js +++ b/src/data/bucket/symbol_bucket.js @@ -131,8 +131,8 @@ function addDynamicAttributes(dynamicLayoutVertexArray: StructArray, p: Point, a dynamicLayoutVertexArray.emplaceBack(p.x, p.y, angle); } -function containsRTLText(text: Formatted): boolean { - for (const section of test.sections) { +function containsRTLText(formattedText: Formatted): boolean { + for (const section of formattedText.sections) { if (stringContainsRTLText(section.text)) { return true; }