Skip to content

Commit 8e4b2f0

Browse files
committed
web: tidy & format
Signed-off-by: Matt Liberty <mliberty@precisioninno.com>
1 parent abcf56b commit 8e4b2f0

3 files changed

Lines changed: 19 additions & 10 deletions

File tree

src/web/src/font_atlas.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55

66
#pragma once
77

8+
#include <string_view>
9+
810
#include "glyph_cache.h"
911

1012
namespace web {

src/web/src/glyph_cache.cpp

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@
55

66
#include <algorithm>
77
#include <cmath>
8+
#include <cstddef>
9+
#include <mutex>
10+
#include <string_view>
11+
#include <vector>
812

913
#include "font_data.h"
1014
#include "third-party/stb_truetype/stb_truetype.h"
@@ -143,17 +147,22 @@ GlyphCache::GlyphInfo GlyphCache::glyph(int font_height, char ch) const
143147
const int idx = static_cast<unsigned char>(ch) - kFirstChar;
144148
const auto& slot = getSlot(font_height);
145149
if (idx < 0 || idx >= kNumGlyphs) {
146-
return {nullptr, 0, 0, 0, 0, 0};
150+
return {.alpha = nullptr,
151+
.bmp_width = 0,
152+
.bmp_height = 0,
153+
.x_offset = 0,
154+
.y_offset = 0,
155+
.advance = 0};
147156
}
148157
const auto& cg = slot.glyphs[idx];
149158
const unsigned char* alpha_ptr
150159
= cg.bmp_width > 0 ? slot.alpha.data() + cg.alpha_offset : nullptr;
151-
return {alpha_ptr,
152-
cg.bmp_width,
153-
cg.bmp_height,
154-
cg.x_offset,
155-
cg.y_offset,
156-
cg.advance};
160+
return {.alpha = alpha_ptr,
161+
.bmp_width = cg.bmp_width,
162+
.bmp_height = cg.bmp_height,
163+
.x_offset = cg.x_offset,
164+
.y_offset = cg.y_offset,
165+
.advance = cg.advance};
157166
}
158167

159168
int GlyphCache::kern(int font_height, char ch1, char ch2) const

src/web/src/tile_generator.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -405,9 +405,7 @@ odb::Rect TileGenerator::getBounds() const
405405
int max_text_px = 0;
406406
for (odb::dbBTerm* term : block->getBTerms()) {
407407
const int w = fontAtlasTextWidth(term->getName(), kPinLabelFontHeight);
408-
if (w > max_text_px) {
409-
max_text_px = w;
410-
}
408+
max_text_px = std::max(w, max_text_px);
411409
}
412410
const int label_px = kMinPinNameSizePixels + 3 + max_text_px;
413411
const int margin = label_px * pin_size / kMinPinNameSizePixels;

0 commit comments

Comments
 (0)