add letterSpacing

This commit is contained in:
jrkb 2023-05-02 17:37:36 +02:00
parent e17c0e4038
commit a70ece33f1

View file

@ -152,6 +152,7 @@ struct GlyphAppearance {
uint32_t charcode;
std::array <float, 4> 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);