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

Commit

Permalink
[core] minor fix
Browse files Browse the repository at this point in the history
  • Loading branch information
zmiao committed Oct 6, 2019
1 parent c7eae66 commit a884288
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/mbgl/text/glyph_pbf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
11 changes: 7 additions & 4 deletions src/mbgl/text/quads.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
3 changes: 3 additions & 0 deletions src/mbgl/text/shaping.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit a884288

Please sign in to comment.