From eedb1a027f85489628b378638bcaae8e093a8227 Mon Sep 17 00:00:00 2001 From: Lucas Wojciechowski Date: Fri, 4 Nov 2016 11:55:31 -0700 Subject: [PATCH] Do not rotate non-CJK characters in vertical writing mode (fixes #3506) --- js/symbol/shaping.js | 2 +- js/util/script_detection.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/js/symbol/shaping.js b/js/symbol/shaping.js index 40d74961a0b..109a072bcab 100644 --- a/js/symbol/shaping.js +++ b/js/symbol/shaping.js @@ -54,7 +54,7 @@ function shapeText(text, glyphs, maxWidth, lineHeight, horizontalAlign, vertical if (!glyph && codePoint !== newLine) continue; - if (writingMode === WritingMode.horizontal) { + if (!scriptDetection.charAllowsVerticalWritingMode(text[i]) || writingMode === WritingMode.horizontal) { positionedGlyphs.push(new PositionedGlyph(codePoint, x, yOffset, glyph, 0)); if (glyph) x += glyph.advance + spacing; diff --git a/js/util/script_detection.js b/js/util/script_detection.js index cc760c387b6..b393017716d 100644 --- a/js/util/script_detection.js +++ b/js/util/script_detection.js @@ -12,7 +12,7 @@ module.exports.allowsIdeographicBreaking = function(chars) { module.exports.allowsVerticalWritingMode = function(chars) { for (const char of chars) { - if (charAllowsVerticalWritingMode(char.charCodeAt(0))) return true; + if (exports.charAllowsVerticalWritingMode(char.charCodeAt(0))) return true; } return false; }; @@ -45,7 +45,7 @@ module.exports.charAllowsIdeographicBreaking = function(char) { return false; }; -function charAllowsVerticalWritingMode(char) { +exports.charAllowsVerticalWritingMode = function(char) { // Return early for characters outside all ranges that allow the vertical // writing mode. if (char < 0x1100) return false;