summaryrefslogtreecommitdiff
path: root/src/mbgl/text/shaping.cpp
diff options
context:
space:
mode:
authorJohn Firebaugh <john.firebaugh@gmail.com>2017-04-06 09:20:07 -0700
committerJohn Firebaugh <john.firebaugh@gmail.com>2017-04-14 15:39:31 -0700
commita50d7a331bccd5ef35f08d8d0e24a0348510eb5a (patch)
treeac174cebebefa07a4f90263b57aaa47747bf1ef8 /src/mbgl/text/shaping.cpp
parent09a22715769c629ad433b405908b60e1b9fa969b (diff)
downloadqtlocation-mapboxgl-a50d7a331bccd5ef35f08d8d0e24a0348510eb5a.tar.gz
[core] Replace GlyphRangeSet in onGlyphsAvailable with optionals in the map
GlyphRangeSet isn't keyed by FontStack, so using it to indicate that a particular range was loaded could have produced false positives.
Diffstat (limited to 'src/mbgl/text/shaping.cpp')
-rw-r--r--src/mbgl/text/shaping.cpp16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/mbgl/text/shaping.cpp b/src/mbgl/text/shaping.cpp
index 5fae03b4c7..78aa142c61 100644
--- a/src/mbgl/text/shaping.cpp
+++ b/src/mbgl/text/shaping.cpp
@@ -56,8 +56,8 @@ void justifyLine(std::vector<PositionedGlyph>& positionedGlyphs,
PositionedGlyph& glyph = positionedGlyphs[end];
auto it = glyphs.find(glyph.glyph);
- if (it != glyphs.end()) {
- const uint32_t lastAdvance = it->second.metrics.advance;
+ if (it != glyphs.end() && it->second) {
+ const uint32_t lastAdvance = it->second->metrics.advance;
const float lineIndent = float(glyph.x + lastAdvance) * justify;
for (std::size_t j = start; j <= end; j++) {
@@ -74,8 +74,8 @@ float determineAverageLineWidth(const std::u16string& logicalInput,
for (char16_t chr : logicalInput) {
auto it = glyphs.find(chr);
- if (it != glyphs.end()) {
- totalWidth += it->second.metrics.advance + spacing;
+ if (it != glyphs.end() && it->second) {
+ totalWidth += it->second->metrics.advance + spacing;
}
}
@@ -185,8 +185,8 @@ std::set<std::size_t> determineLineBreaks(const std::u16string& logicalInput,
for (std::size_t i = 0; i < logicalInput.size(); i++) {
const char16_t codePoint = logicalInput[i];
auto it = glyphs.find(codePoint);
- if (it != glyphs.end() && !boost::algorithm::is_any_of(u" \t\n\v\f\r")(codePoint)) {
- currentX += it->second.metrics.advance + spacing;
+ if (it != glyphs.end() && it->second && !boost::algorithm::is_any_of(u" \t\n\v\f\r")(codePoint)) {
+ currentX += it->second->metrics.advance + spacing;
}
// Ideographic characters, spaces, and word-breaking punctuation that often appear without
@@ -234,11 +234,11 @@ void shapeLines(Shaping& shaping,
std::size_t lineStartIndex = shaping.positionedGlyphs.size();
for (char16_t chr : line) {
auto it = glyphs.find(chr);
- if (it == glyphs.end()) {
+ if (it == glyphs.end() || !it->second) {
continue;
}
- const Glyph& glyph = it->second;
+ const Glyph& glyph = *it->second;
if (writingMode == WritingModeType::Horizontal || !util::i18n::hasUprightVerticalOrientation(chr)) {
shaping.positionedGlyphs.emplace_back(chr, x, y, 0);