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

Commit c14f327

Browse files
committed
[core] Fix clang-format error
1 parent 9aedf6d commit c14f327

File tree

2 files changed

+60
-64
lines changed

2 files changed

+60
-64
lines changed

src/mbgl/text/glyph_pbf.cpp

Lines changed: 56 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -21,91 +21,88 @@ std::vector<Glyph> parseGlyphPBF(const GlyphRange& glyphRange, const std::string
2121

2222
while (glyph_pbf.next()) {
2323
switch (glyph_pbf.tag()) {
24-
case 1: // id
25-
glyph.id = glyph_pbf.get_uint32();
26-
hasID = true;
27-
break;
28-
case 2: // bitmap
29-
glyphData = glyph_pbf.get_view();
30-
break;
31-
case 3: // width
32-
glyph.metrics.width = glyph_pbf.get_uint32();
33-
hasWidth = true;
34-
break;
35-
case 4: // height
36-
glyph.metrics.height = glyph_pbf.get_uint32();
37-
hasHeight = true;
38-
break;
39-
case 5: // left
40-
glyph.metrics.left = glyph_pbf.get_sint32();
41-
hasLeft = true;
42-
break;
43-
case 6: // top
44-
glyph.metrics.top = glyph_pbf.get_sint32();
45-
hasTop = true;
46-
break;
47-
case 7: // advance
48-
glyph.metrics.advance = glyph_pbf.get_uint32();
49-
hasAdvance = true;
50-
break;
51-
default:
52-
glyph_pbf.skip();
53-
break;
24+
case 1: // id
25+
glyph.id = glyph_pbf.get_uint32();
26+
hasID = true;
27+
break;
28+
case 2: // bitmap
29+
glyphData = glyph_pbf.get_view();
30+
break;
31+
case 3: // width
32+
glyph.metrics.width = glyph_pbf.get_uint32();
33+
hasWidth = true;
34+
break;
35+
case 4: // height
36+
glyph.metrics.height = glyph_pbf.get_uint32();
37+
hasHeight = true;
38+
break;
39+
case 5: // left
40+
glyph.metrics.left = glyph_pbf.get_sint32();
41+
hasLeft = true;
42+
break;
43+
case 6: // top
44+
glyph.metrics.top = glyph_pbf.get_sint32();
45+
hasTop = true;
46+
break;
47+
case 7: // advance
48+
glyph.metrics.advance = glyph_pbf.get_uint32();
49+
hasAdvance = true;
50+
break;
51+
default:
52+
glyph_pbf.skip();
53+
break;
5454
}
5555
}
5656

5757
// Only treat this glyph as a correct glyph if it has all required fields. It also
5858
// needs to satisfy a few metrics conditions that ensure that the glyph isn't bogus.
5959
// All other glyphs are malformed. We're also discarding all glyphs that are outside
6060
// the expected glyph range.
61-
if (!hasID || !hasWidth || !hasHeight || !hasLeft || !hasTop || !hasAdvance ||
62-
glyph.metrics.width >= 256 || glyph.metrics.height >= 256 ||
63-
glyph.metrics.left < -128 || glyph.metrics.left >= 128 ||
64-
glyph.metrics.top < -128 || glyph.metrics.top >= 128 ||
65-
glyph.metrics.advance >= 256 || glyph.id < glyphRange.first ||
66-
glyph.id > glyphRange.second) {
61+
if (!hasID || !hasWidth || !hasHeight || !hasLeft || !hasTop || !hasAdvance || glyph.metrics.width >= 256 ||
62+
glyph.metrics.height >= 256 || glyph.metrics.left < -128 || glyph.metrics.left >= 128 ||
63+
glyph.metrics.top < -128 || glyph.metrics.top >= 128 || glyph.metrics.advance >= 256 ||
64+
glyph.id < glyphRange.first || glyph.id > glyphRange.second) {
6765
return;
6866
}
6967

7068
// If the area of width/height is non-zero, we need to adjust the expected size
7169
// with the implicit border size, otherwise we expect there to be no bitmap at all.
7270
if (glyph.metrics.width && glyph.metrics.height) {
73-
const Size size{ glyph.metrics.width + 2 * Glyph::borderSize,
74-
glyph.metrics.height + 2 * Glyph::borderSize };
71+
const Size size{glyph.metrics.width + 2 * Glyph::borderSize,
72+
glyph.metrics.height + 2 * Glyph::borderSize};
7573

7674
if (size.area() != glyphData.size()) {
7775
return;
7876
}
7977

80-
glyph.bitmap = AlphaImage(size, reinterpret_cast<const uint8_t*>(glyphData.data()),
81-
glyphData.size());
78+
glyph.bitmap = AlphaImage(size, reinterpret_cast<const uint8_t*>(glyphData.data()), glyphData.size());
8279
}
8380

8481
result.push_back(std::move(glyph));
8582
};
8683

87-
double ascender{ 0.0 }, descender{ 0.0 };
88-
uint16_t count{ 0 };
84+
double ascender{0.0}, descender{0.0};
85+
uint16_t count{0};
8986
auto fontstack_pbf = glyphs_pbf.get_message();
9087
while (fontstack_pbf.next()) {
9188
switch (fontstack_pbf.tag()) {
92-
case 3: {
93-
readGlyphMetrics(fontstack_pbf);
94-
++count;
95-
break;
96-
}
97-
case 4: {
98-
ascender = fontstack_pbf.get_double();
99-
break;
100-
}
101-
case 5: {
102-
descender = fontstack_pbf.get_double();
103-
break;
104-
}
105-
default: {
106-
fontstack_pbf.skip();
107-
break;
108-
}
89+
case 3: {
90+
readGlyphMetrics(fontstack_pbf);
91+
++count;
92+
break;
93+
}
94+
case 4: {
95+
ascender = fontstack_pbf.get_double();
96+
break;
97+
}
98+
case 5: {
99+
descender = fontstack_pbf.get_double();
100+
break;
101+
}
102+
default: {
103+
fontstack_pbf.skip();
104+
break;
105+
}
109106
}
110107
}
111108
if (ascender != 0.0 || descender != 0.0) {

src/mbgl/text/shaping.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -365,18 +365,17 @@ void shapeLines(Shaping& shaping,
365365
// from the horizontal baseline to the highest ‘character’ coordinate in a font face.
366366
// Since we're laying out at 24 points, we need also calculate how much it will move
367367
// when we scale up or down.
368-
const double baselineOffset = -glyph.metrics.ascender * section.scale +
369-
(lineMaxScale - section.scale) * util::ONE_EM;
368+
const double baselineOffset =
369+
-glyph.metrics.ascender * section.scale + (lineMaxScale - section.scale) * util::ONE_EM;
370370

371371
if (writingMode == WritingModeType::Horizontal ||
372372
// Don't verticalize glyphs that have no upright orientation if vertical placement is disabled.
373373
(!allowVerticalPlacement && !util::i18n::hasUprightVerticalOrientation(codePoint)) ||
374374
// If vertical placement is ebabled, don't verticalize glyphs that
375375
// are from complex text layout script, or whitespaces.
376376
(allowVerticalPlacement && (util::i18n::isWhitespace(codePoint) || util::i18n::isCharInComplexShapingScript(codePoint)))) {
377-
shaping.positionedGlyphs.emplace_back(codePoint, x, y + baselineOffset, false,
378-
section.fontStackHash, section.scale,
379-
sectionIndex);
377+
shaping.positionedGlyphs.emplace_back(
378+
codePoint, x, y + baselineOffset, false, section.fontStackHash, section.scale, sectionIndex);
380379
x += glyph.metrics.advance * section.scale + spacing;
381380
} else {
382381
shaping.positionedGlyphs.emplace_back(codePoint, x, y + baselineOffset, true, section.fontStackHash, section.scale, sectionIndex);

0 commit comments

Comments
 (0)