From 271142ab9c1b12cd06e2141803d9eb7a64389690 Mon Sep 17 00:00:00 2001 From: Bruno de Oliveira Abinader Date: Fri, 4 Jan 2019 16:08:19 -0400 Subject: [test] Added LocalGlyphRasterizer.ChinesePunctuation test --- .../fixtures/local_glyphs/chinese-punctuation.json | 195 +++++++++++++++++++++ .../local_glyphs/chinese_punctuation/expected.png | Bin 0 -> 25981 bytes test/text/local_glyph_rasterizer.test.cpp | 20 +++ 3 files changed, 215 insertions(+) create mode 100644 test/fixtures/local_glyphs/chinese-punctuation.json create mode 100644 test/fixtures/local_glyphs/chinese_punctuation/expected.png 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 new file mode 100644 index 0000000000..74bea29b80 Binary files /dev/null and b/test/fixtures/local_glyphs/chinese_punctuation/expected.png differ 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 fontFamily) + : frontend(size, pixelRatio, fileSource, threadPool, optional(), 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(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. -- cgit v1.2.1