From 2bb2a40b6d13d4fe44e8879003a3e53416033a34 Mon Sep 17 00:00:00 2001 From: Alexander Shalamov Date: Wed, 13 Nov 2019 18:04:47 +0200 Subject: [core] Shape images in labels and create image quads --- test/text/cross_tile_symbol_index.test.cpp | 7 +++---- test/text/quads.test.cpp | 5 ++++- test/text/shaping.test.cpp | 24 ++++++++++++++---------- 3 files changed, 21 insertions(+), 15 deletions(-) (limited to 'test') diff --git a/test/text/cross_tile_symbol_index.test.cpp b/test/text/cross_tile_symbol_index.test.cpp index 4ff84063f9..a02055e70f 100644 --- a/test/text/cross_tile_symbol_index.test.cpp +++ b/test/text/cross_tile_symbol_index.test.cpp @@ -6,7 +6,7 @@ using namespace mbgl; SymbolInstance makeSymbolInstance(float x, float y, std::u16string key) { GeometryCoordinates line; - GlyphPositions positions; + ImageMap imageMap; const ShapedTextOrientations shaping{}; style::SymbolLayoutProperties::Evaluated layout_; IndexedSubfeature subfeature(0, "", "", 0); @@ -16,9 +16,8 @@ SymbolInstance makeSymbolInstance(float x, float y, std::u16string key) { std::array variableTextOffset{{0.0f, 0.0f}}; style::SymbolPlacementType placementType = style::SymbolPlacementType::Point; - auto sharedData = std::make_shared(std::move(line), - shaping, nullopt, nullopt, layout_, placementType, - textOffset, positions, false); + auto sharedData = std::make_shared( + std::move(line), shaping, nullopt, nullopt, layout_, placementType, textOffset, imageMap, false); return SymbolInstance(anchor, std::move(sharedData), shaping, nullopt, nullopt, 0, 0, placementType, textOffset, 0, 0, iconOffset, subfeature, 0, 0, key, 0.0f, 0.0f, 0.0f, variableTextOffset, false); } diff --git a/test/text/quads.test.cpp b/test/text/quads.test.cpp index b04617a40b..4d7f254efa 100644 --- a/test/text/quads.test.cpp +++ b/test/text/quads.test.cpp @@ -45,7 +45,10 @@ TEST(getIconQuads, style) { shapedText.bottom = 30.0f; shapedText.left = -60.0f; shapedText.right = 20.0f; - shapedText.positionedGlyphs.emplace_back(PositionedGlyph(32, 0.0f, 0.0f, false, 0, 1.0)); + // shapedText.positionedGlyphs.emplace_back(PositionedGlyph(32, 0.0f, 0.0f, false, 0, 1.0)); + shapedText.positionedLines.emplace_back(); + shapedText.positionedLines.back().positionedGlyphs.emplace_back( + PositionedGlyph(32, 0.0f, 0.0f, false, 0, 1.0, /*texRect*/ {}, /*metrics*/ {}, /*imageID*/ nullopt)); // none { diff --git a/test/text/shaping.test.cpp b/test/text/shaping.test.cpp index c4d2ef7fc4..53f8505393 100644 --- a/test/text/shaping.test.cpp +++ b/test/text/shaping.test.cpp @@ -10,13 +10,16 @@ using namespace mbgl; using namespace util; TEST(Shaping, ZWSP) { + GlyphPosition glyphPosition; + glyphPosition.metrics.width = 18; + glyphPosition.metrics.height = 18; + glyphPosition.metrics.left = 2; + glyphPosition.metrics.top = -8; + glyphPosition.metrics.advance = 21; + Glyph glyph; glyph.id = u'中'; - glyph.metrics.width = 18; - glyph.metrics.height = 18; - glyph.metrics.left = 2; - glyph.metrics.top = -8; - glyph.metrics.advance = 21; + glyph.metrics = glyphPosition.metrics; BiDi bidi; auto immutableGlyph = Immutable(makeMutable(std::move(glyph))); @@ -25,7 +28,7 @@ TEST(Shaping, ZWSP) { GlyphMap glyphs = { { FontStackHasher()(fontStack), {{u'中', std::move(immutableGlyph)}} } }; - + GlyphPositions glyphPositions = {{FontStackHasher()(fontStack), {{u'中', std::move(glyphPosition)}}}}; ImagePositions imagePositions; const auto testGetShaping = [&](const TaggedString& string, unsigned maxWidthInChars) { @@ -39,6 +42,7 @@ TEST(Shaping, ZWSP) { WritingModeType::Horizontal, bidi, glyphs, + glyphPositions, imagePositions, 16.0, /*allowVerticalPlacement*/ false); @@ -51,7 +55,7 @@ TEST(Shaping, ZWSP) { { TaggedString string(u"中中\u200b中中\u200b中中\u200b中中中中中中\u200b中中", sectionOptions); auto shaping = testGetShaping(string, 5); - ASSERT_EQ(shaping.lineCount, 3); + ASSERT_EQ(shaping.positionedLines.size(), 3); ASSERT_EQ(shaping.top, -36); ASSERT_EQ(shaping.bottom, 36); ASSERT_EQ(shaping.left, -63); @@ -65,7 +69,7 @@ TEST(Shaping, ZWSP) { { TaggedString string(u"中中\u200b中", sectionOptions); auto shaping = testGetShaping(string, 1); - ASSERT_EQ(shaping.lineCount, 2); + ASSERT_EQ(shaping.positionedLines.size(), 2); ASSERT_EQ(shaping.top, -24); ASSERT_EQ(shaping.bottom, 24); ASSERT_EQ(shaping.left, -21); @@ -78,7 +82,7 @@ TEST(Shaping, ZWSP) { { TaggedString string(u"中中\u200b", sectionOptions); auto shaping = testGetShaping(string, 2); - ASSERT_EQ(shaping.lineCount, 1); + ASSERT_EQ(shaping.positionedLines.size(), 1); ASSERT_EQ(shaping.top, -12); ASSERT_EQ(shaping.bottom, 12); ASSERT_EQ(shaping.left, -21); @@ -90,7 +94,7 @@ TEST(Shaping, ZWSP) { { TaggedString string(u"\u200b\u200b\u200b\u200b\u200b", sectionOptions); auto shaping = testGetShaping(string, 1); - ASSERT_EQ(shaping.lineCount, 5); + ASSERT_EQ(shaping.positionedLines.size(), 5); ASSERT_EQ(shaping.top, -60); ASSERT_EQ(shaping.bottom, 60); ASSERT_EQ(shaping.left, 0); -- cgit v1.2.1