diff options
author | zmiao <miao.zhao@mapbox.com> | 2019-10-01 11:58:12 +0300 |
---|---|---|
committer | zmiao <miao.zhao@mapbox.com> | 2019-10-06 19:48:09 +0300 |
commit | a8842884e27ff0567b5264ac3f96a5452d6bf69d (patch) | |
tree | 254858af1da5e9197050cba4d8551fc03def71cb | |
parent | c7eae66721a91f2a9a681e443741d7ff81c07f58 (diff) | |
download | qtlocation-mapboxgl-a8842884e27ff0567b5264ac3f96a5452d6bf69d.tar.gz |
[core] minor fix
-rw-r--r-- | src/mbgl/text/glyph_pbf.cpp | 2 | ||||
-rw-r--r-- | src/mbgl/text/quads.cpp | 11 | ||||
-rw-r--r-- | src/mbgl/text/shaping.cpp | 3 |
3 files changed, 11 insertions, 5 deletions
diff --git a/src/mbgl/text/glyph_pbf.cpp b/src/mbgl/text/glyph_pbf.cpp index eec9bd2f49..8ed48d08c1 100644 --- a/src/mbgl/text/glyph_pbf.cpp +++ b/src/mbgl/text/glyph_pbf.cpp @@ -8,7 +8,7 @@ std::tuple<std::vector<Glyph>, int32_t, int32_t> parseGlyphPBF(const GlyphRange& std::vector<Glyph> glyphs; glyphs.reserve(256); int32_t ascender{0}, descender{0}; - bool ascenderSet{false}, descenderSet{0}; + bool ascenderSet{false}, descenderSet{false}; protozero::pbf_reader glyphs_pbf(data); diff --git a/src/mbgl/text/quads.cpp b/src/mbgl/text/quads.cpp index c6bc3c2bdc..3e3beb29a3 100644 --- a/src/mbgl/text/quads.cpp +++ b/src/mbgl/text/quads.cpp @@ -125,11 +125,14 @@ SymbolQuads getGlyphQuads(const Shaping& shapedText, // necessary, but we also pull the glyph to the left along the x axis. // The y coordinate includes baseline yOffset, therefore, needs to be accounted // for when glyph is rotated and translated. - float yShift = Shaping::yOffset; - if (shapedText.hasBaseline && fontPositions->second.ascender.has_value() && - fontPositions->second.descender.has_value()) { - yShift = (-fontPositions->second.ascender.value() + fontPositions->second.descender.value()) / 2; + if (shapedText.hasBaseline) { + assert(fontPositions->second.ascender && fontPositions->second.descender); } + const float yShift = + (shapedText.hasBaseline + ? ((-(fontPositions->second.ascender.value()) + fontPositions->second.descender.value()) / 2.0 * + positionedGlyph.scale) + : Shaping::yOffset); const Point<float> center{-halfAdvance, halfAdvance - yShift}; const float verticalRotation = -M_PI_2; diff --git a/src/mbgl/text/shaping.cpp b/src/mbgl/text/shaping.cpp index a0c0c9d976..d4a30a3446 100644 --- a/src/mbgl/text/shaping.cpp +++ b/src/mbgl/text/shaping.cpp @@ -381,6 +381,9 @@ void shapeLines(Shaping& shaping, // with different offset shift. If font's baseline is not applicable, fall back to use a default baseline // offset, see shaping.yOffset. Since we're laying out at 24 points, we need also calculate how much it will // move when we scale up or down. + if (hasBaseline) { + assert(glyphs->second.ascender && glyphs->second.descender); + } const float baselineOffset = (hasBaseline ? ((-(glyphs->second.ascender.value()) + glyphs->second.descender.value()) / 2.0 * section.scale) |