Improve truetype font text positioning with fractional glyph advances and DPI-scaled coordinates.

Disallow Font:setFallbacks for fonts that have different DPI scales.
It's still too easy to render text at a non-integer pixel when fractional DPI scales are used, so maybe a more thorough redesign would be useful.

Fixes #2318.
Fixes #2168.
This commit is contained in:
Sasha Szpakowski
2026-06-21 16:30:43 -03:00
parent a7679a5509
commit 7d49d880d7
7 changed files with 52 additions and 27 deletions
+2 -2
View File
@@ -608,12 +608,12 @@ void Font::printf(graphics::Graphics *gfx, const std::vector<love::font::Colored
printv(gfx, m, drawcommands, vertices);
}
int Font::getWidth(const std::string &str)
float Font::getWidth(const std::string &str)
{
return shaper->getWidth(str);
}
int Font::getWidth(uint32 glyph)
float Font::getWidth(uint32 glyph)
{
return shaper->getGlyphAdvance(glyph);
}