From 4297e5f499b93bbef07da5679f0c117f5f8aa6d7 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Thu, 26 Sep 2024 19:40:43 -0700 Subject: [PATCH] Added TTF_SetFontLineSkip() Fixes https://github.com/libsdl-org/SDL_ttf/issues/353 (cherry picked from commit 8b9ccb6cddad35429c53f85cfea88202847824f4) --- SDL_ttf.c | 9 +++++++++ SDL_ttf.h | 14 ++++++++++++-- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/SDL_ttf.c b/SDL_ttf.c index 2fb10c03..5122de6e 100644 --- a/SDL_ttf.c +++ b/SDL_ttf.c @@ -3011,6 +3011,15 @@ int TTF_FontLineSkip(const TTF_Font *font) return font->lineskip; } +void TTF_SetFontLineSkip(TTF_Font *font, int lineskip) +{ + if (!font) { + return; + } + + font->lineskip = lineskip; +} + int TTF_GetFontKerning(const TTF_Font *font) { return font->allow_kerning; diff --git a/SDL_ttf.h b/SDL_ttf.h index 9d5c59ae..aff2f1a4 100644 --- a/SDL_ttf.h +++ b/SDL_ttf.h @@ -634,15 +634,25 @@ extern DECLSPEC int SDLCALL TTF_FontAscent(const TTF_Font *font); extern DECLSPEC int SDLCALL TTF_FontDescent(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. + * \returns the font's line spacing. * * \since This function is available since SDL_ttf 2.0.12. */ extern DECLSPEC int SDLCALL TTF_FontLineSkip(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. + * + * \since This function is available since SDL_ttf 2.22.0. + */ +extern DECLSPEC void SDLCALL TTF_SetFontLineSkip(TTF_Font *font, int lineskip); + /** * Query whether or not kerning is allowed for a font. *