From 87e45339635e8fb9420b4b2812a5550361e6c1c2 Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Wed, 5 Jan 2022 14:19:35 -0800
Subject: [PATCH] Polish pass on TTF_GetFreeTypeVersion() and
TTF_GetHarfBuzzVersion()
---
CHANGES.txt | 2 ++
SDL_ttf.c | 19 +++++++++++++++----
SDL_ttf.h | 7 +++++--
3 files changed, 22 insertions(+), 6 deletions(-)
diff --git a/CHANGES.txt b/CHANGES.txt
index 6fcf490..b0de1bd 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,6 @@
2.0.18:
+Ozkan Sezer - Wed Jan 5 14:15:46 PST 2022
+ * Added TTF_GetFreeTypeVersion() and TTF_GetHarfBuzzVersion()
Sylvain - Jan 16, 2021
* Added support for Signed Distance Field rendering with TTF_SetFontSDF() and TTF_GetFontSDF()
David Ludwig - Dec 28, 2019
diff --git a/SDL_ttf.c b/SDL_ttf.c
index cc4264a..47a065a 100644
--- a/SDL_ttf.c
+++ b/SDL_ttf.c
@@ -1550,13 +1550,24 @@ void TTF_GetFreeTypeVersion(int *major, int *minor, int *patch)
FT_Library_Version(library, major, minor, patch);
}
-void TTF_GetHarfBuzzVersion(unsigned int *major, unsigned int *minor, unsigned int *patch)
+void TTF_GetHarfBuzzVersion(int *major, int *minor, int *patch)
{
+ unsigned int hb_major = 0;
+ unsigned int hb_minor = 0;
+ unsigned int hb_micro = 0;
+
#if TTF_USE_HARFBUZZ
- hb_version(major, minor, patch);
-#else
- *major = *minor = *patch = 0;
+ hb_version(&hb_major, &hb_minor, &hb_micro);
#endif
+ if (major) {
+ *major = (int)hb_major;
+ }
+ if (minor) {
+ *minor = (int)hb_minor;
+ }
+ if (patch) {
+ *patch = (int)hb_micro;
+ }
}
static unsigned long RWread(
diff --git a/SDL_ttf.h b/SDL_ttf.h
index 9fcef20..ec5c9de 100644
--- a/SDL_ttf.h
+++ b/SDL_ttf.h
@@ -85,10 +85,13 @@ extern "C" {
extern DECLSPEC const SDL_version * SDLCALL TTF_Linked_Version(void);
/* This function stores the version of the FreeType2 library in use.
- TTF_Init() should be called before using.
+ TTF_Init() should be called before calling this function.
*/
extern DECLSPEC void SDLCALL TTF_GetFreeTypeVersion(int *major, int *minor, int *patch);
-extern DECLSPEC void SDLCALL TTF_GetHarfBuzzVersion(unsigned int *major, unsigned int *minor, unsigned int *patch);
+
+/* This function stores the version of the HarfBuzz library in use, or 0 if HarfBuzz is not available.
+ */
+extern DECLSPEC void SDLCALL TTF_GetHarfBuzzVersion(int *major, int *minor, int *patch);
/* ZERO WIDTH NO-BREAKSPACE (Unicode byte order mark) */
#define UNICODE_BOM_NATIVE 0xFEFF