mirror of
https://github.com/esphome/esphome.git
synced 2025-04-16 07:40:29 +01:00
Use advance instead of bitmap width
This commit is contained in:
parent
102e2b1cda
commit
1520e4f3b1
@ -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(
|
return font_file_schema(
|
||||||
{
|
{
|
||||||
CONF_TYPE: TYPE_LOCAL_BITMAP,
|
CONF_TYPE: TYPE_LOCAL_BITMAP,
|
||||||
|
@ -81,7 +81,7 @@ void Font::measure(const char *str, int *width, int *x_offset, int *baseline, in
|
|||||||
if (glyph_n < 0) {
|
if (glyph_n < 0) {
|
||||||
// Unknown char, skip
|
// Unknown char, skip
|
||||||
if (!this->get_glyphs().empty())
|
if (!this->get_glyphs().empty())
|
||||||
x += this->get_glyphs()[0].glyph_data_->width;
|
x += this->get_glyphs()[0].glyph_data_->advance;
|
||||||
i++;
|
i++;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -92,7 +92,7 @@ void Font::measure(const char *str, int *width, int *x_offset, int *baseline, in
|
|||||||
} else {
|
} else {
|
||||||
min_x = std::min(min_x, x + glyph.glyph_data_->offset_x);
|
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;
|
i += match_length;
|
||||||
has_char = true;
|
has_char = true;
|
||||||
@ -111,7 +111,7 @@ void Font::print(int x_start, int y_start, display::Display *display, Color colo
|
|||||||
// Unknown char, skip
|
// Unknown char, skip
|
||||||
ESP_LOGW(TAG, "Encountered character without representation in font: '%c'", text[i]);
|
ESP_LOGW(TAG, "Encountered character without representation in font: '%c'", text[i]);
|
||||||
if (!this->get_glyphs().empty()) {
|
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);
|
display->filled_rectangle(x_at, y_start, glyph_width, this->height_, color);
|
||||||
x_at += glyph_width;
|
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;
|
i += match_length;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user