fix msdf font layout issue

This commit is contained in:
fibref
2026-02-16 19:52:12 +08:00
parent d3bd377264
commit 0612b923e1
2 changed files with 6 additions and 3 deletions

View File

@@ -258,6 +258,10 @@ bool FontManager::AddNewEntry(Font* font, Char c, FontCharacterEntry& entry)
{
// Generate bitmap for MSDF
FT_GlyphSlot glyph = face->glyph;
// Set advance in advance
entry.AdvanceX = Convert26Dot6ToRoundedPixel<int16>(glyph->advance.x);
int16 msdf_top = 0;
int16 msdf_left = 0;
MSDFGenerator::GenerateMSDF(glyph, GlyphImageData, glyphWidth, glyphHeight, msdf_top, msdf_left);
@@ -268,8 +272,7 @@ bool FontManager::AddNewEntry(Font* font, Char c, FontCharacterEntry& entry)
return false;
}
// Fill the character data
entry.AdvanceX = Convert26Dot6ToRoundedPixel<int16>(glyph->advance.x);
// Fill the remaining character data
entry.OffsetY = msdf_top;
entry.OffsetX = msdf_left;
entry.IsValid = true;

View File

@@ -124,6 +124,6 @@ public:
outputWidth = width;
outputHeight = height;
top = static_cast<int16>(Math::CeilToInt(bounds.t + pxRange / 2.0));
left = static_cast<int16>(Math::FloorToInt(bounds.l + pxRange / 2.0));
left = static_cast<int16>(Math::FloorToInt(bounds.l - pxRange / 2.0));
}
};