From 83938ec7025e30e4cc87bb8b671bc01ea8282f89 Mon Sep 17 00:00:00 2001
From: Sylvain <[EMAIL REDACTED]>
Date: Wed, 20 Mar 2024 13:27:38 +0100
Subject: [PATCH] Harfbuzz can do kerning positioning even if the font hasn't
the data (see #341)
(cherry picked from commit 6e260a2eafbbcebd23994950d1b7adfab574dbe6)
(cherry picked from commit 2704f4e3318b3c3141235b06867fc8bab4967055)
---
SDL_ttf.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/SDL_ttf.c b/SDL_ttf.c
index 557c1726..941bcc93 100644
--- a/SDL_ttf.c
+++ b/SDL_ttf.c
@@ -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;
@@ -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)
@@ -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;