Skip to content
This repository was archived by the owner on Aug 8, 2023. It is now read-only.

Commit 43d132b

Browse files
committed
[core] minor fix
1 parent 383f4a7 commit 43d132b

File tree

3 files changed

+11
-5
lines changed

3 files changed

+11
-5
lines changed

src/mbgl/text/glyph_pbf.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ std::tuple<std::vector<Glyph>, int32_t, int32_t> parseGlyphPBF(const GlyphRange&
88
std::vector<Glyph> glyphs;
99
glyphs.reserve(256);
1010
int32_t ascender{0}, descender{0};
11-
bool ascenderSet{false}, descenderSet{0};
11+
bool ascenderSet{false}, descenderSet{false};
1212

1313
protozero::pbf_reader glyphs_pbf(data);
1414

src/mbgl/text/quads.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -125,11 +125,14 @@ SymbolQuads getGlyphQuads(const Shaping& shapedText,
125125
// necessary, but we also pull the glyph to the left along the x axis.
126126
// The y coordinate includes baseline yOffset, therefore, needs to be accounted
127127
// for when glyph is rotated and translated.
128-
float yShift = Shaping::yOffset;
129-
if (shapedText.hasBaseline && fontPositions->second.ascender.has_value() &&
130-
fontPositions->second.descender.has_value()) {
131-
yShift = (-fontPositions->second.ascender.value() + fontPositions->second.descender.value()) / 2;
128+
if (shapedText.hasBaseline) {
129+
assert(fontPositions->second.ascender && fontPositions->second.descender);
132130
}
131+
const float yShift =
132+
(shapedText.hasBaseline
133+
? ((-(fontPositions->second.ascender.value()) + fontPositions->second.descender.value()) / 2.0 *
134+
positionedGlyph.scale)
135+
: Shaping::yOffset);
133136
const Point<float> center{-halfAdvance, halfAdvance - yShift};
134137
const float verticalRotation = -M_PI_2;
135138

src/mbgl/text/shaping.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -381,6 +381,9 @@ void shapeLines(Shaping& shaping,
381381
// with different offset shift. If font's baseline is not applicable, fall back to use a default baseline
382382
// offset, see shaping.yOffset. Since we're laying out at 24 points, we need also calculate how much it will
383383
// move when we scale up or down.
384+
if (hasBaseline) {
385+
assert(glyphs->second.ascender && glyphs->second.descender);
386+
}
384387
const float baselineOffset =
385388
(hasBaseline
386389
? ((-(glyphs->second.ascender.value()) + glyphs->second.descender.value()) / 2.0 * section.scale)

0 commit comments

Comments
 (0)