Fix divide by zero displaying characters with an unknown column width

The result of BLI_wcwidth wasn't checked before using the result to
calculate a width, this cause a negative return value to be multiplied
by the font size which divided by zero.
This commit is contained in:
Campbell Barton
2023-09-15 16:04:31 +10:00
parent bc51449ff1
commit af81ee37b9

View File

@@ -1053,7 +1053,10 @@ static FT_GlyphSlot blf_glyph_render(FontBLF *settings_font,
}
if ((settings_font->flags & BLF_MONOSPACED) && (settings_font != glyph_font)) {
blf_glyph_transform_monospace(glyph, BLI_wcwidth(char32_t(charcode)) * fixed_width);
const int col = BLI_wcwidth(char32_t(charcode));
if (col > 0) {
blf_glyph_transform_monospace(glyph, col * fixed_width);
}
}
/* Fallback glyph transforms, but only if required and not yet done. */