summaryrefslogtreecommitdiff
path: root/test/text
diff options
context:
space:
mode:
authorAlexander Shalamov <alexander.shalamov@mapbox.com>2019-11-13 18:04:47 +0200
committerAlexander Shalamov <alexander.shalamov@mapbox.com>2019-12-02 17:11:49 +0200
commit2bb2a40b6d13d4fe44e8879003a3e53416033a34 (patch)
tree19b184fc5faef7a2bfaba579f61c59e8e3e1db7b /test/text
parentf4f652063d9a9903d96bf6f32257a5e6fd6dbfe2 (diff)
downloadqtlocation-mapboxgl-2bb2a40b6d13d4fe44e8879003a3e53416033a34.tar.gz
[core] Shape images in labels and create image quads
Diffstat (limited to 'test/text')
-rw-r--r--test/text/cross_tile_symbol_index.test.cpp7
-rw-r--r--test/text/quads.test.cpp5
-rw-r--r--test/text/shaping.test.cpp24
3 files changed, 21 insertions, 15 deletions
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<float, 2> variableTextOffset{{0.0f, 0.0f}};
style::SymbolPlacementType placementType = style::SymbolPlacementType::Point;
- auto sharedData = std::make_shared<SymbolInstanceSharedData>(std::move(line),
- shaping, nullopt, nullopt, layout_, placementType,
- textOffset, positions, false);
+ auto sharedData = std::make_shared<SymbolInstanceSharedData>(
+ 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<Glyph>(makeMutable<Glyph>(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);