From e6c15d0f6f285bc604c0d93381b9b1d3957cb5c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Minh=20Nguy=E1=BB=85n?= Date: Fri, 10 Feb 2017 16:57:48 -0800 Subject: Upright CJK characters in vertically-oriented labels (#7114) CJK characters and adjacent punctuation now remain upright in vertically oriented labels that have line placement. Fixes #1682. --- src/mbgl/layout/symbol_instance.cpp | 39 ++++++++++++++++++++++++++----------- 1 file changed, 28 insertions(+), 11 deletions(-) (limited to 'src/mbgl/layout/symbol_instance.cpp') diff --git a/src/mbgl/layout/symbol_instance.cpp b/src/mbgl/layout/symbol_instance.cpp index fafcc7c15d..2935fddd91 100644 --- a/src/mbgl/layout/symbol_instance.cpp +++ b/src/mbgl/layout/symbol_instance.cpp @@ -6,29 +6,46 @@ namespace mbgl { using namespace style; SymbolInstance::SymbolInstance(Anchor& anchor, const GeometryCoordinates& line, - const Shaping& shapedText, const PositionedIcon& shapedIcon, + const std::pair& shapedTextOrientations, const PositionedIcon& shapedIcon, const SymbolLayoutProperties::Evaluated& layout, const bool addToBuffers, const uint32_t index_, const float textBoxScale, const float textPadding, const SymbolPlacementType textPlacement, const float iconBoxScale, const float iconPadding, const SymbolPlacementType iconPlacement, const GlyphPositions& face, const IndexedSubfeature& indexedFeature) : point(anchor.point), index(index_), - hasText(shapedText), + hasText(shapedTextOrientations.first || shapedTextOrientations.second), hasIcon(shapedIcon), - // Create the quads used for rendering the glyphs. - glyphQuads(addToBuffers && shapedText ? - getGlyphQuads(anchor, shapedText, textBoxScale, line, layout, textPlacement, face) : - SymbolQuads()), - // Create the quad used for rendering the icon. iconQuads(addToBuffers && shapedIcon ? - getIconQuads(anchor, shapedIcon, line, layout, iconPlacement, shapedText) : + getIconQuads(anchor, shapedIcon, line, layout, iconPlacement, shapedTextOrientations.first) : SymbolQuads()), // Create the collision features that will be used to check whether this symbol instance can be placed - textCollisionFeature(line, anchor, shapedText, textBoxScale, textPadding, textPlacement, indexedFeature), - iconCollisionFeature(line, anchor, shapedIcon, iconBoxScale, iconPadding, iconPlacement, indexedFeature) - {} + textCollisionFeature(line, anchor, shapedTextOrientations.second ?: shapedTextOrientations.first, textBoxScale, textPadding, textPlacement, indexedFeature), + iconCollisionFeature(line, anchor, shapedIcon, iconBoxScale, iconPadding, iconPlacement, indexedFeature) { + + // Create the quads used for rendering the glyphs. + if (addToBuffers) { + if (shapedTextOrientations.first) { + auto quads = getGlyphQuads(anchor, shapedTextOrientations.first, textBoxScale, line, layout, textPlacement, face); + glyphQuads.insert(glyphQuads.end(), quads.begin(), quads.end()); + } + if (shapedTextOrientations.second) { + auto quads = getGlyphQuads(anchor, shapedTextOrientations.second, textBoxScale, line, layout, textPlacement, face); + glyphQuads.insert(glyphQuads.end(), quads.begin(), quads.end()); + } + } + + if (shapedTextOrientations.first && shapedTextOrientations.second) { + writingModes = WritingModeType::Horizontal | WritingModeType::Vertical; + } else if (shapedTextOrientations.first) { + writingModes = WritingModeType::Horizontal; + } else if (shapedTextOrientations.second) { + writingModes = WritingModeType::Vertical; + } else { + writingModes = WritingModeType::None; + } +} } // namespace mbgl -- cgit v1.2.1