https://github.com/libsdl-org/SDL_ttf/commit/7a1942b7ceab9bac45f78cb999b0d911f06b2523
From 7a1942b7ceab9bac45f78cb999b0d911f06b2523 Mon Sep 17 00:00:00 2001
From: Simon McVittie <[EMAIL REDACTED]>
Date: Wed, 8 Jan 2025 17:25:59 +0000
Subject: [PATCH] testgputext: Allow a font filename to be given on the
command-line
This allows it to be used as an "as-installed" test, just like
showfont and glfont, without needing to bundle a specific font file
or be in a specific directory.
Signed-off-by: Simon McVittie <smcv@debian.org>
---
examples/testgputext.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/examples/testgputext.c b/examples/testgputext.c
index 09a9d458..8a61836d 100644
--- a/examples/testgputext.c
+++ b/examples/testgputext.c
@@ -224,8 +224,10 @@ void free_context(Context *context)
int main(int argc, char *argv[])
{
- (void)argc;
- (void)argv;
+ const char *font_filename = "NotoSansMono-Regular.ttf";
+
+ if (argc > 1)
+ font_filename = argv[1];
check_error_bool(SDL_Init(SDL_INIT_VIDEO | SDL_INIT_EVENTS));
@@ -327,7 +329,7 @@ int main(int argc, char *argv[])
geometry_data.indices = SDL_calloc(MAX_INDEX_COUNT, sizeof(int));
check_error_bool(TTF_Init());
- TTF_Font *font = check_error_ptr(TTF_OpenFont("NotoSansMono-Regular.ttf", 50));
+ TTF_Font *font = check_error_ptr(TTF_OpenFont(font_filename, 50));
if (!font)
running = false;
TTF_SetFontWrapAlignment(font, TTF_HORIZONTAL_ALIGN_CENTER);