diff options
author | zmiao <zmiao.jamie@gmail.com> | 2019-09-19 14:14:54 +0300 |
---|---|---|
committer | zmiao <miao.zhao@mapbox.com> | 2019-10-06 19:48:08 +0300 |
commit | f669a7d26bcd90959204a4d990d52aaccacad917 (patch) | |
tree | dbe4a34aacd69669aedc480cb332a6d43f185b71 | |
parent | a05789f1b8f8e6466827ecef5f46c1c0a75d6aa6 (diff) | |
download | qtlocation-mapboxgl-f669a7d26bcd90959204a4d990d52aaccacad917.tar.gz |
[core] Fix clang-format error
-rw-r--r-- | src/mbgl/text/glyph_pbf.cpp | 115 | ||||
-rw-r--r-- | src/mbgl/text/shaping.cpp | 9 |
2 files changed, 60 insertions, 64 deletions
diff --git a/src/mbgl/text/glyph_pbf.cpp b/src/mbgl/text/glyph_pbf.cpp index d7b176b042..b4abfdeb39 100644 --- a/src/mbgl/text/glyph_pbf.cpp +++ b/src/mbgl/text/glyph_pbf.cpp @@ -21,36 +21,36 @@ std::vector<Glyph> parseGlyphPBF(const GlyphRange& glyphRange, const std::string while (glyph_pbf.next()) { switch (glyph_pbf.tag()) { - case 1: // id - glyph.id = glyph_pbf.get_uint32(); - hasID = true; - break; - case 2: // bitmap - glyphData = glyph_pbf.get_view(); - break; - case 3: // width - glyph.metrics.width = glyph_pbf.get_uint32(); - hasWidth = true; - break; - case 4: // height - glyph.metrics.height = glyph_pbf.get_uint32(); - hasHeight = true; - break; - case 5: // left - glyph.metrics.left = glyph_pbf.get_sint32(); - hasLeft = true; - break; - case 6: // top - glyph.metrics.top = glyph_pbf.get_sint32(); - hasTop = true; - break; - case 7: // advance - glyph.metrics.advance = glyph_pbf.get_uint32(); - hasAdvance = true; - break; - default: - glyph_pbf.skip(); - break; + case 1: // id + glyph.id = glyph_pbf.get_uint32(); + hasID = true; + break; + case 2: // bitmap + glyphData = glyph_pbf.get_view(); + break; + case 3: // width + glyph.metrics.width = glyph_pbf.get_uint32(); + hasWidth = true; + break; + case 4: // height + glyph.metrics.height = glyph_pbf.get_uint32(); + hasHeight = true; + break; + case 5: // left + glyph.metrics.left = glyph_pbf.get_sint32(); + hasLeft = true; + break; + case 6: // top + glyph.metrics.top = glyph_pbf.get_sint32(); + hasTop = true; + break; + case 7: // advance + glyph.metrics.advance = glyph_pbf.get_uint32(); + hasAdvance = true; + break; + default: + glyph_pbf.skip(); + break; } } @@ -58,54 +58,51 @@ std::vector<Glyph> parseGlyphPBF(const GlyphRange& glyphRange, const std::string // needs to satisfy a few metrics conditions that ensure that the glyph isn't bogus. // All other glyphs are malformed. We're also discarding all glyphs that are outside // the expected glyph range. - if (!hasID || !hasWidth || !hasHeight || !hasLeft || !hasTop || !hasAdvance || - glyph.metrics.width >= 256 || glyph.metrics.height >= 256 || - glyph.metrics.left < -128 || glyph.metrics.left >= 128 || - glyph.metrics.top < -128 || glyph.metrics.top >= 128 || - glyph.metrics.advance >= 256 || glyph.id < glyphRange.first || - glyph.id > glyphRange.second) { + if (!hasID || !hasWidth || !hasHeight || !hasLeft || !hasTop || !hasAdvance || glyph.metrics.width >= 256 || + glyph.metrics.height >= 256 || glyph.metrics.left < -128 || glyph.metrics.left >= 128 || + glyph.metrics.top < -128 || glyph.metrics.top >= 128 || glyph.metrics.advance >= 256 || + glyph.id < glyphRange.first || glyph.id > glyphRange.second) { return; } // If the area of width/height is non-zero, we need to adjust the expected size // with the implicit border size, otherwise we expect there to be no bitmap at all. if (glyph.metrics.width && glyph.metrics.height) { - const Size size{ glyph.metrics.width + 2 * Glyph::borderSize, - glyph.metrics.height + 2 * Glyph::borderSize }; + const Size size{glyph.metrics.width + 2 * Glyph::borderSize, + glyph.metrics.height + 2 * Glyph::borderSize}; if (size.area() != glyphData.size()) { return; } - glyph.bitmap = AlphaImage(size, reinterpret_cast<const uint8_t*>(glyphData.data()), - glyphData.size()); + glyph.bitmap = AlphaImage(size, reinterpret_cast<const uint8_t*>(glyphData.data()), glyphData.size()); } result.push_back(std::move(glyph)); }; - double ascender{ 0.0 }, descender{ 0.0 }; - uint16_t count{ 0 }; + double ascender{0.0}, descender{0.0}; + uint16_t count{0}; auto fontstack_pbf = glyphs_pbf.get_message(); while (fontstack_pbf.next()) { switch (fontstack_pbf.tag()) { - case 3: { - readGlyphMetrics(fontstack_pbf); - ++count; - break; - } - case 4: { - ascender = fontstack_pbf.get_double(); - break; - } - case 5: { - descender = fontstack_pbf.get_double(); - break; - } - default: { - fontstack_pbf.skip(); - break; - } + case 3: { + readGlyphMetrics(fontstack_pbf); + ++count; + break; + } + case 4: { + ascender = fontstack_pbf.get_double(); + break; + } + case 5: { + descender = fontstack_pbf.get_double(); + break; + } + default: { + fontstack_pbf.skip(); + break; + } } } if (ascender != 0.0 || descender != 0.0) { diff --git a/src/mbgl/text/shaping.cpp b/src/mbgl/text/shaping.cpp index d62401c97e..81639adefd 100644 --- a/src/mbgl/text/shaping.cpp +++ b/src/mbgl/text/shaping.cpp @@ -365,8 +365,8 @@ void shapeLines(Shaping& shaping, // from the horizontal baseline to the highest ‘character’ coordinate in a font face. // Since we're laying out at 24 points, we need also calculate how much it will move // when we scale up or down. - const double baselineOffset = -glyph.metrics.ascender * section.scale + - (lineMaxScale - section.scale) * util::ONE_EM; + const double baselineOffset = + -glyph.metrics.ascender * section.scale + (lineMaxScale - section.scale) * util::ONE_EM; if (writingMode == WritingModeType::Horizontal || // Don't verticalize glyphs that have no upright orientation if vertical placement is disabled. @@ -374,9 +374,8 @@ void shapeLines(Shaping& shaping, // If vertical placement is ebabled, don't verticalize glyphs that // are from complex text layout script, or whitespaces. (allowVerticalPlacement && (util::i18n::isWhitespace(codePoint) || util::i18n::isCharInComplexShapingScript(codePoint)))) { - shaping.positionedGlyphs.emplace_back(codePoint, x, y + baselineOffset, false, - section.fontStackHash, section.scale, - sectionIndex); + shaping.positionedGlyphs.emplace_back( + codePoint, x, y + baselineOffset, false, section.fontStackHash, section.scale, sectionIndex); x += glyph.metrics.advance * section.scale + spacing; } else { shaping.positionedGlyphs.emplace_back(codePoint, x, y + baselineOffset, true, section.fontStackHash, section.scale, sectionIndex); |