diff options
author | Bruno de Oliveira Abinader <bruno@mapbox.com> | 2019-01-04 16:08:19 -0400 |
---|---|---|
committer | Bruno de Oliveira Abinader <bruno@mapbox.com> | 2019-01-04 16:08:19 -0400 |
commit | 271142ab9c1b12cd06e2141803d9eb7a64389690 (patch) | |
tree | 04de5fe1625762bcf1c57a528b502c3a7d416663 | |
parent | f7ef1bcc8c851eaf793f1634e9f778cfc8003f17 (diff) | |
download | qtlocation-mapboxgl-upstream/qt-local-font-family.tar.gz |
[test] Added LocalGlyphRasterizer.ChinesePunctuation testupstream/qt-local-font-family
-rw-r--r-- | test/fixtures/local_glyphs/chinese-punctuation.json | 195 | ||||
-rw-r--r-- | test/fixtures/local_glyphs/chinese_punctuation/expected.png | bin | 0 -> 25981 bytes | |||
-rw-r--r-- | test/text/local_glyph_rasterizer.test.cpp | 20 |
3 files changed, 215 insertions, 0 deletions
diff --git a/test/fixtures/local_glyphs/chinese-punctuation.json b/test/fixtures/local_glyphs/chinese-punctuation.json new file mode 100644 index 0000000000..e3c7c57fcc --- /dev/null +++ b/test/fixtures/local_glyphs/chinese-punctuation.json @@ -0,0 +1,195 @@ +{ + "version": 8, + "zoom": 0, + "center": [0, 0], + "sources": { + "mapbox": { + "type": "geojson", + "data": { + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "properties": { + "name": "氣—到–身_什…戰.只。" + }, + "geometry": { + "type": "LineString", + "coordinates": [ + [ + -119, + 85 + ], + [ + -119, + 10 + ] + ] + } + }, + { + "type": "Feature", + "properties": { + "name": "(氣)到(身)(什)" + }, + "geometry": { + "type": "LineString", + "coordinates": [ + [ + -32.453124999999964, + 85 + ], + [ + -32.453124999999964, + 10 + ] + ] + } + }, + { + "type": "Feature", + "properties": { + "name": "“氣”到“身”“白”" + }, + "geometry": { + "type": "LineString", + "coordinates": [ + [ + 52.04687500000002, + 85 + ], + [ + 52.04687500000002, + 10 + ] + ] + } + }, + { + "type": "Feature", + "properties": { + "name": "—氣—到—a—a—" + }, + "geometry": { + "type": "LineString", + "coordinates": [ + [ + 128.703125, + 85 + ], + [ + 128.703125, + 10 + ] + ] + } + }, + { + "type": "Feature", + "properties": { + "name": "氣—到–身_什…戰.只。" + }, + "geometry": { + "type": "LineString", + "coordinates": [ + [ + -150, + -17 + ], + [ + -10, + -17 + ] + ] + } + }, + { + "type": "Feature", + "properties": { + "name": "(氣)到(身)(什)" + }, + "geometry": { + "type": "LineString", + "coordinates": [ + [ + -150, + -58 + ], + [ + -10, + -58 + ] + ] + } + }, + { + "type": "Feature", + "properties": { + "name": "“氣”到“身”“白”" + }, + "geometry": { + "type": "LineString", + "coordinates": [ + [ + 10, + -17 + ], + [ + 130, + -17 + ] + ] + } + }, + { + "type": "Feature", + "properties": { + "name": "—氣—到—a—a—" + }, + "geometry": { + "type": "LineString", + "coordinates": [ + [ + 10, + -58 + ], + [ + 130, + -58 + ] + ] + } + } + ] + } + } + }, + "glyphs": "local://glyphs/{fontstack}/{range}.pbf", + "layers": [ + { + "id": "background", + "type": "background", + "paint": { + "background-color": "white" + } + }, + { + "id": "lines-symbol", + "type": "symbol", + "source": "mapbox", + "layout": { + "text-field": "{name}", + "symbol-placement": "line", + "text-allow-overlap": true, + "text-font": [ "NotoCJK" ] + } + }, { + "id": "lines", + "type": "line", + "source": "mapbox", + "paint": { + "line-opacity": 0.25 + } + } + ] +} diff --git a/test/fixtures/local_glyphs/chinese_punctuation/expected.png b/test/fixtures/local_glyphs/chinese_punctuation/expected.png Binary files differnew file mode 100644 index 0000000000..74bea29b80 --- /dev/null +++ b/test/fixtures/local_glyphs/chinese_punctuation/expected.png diff --git a/test/text/local_glyph_rasterizer.test.cpp b/test/text/local_glyph_rasterizer.test.cpp index 0dfec1689a..3b99a4b25d 100644 --- a/test/text/local_glyph_rasterizer.test.cpp +++ b/test/text/local_glyph_rasterizer.test.cpp @@ -36,6 +36,11 @@ public: { } + LocalGlyphRasterizerTest(Size size, const optional<std::string> fontFamily) + : frontend(size, pixelRatio, fileSource, threadPool, optional<std::string>(), GLContextMode::Unique, fontFamily) + { + } + util::RunLoop loop; StubFileSource fileSource; ThreadPool threadPool { 4 }; @@ -74,6 +79,21 @@ TEST(LocalGlyphRasterizer, PingFang) { #endif // defined(__APPLE__) +#if defined(__APPLE__) +TEST(LocalGlyphRasterizer, ChinesePunctuation) { + LocalGlyphRasterizerTest test(Size(512, 512), std::string("PingFang")); + + test.fileSource.glyphsResponse = [&] (const Resource& resource) { + EXPECT_EQ(Resource::Kind::Glyphs, resource.kind); + Response response; + response.data = std::make_shared<std::string>(util::read_file("test/fixtures/resources/glyphs.pbf")); + return response; + }; + test.map.getStyle().loadJSON(util::read_file("test/fixtures/local_glyphs/chinese-punctuation.json")); + test.checkRendering("chinese_punctuation"); +} +#endif // defined(__APPLE__) + TEST(LocalGlyphRasterizer, NoLocal) { // Expectation: without any local fonts set, and without any CJK glyphs provided, // the output should just contain basic latin characters. |