Skip to content

Commit

Permalink
Harfbuzz can do kerning positioning even if the font hasn't the data …
Browse files Browse the repository at this point in the history
…(see #341)

(cherry picked from commit 6e260a2)
  • Loading branch information
1bsyl committed Mar 20, 2024
1 parent 8edfa3f commit 2704f4e
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion SDL_ttf.c
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,9 @@ struct _TTF_Font {

/* Whether kerning is desired */
int allow_kerning;
#if !TTF_USE_HARFBUZZ
int use_kerning;
#endif

/* Extra width in glyph bounds for text styles */
int glyph_overhang;
Expand Down Expand Up @@ -3016,7 +3018,11 @@ int TTF_GetFontKerning(const TTF_Font *font)
void TTF_SetFontKerning(TTF_Font *font, int allowed)
{
font->allow_kerning = allowed;
#if TTF_USE_HARFBUZZ
/* Harfbuzz can do kerning positioning even if the font hasn't the data */
#else
font->use_kerning = allowed && FT_HAS_KERNING(font->face);
#endif
}

long TTF_FontFaces(const TTF_Font *font)
Expand Down Expand Up @@ -3234,7 +3240,7 @@ static int TTF_Size_Internal(TTF_Font *font,

hb_feature_t userfeatures[1];
userfeatures[0].tag = HB_TAG('k','e','r','n');
userfeatures[0].value = font->use_kerning;
userfeatures[0].value = font->allow_kerning;
userfeatures[0].start = HB_FEATURE_GLOBAL_START;
userfeatures[0].end = HB_FEATURE_GLOBAL_END;

Expand Down

0 comments on commit 2704f4e

Please sign in to comment.