1
0
mirror of https://github.com/esphome/esphome.git synced 2025-04-15 15:20:27 +01:00

Use advance instead of bitmap width

This commit is contained in:
clydebarrow 2025-02-23 14:51:49 +11:00
parent 102e2b1cda
commit 1520e4f3b1
2 changed files with 6 additions and 5 deletions

View File

@ -387,7 +387,8 @@ def validate_file_shorthand(value):
}
)
if value.endswith(".pcf") or value.endswith(".bdf"):
extension = Path(value).suffix
if extension in BITMAP_EXTENSIONS:
return font_file_schema(
{
CONF_TYPE: TYPE_LOCAL_BITMAP,

View File

@ -81,7 +81,7 @@ void Font::measure(const char *str, int *width, int *x_offset, int *baseline, in
if (glyph_n < 0) {
// Unknown char, skip
if (!this->get_glyphs().empty())
x += this->get_glyphs()[0].glyph_data_->width;
x += this->get_glyphs()[0].glyph_data_->advance;
i++;
continue;
}
@ -92,7 +92,7 @@ void Font::measure(const char *str, int *width, int *x_offset, int *baseline, in
} else {
min_x = std::min(min_x, x + glyph.glyph_data_->offset_x);
}
x += glyph.glyph_data_->width + glyph.glyph_data_->offset_x;
x += glyph.glyph_data_->advance;
i += match_length;
has_char = true;
@ -111,7 +111,7 @@ void Font::print(int x_start, int y_start, display::Display *display, Color colo
// Unknown char, skip
ESP_LOGW(TAG, "Encountered character without representation in font: '%c'", text[i]);
if (!this->get_glyphs().empty()) {
uint8_t glyph_width = this->get_glyphs()[0].glyph_data_->width;
uint8_t glyph_width = this->get_glyphs()[0].glyph_data_->advance;
display->filled_rectangle(x_at, y_start, glyph_width, this->height_, color);
x_at += glyph_width;
}
@ -161,7 +161,7 @@ void Font::print(int x_start, int y_start, display::Display *display, Color colo
}
}
}
x_at += glyph.glyph_data_->width + glyph.glyph_data_->offset_x;
x_at += glyph.glyph_data_->advance;
i += match_length;
}