From 8b9ccb6cddad35429c53f85cfea88202847824f4 Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Thu, 26 Sep 2024 19:40:43 -0700
Subject: [PATCH] Added TTF_SetFontLineSkip()
Fixes https://github.com/libsdl-org/SDL_ttf/issues/353
---
include/SDL3_ttf/SDL_ttf.h | 14 +++++++++++++-
src/SDL_ttf.c | 7 +++++++
src/SDL_ttf.sym | 1 +
3 files changed, 21 insertions(+), 1 deletion(-)
diff --git a/include/SDL3_ttf/SDL_ttf.h b/include/SDL3_ttf/SDL_ttf.h
index 9d6e8c5f..31b376c6 100644
--- a/include/SDL3_ttf/SDL_ttf.h
+++ b/include/SDL3_ttf/SDL_ttf.h
@@ -511,7 +511,7 @@ extern SDL_DECLSPEC int SDLCALL TTF_GetFontAscent(const TTF_Font *font);
extern SDL_DECLSPEC int SDLCALL TTF_GetFontDescent(const TTF_Font *font);
/**
- * Query the recommended spacing between lines of text for a font.
+ * Query the spacing between lines of text for a font.
*
* \param font the font to query.
* \returns the font's recommended spacing.
@@ -522,6 +522,18 @@ extern SDL_DECLSPEC int SDLCALL TTF_GetFontDescent(const TTF_Font *font);
*/
extern SDL_DECLSPEC int SDLCALL TTF_GetFontLineSkip(const TTF_Font *font);
+/**
+ * Set the spacing between lines of text for a font.
+ *
+ * \param font the font to modify.
+ * \param lineskip the new line spacing for the font.
+ *
+ * \threadsafety This function should be called on the thread that created the font.
+ *
+ * \since This function is available since SDL_ttf 3.0.0.
+ */
+extern SDL_DECLSPEC void SDLCALL TTF_SetFontLineSkip(TTF_Font *font, int lineskip);
+
/**
* Query whether or not kerning is enabled for a font.
*
diff --git a/src/SDL_ttf.c b/src/SDL_ttf.c
index e8729e4f..384286ce 100644
--- a/src/SDL_ttf.c
+++ b/src/SDL_ttf.c
@@ -2788,6 +2788,13 @@ int TTF_GetFontLineSkip(const TTF_Font *font)
return font->lineskip;
}
+void TTF_SetFontLineSkip(TTF_Font *font, int lineskip)
+{
+ TTF_CHECK_FONT(font,);
+
+ font->lineskip = lineskip;
+}
+
bool TTF_GetFontKerning(const TTF_Font *font)
{
TTF_CHECK_FONT(font, false);
diff --git a/src/SDL_ttf.sym b/src/SDL_ttf.sym
index 3a49d033..c6891704 100644
--- a/src/SDL_ttf.sym
+++ b/src/SDL_ttf.sym
@@ -43,6 +43,7 @@ SDL3_ttf_0.0.0 {
TTF_SetFontHinting;
TTF_SetFontKerning;
TTF_SetFontLanguage;
+ TTF_SetFontLineSkip;
TTF_SetFontOutline;
TTF_SetFontSDF;
TTF_SetFontScriptName;