From a70ece33f19086dfa55560373ae5df5349820b1a Mon Sep 17 00:00:00 2001 From: themancalledjakob Date: Tue, 2 May 2023 17:37:36 +0200 Subject: [PATCH] add letterSpacing --- src/gpufont/font.hpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/gpufont/font.hpp b/src/gpufont/font.hpp index 3f32c92..731f18a 100644 --- a/src/gpufont/font.hpp +++ b/src/gpufont/font.hpp @@ -152,6 +152,7 @@ struct GlyphAppearance { uint32_t charcode; std::array color; float fontSize_px; + float letterSpacing; }; } // create hash for GlyphIdentity, so we can use it in our unordered_map as key @@ -1157,7 +1158,7 @@ class Font { if(glyphIdentity.charcode == '\0'){ break; } - float letterFontSize_px = glyphAppearance.fontSize_px; // can be individual + float letterFontSize_px = glyphAppearance.fontSize_px; const uint32_t & charcode = glyphIdentity.charcode; if(charcode == '\r'){ @@ -1186,10 +1187,14 @@ class Font { FT_Vector kerning; FT_Error error = FT_Get_Kerning(face, previous, glyph.index, kerningMode, &kerning); if(!error){ - advanceX += ((float)kerning.x * letterFontSize_px) / emSize * worldSize; + advanceX += (((float)kerning.x * letterFontSize_px)) / emSize * worldSize; + cout << "WHAT IS THIS EVEN HAPPYNG"; } } + float letterSpacing = advanceX == 0 ? 0 : glyphAppearance.letterSpacing; + advanceX += (letterSpacing * letterFontSize_px) * worldSize; + // Do not emit quad for empty glyphs (whitespace). if(glyph.curveCount){ FT_Pos d = (FT_Pos)(emSize * dilation);