SDL_ttf: Updated for SDL3 version changes

From ffd34fac2cafea0448c8471a0b6b9faa97867eb8 Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Wed, 15 May 2024 13:24:07 -0700
Subject: [PATCH] Updated for SDL3 version changes

---
 .wikiheaders-options                          |  2 +-
 .../cmake/sdl3_ttf-config-version.cmake       |  8 ++---
 .../CMake/sdl3_ttf-config-version.cmake       |  8 ++---
 build-scripts/test-versioning.sh              |  2 +-
 build-scripts/wikiheaders.pl                  | 22 ++++++------
 include/SDL3_ttf/SDL_ttf.h                    | 35 +++++--------------
 release_checklist.md                          |  6 ++--
 src/SDL_ttf.c                                 | 26 +++++---------
 8 files changed, 41 insertions(+), 68 deletions(-)

diff --git a/.wikiheaders-options b/.wikiheaders-options
index ad214089..99934573 100644
--- a/.wikiheaders-options
+++ b/.wikiheaders-options
@@ -7,7 +7,7 @@ mainincludefname = SDL3_ttf/SDL_ttf.h
 versionfname = include/SDL3_ttf/SDL_ttf.h
 versionmajorregex = \A\#define\s+SDL_TTF_MAJOR_VERSION\s+(\d+)\Z
 versionminorregex = \A\#define\s+SDL_TTF_MINOR_VERSION\s+(\d+)\Z
-versionpatchregex = \A\#define\s+SDL_TTF_PATCHLEVEL\s+(\d+)\Z
+versionmicroregex = \A\#define\s+SDL_TTF_MICRO_VERSION\s+(\d+)\Z
 selectheaderregex = \ASDL_ttf\.h\Z
 projecturl = https://libsdl.org/projects/SDL_ttf
 wikiurl = https://wiki.libsdl.org/SDL_ttf
diff --git a/VisualC/pkg-support/cmake/sdl3_ttf-config-version.cmake b/VisualC/pkg-support/cmake/sdl3_ttf-config-version.cmake
index 632abfe4..0160987c 100644
--- a/VisualC/pkg-support/cmake/sdl3_ttf-config-version.cmake
+++ b/VisualC/pkg-support/cmake/sdl3_ttf-config-version.cmake
@@ -13,10 +13,10 @@ string(REGEX MATCH "#define[ \t]+SDL_TTF_MAJOR_VERSION[ \t]+([0-9]+)" _sdl_major
 set(_sdl_major "${CMAKE_MATCH_1}")
 string(REGEX MATCH "#define[ \t]+SDL_TTF_MINOR_VERSION[ \t]+([0-9]+)" _sdl_minor_re "${_sdl_ttf_h}")
 set(_sdl_minor "${CMAKE_MATCH_1}")
-string(REGEX MATCH "#define[ \t]+SDL_TTF_PATCHLEVEL[ \t]+([0-9]+)" _sdl_patch_re "${_sdl_ttf_h}")
-set(_sdl_patch "${CMAKE_MATCH_1}")
-if(_sdl_major_re AND _sdl_minor_re AND _sdl_patch_re)
-    set(PACKAGE_VERSION "${_sdl_major}.${_sdl_minor}.${_sdl_patch}")
+string(REGEX MATCH "#define[ \t]+SDL_TTF_MICRO_VERSION[ \t]+([0-9]+)" _sdl_micro_re "${_sdl_ttf_h}")
+set(_sdl_micro "${CMAKE_MATCH_1}")
+if(_sdl_major_re AND _sdl_minor_re AND _sdl_micro_re)
+    set(PACKAGE_VERSION "${_sdl_major}.${_sdl_minor}.${_sdl_micro}")
 else()
     message(AUTHOR_WARNING "Could not extract version from SDL_ttf.h.")
     return()
diff --git a/Xcode/pkg-support/resources/CMake/sdl3_ttf-config-version.cmake b/Xcode/pkg-support/resources/CMake/sdl3_ttf-config-version.cmake
index 007b2b8a..3602d9d0 100644
--- a/Xcode/pkg-support/resources/CMake/sdl3_ttf-config-version.cmake
+++ b/Xcode/pkg-support/resources/CMake/sdl3_ttf-config-version.cmake
@@ -13,10 +13,10 @@ string(REGEX MATCH "#define[ \t]+SDL_TTF_MAJOR_VERSION[ \t]+([0-9]+)" _sdl_major
 set(_sdl_major "${CMAKE_MATCH_1}")
 string(REGEX MATCH "#define[ \t]+SDL_TTF_MINOR_VERSION[ \t]+([0-9]+)" _sdl_minor_re "${_sdl_ttf_h}")
 set(_sdl_minor "${CMAKE_MATCH_1}")
-string(REGEX MATCH "#define[ \t]+SDL_TTF_PATCHLEVEL[ \t]+([0-9]+)" _sdl_patch_re "${_sdl_ttf_h}")
-set(_sdl_patch "${CMAKE_MATCH_1}")
-if(_sdl_major_re AND _sdl_minor_re AND _sdl_patch_re)
-    set(PACKAGE_VERSION "${_sdl_major}.${_sdl_minor}.${_sdl_patch}")
+string(REGEX MATCH "#define[ \t]+SDL_TTF_MICRO_VERSION[ \t]+([0-9]+)" _sdl_micro_re "${_sdl_ttf_h}")
+set(_sdl_micro "${CMAKE_MATCH_1}")
+if(_sdl_major_re AND _sdl_minor_re AND _sdl_micro_re)
+    set(PACKAGE_VERSION "${_sdl_major}.${_sdl_minor}.${_sdl_micro}")
 else()
     message(AUTHOR_WARNING "Could not extract version from SDL_ttf.h.")
     return()
diff --git a/build-scripts/test-versioning.sh b/build-scripts/test-versioning.sh
index 58b9d816..b8339d0d 100755
--- a/build-scripts/test-versioning.sh
+++ b/build-scripts/test-versioning.sh
@@ -12,7 +12,7 @@ export LC_CTYPE=C
 header=include/SDL3_ttf/SDL_ttf.h
 ref_major=$(sed -ne 's/^#define SDL_TTF_MAJOR_VERSION  *//p' $header)
 ref_minor=$(sed -ne 's/^#define SDL_TTF_MINOR_VERSION  *//p' $header)
-ref_micro=$(sed -ne 's/^#define SDL_TTF_PATCHLEVEL  *//p' $header)
+ref_micro=$(sed -ne 's/^#define SDL_TTF_MICRO_VERSION  *//p' $header)
 ref_version="${ref_major}.${ref_minor}.${ref_micro}"
 
 tests=0
diff --git a/build-scripts/wikiheaders.pl b/build-scripts/wikiheaders.pl
index 185701b4..6e421970 100755
--- a/build-scripts/wikiheaders.pl
+++ b/build-scripts/wikiheaders.pl
@@ -16,7 +16,7 @@
 my $versionfname = 'include/SDL_version.h';
 my $versionmajorregex = '\A\#define\s+SDL_MAJOR_VERSION\s+(\d+)\Z';
 my $versionminorregex = '\A\#define\s+SDL_MINOR_VERSION\s+(\d+)\Z';
-my $versionpatchregex = '\A\#define\s+SDL_PATCHLEVEL\s+(\d+)\Z';
+my $versionmicroregex = '\A\#define\s+SDL_MICRO_VERSION\s+(\d+)\Z';
 my $mainincludefname = 'SDL.h';
 my $selectheaderregex = '\ASDL.*?\.h\Z';
 my $projecturl = 'https://libsdl.org/';
@@ -92,7 +92,7 @@
             $readmesubdir = $val, next if $key eq 'readmesubdir';
             $versionmajorregex = $val, next if $key eq 'versionmajorregex';
             $versionminorregex = $val, next if $key eq 'versionminorregex';
-            $versionpatchregex = $val, next if $key eq 'versionpatchregex';
+            $versionmicroregex = $val, next if $key eq 'versionmicroregex';
             $versionfname = $val, next if $key eq 'versionfname';
             $mainincludefname = $val, next if $key eq 'mainincludefname';
             $selectheaderregex = $val, next if $key eq 'selectheaderregex';
@@ -2036,19 +2036,19 @@ sub print_undocumented_section {
     open(FH, '<', "$srcpath/$versionfname") or die("Can't open '$srcpath/$versionfname': $!\n");
     my $majorver = 0;
     my $minorver = 0;
-    my $patchver = 0;
+    my $microver = 0;
     while (<FH>) {
         chomp;
         if (/$versionmajorregex/) {
             $majorver = int($1);
         } elsif (/$versionminorregex/) {
             $minorver = int($1);
-        } elsif (/$versionpatchregex/) {
-            $patchver = int($1);
+        } elsif (/$versionmicroregex/) {
+            $microver = int($1);
         }
     }
     close(FH);
-    my $fullversion = "$majorver.$minorver.$patchver";
+    my $fullversion = "$majorver.$minorver.$microver";
 
     foreach (keys %headersyms) {
         my $sym = $_;
@@ -2318,19 +2318,19 @@ sub print_undocumented_section {
     open(FH, '<', "$srcpath/$versionfname") or die("Can't open '$srcpath/$versionfname': $!\n");
     my $majorver = 0;
     my $minorver = 0;
-    my $patchver = 0;
+    my $microver = 0;
     while (<FH>) {
         chomp;
         if (/$versionmajorregex/) {
             $majorver = int($1);
         } elsif (/$versionminorregex/) {
             $minorver = int($1);
-        } elsif (/$versionpatchregex/) {
-            $patchver = int($1);
+        } elsif (/$versionmicroregex/) {
+            $microver = int($1);
         }
     }
     close(FH);
-    my $fullversion = "$majorver.$minorver.$patchver";
+    my $fullversion = "$majorver.$minorver.$microver";
 
     my $latex_fname = "$srcpath/$projectshortname.tex";
     my $latex_tmpfname = "$latex_fname.tmp";
@@ -2369,7 +2369,7 @@ sub print_undocumented_section {
 \\begin{document}
 \\frontmatter
 
-\\title{$projectfullname $majorver.$minorver.$patchver Reference Manual}
+\\title{$projectfullname $majorver.$minorver.$microver Reference Manual}
 \\author{The $projectshortname Developers}
 \\maketitle
 
diff --git a/include/SDL3_ttf/SDL_ttf.h b/include/SDL3_ttf/SDL_ttf.h
index 413de01e..62dbb8ef 100644
--- a/include/SDL3_ttf/SDL_ttf.h
+++ b/include/SDL3_ttf/SDL_ttf.h
@@ -45,30 +45,17 @@ extern "C" {
 #endif
 
 /**
- * Printable format: "%d.%d.%d", MAJOR, MINOR, PATCHLEVEL
+ * Printable format: "%d.%d.%d", MAJOR, MINOR, MICRO
  */
 #define SDL_TTF_MAJOR_VERSION   3
 #define SDL_TTF_MINOR_VERSION   0
-#define SDL_TTF_PATCHLEVEL      0
+#define SDL_TTF_MICRO_VERSION   0
 
 /**
- * This macro can be used to fill a version structure with the compile-time
- * version of the SDL_ttf library.
+ * This is the version number macro for the current SDL_ttf version.
  */
-#define SDL_TTF_VERSION(X)                          \
-{                                                   \
-    (X)->major = SDL_TTF_MAJOR_VERSION;             \
-    (X)->minor = SDL_TTF_MINOR_VERSION;             \
-    (X)->patch = SDL_TTF_PATCHLEVEL;                \
-}
-
-/**
- * Backwards compatibility
- */
-#define TTF_MAJOR_VERSION   SDL_TTF_MAJOR_VERSION
-#define TTF_MINOR_VERSION   SDL_TTF_MINOR_VERSION
-#define TTF_PATCHLEVEL      SDL_TTF_PATCHLEVEL
-#define TTF_VERSION(X)      SDL_TTF_VERSION(X)
+#define SDL_TTF_VERSION \
+    SDL_VERSIONNUM(SDL_TTF_MAJOR_VERSION, SDL_TTF_MINOR_VERSION, SDL_TTF_MICRO_VERSION)
 
 /**
  * This macro will evaluate to true if compiled with SDL_ttf at least X.Y.Z.
@@ -76,22 +63,16 @@ extern "C" {
 #define SDL_TTF_VERSION_ATLEAST(X, Y, Z) \
     ((SDL_TTF_MAJOR_VERSION >= X) && \
      (SDL_TTF_MAJOR_VERSION > X || SDL_TTF_MINOR_VERSION >= Y) && \
-     (SDL_TTF_MAJOR_VERSION > X || SDL_TTF_MINOR_VERSION > Y || SDL_TTF_PATCHLEVEL >= Z))
+     (SDL_TTF_MAJOR_VERSION > X || SDL_TTF_MINOR_VERSION > Y || SDL_TTF_MICRO_VERSION >= Z))
 
 /**
- * Query the version of SDL_ttf that the program is linked against.
- *
  * This function gets the version of the dynamically linked SDL_ttf library.
- * This is separate from the SDL_TTF_VERSION() macro, which tells you what
- * version of the SDL_ttf headers you compiled against.
- *
- * This returns static internal data; do not free or modify it!
  *
- * \returns a pointer to the version information.
+ * \returns SDL_ttf version
  *
  * \since This function is available since SDL_ttf 3.0.0.
  */
-extern DECLSPEC const SDL_Version * SDLCALL TTF_Linked_Version(void);
+extern DECLSPEC int SDLCALL IMG_Version(void);
 
 /**
  * Query the version of the FreeType library in use.
diff --git a/release_checklist.md b/release_checklist.md
index cc9115ec..b13ffde8 100644
--- a/release_checklist.md
+++ b/release_checklist.md
@@ -7,7 +7,7 @@
 * Bump version number to 3.EVEN.0 in all these locations:
 
     * `include/SDL3/SDL_ttf.h`:
-        `SDL_TTF_MAJOR_VERSION`, `SDL_TTF_MINOR_VERSION`, `SDL_TTF_PATCHLEVEL`
+        `SDL_TTF_MAJOR_VERSION`, `SDL_TTF_MINOR_VERSION`, `SDL_TTF_MICRO_VERSION`
     * `CMakeLists.txt`:
         `MAJOR_VERSION`, `MINOR_VERSION`, `MICRO_VERSION`
     * `version.rc`:
@@ -46,7 +46,7 @@
 
 	* `Xcode/SDL_ttf.xcodeproj/project.pbxproj`:
 	  `DYLIB_CURRENT_VERSION`, `DYLIB_COMPATIBILITY_VERSION`
-		* set second number in `DYLIB_CURRENT_VERSION` to *patchlevel*
+		* set second number in `DYLIB_CURRENT_VERSION` to *micro*
         * Leave `DYLIB_COMPATIBILITY_VERSION` unchanged
 
 * Regenerate `configure`
@@ -83,7 +83,7 @@
 	* `Xcode/SDL_ttf.xcodeproj/project.pbxproj`:
 	  `DYLIB_CURRENT_VERSION`, `DYLIB_COMPATIBILITY_VERSION`
 		* set first number in `DYLIB_CURRENT_VERSION` to
-		  (100 * *minor*) + *patchlevel* + 1
+		  (100 * *minor*) + *micro* + 1
 		* set second number in `DYLIB_CURRENT_VERSION` to 0
         * set `DYLIB_COMPATIBILITY_VERSION` to the same value
 
diff --git a/src/SDL_ttf.c b/src/SDL_ttf.c
index 0bd35509..d8119a31 100644
--- a/src/SDL_ttf.c
+++ b/src/SDL_ttf.c
@@ -55,28 +55,22 @@
 #  define TTF_USE_HARFBUZZ 0
 #endif
 
-#if defined(SDL_BUILD_MAJOR_VERSION) && defined(SDL_COMPILE_TIME_ASSERT)
+#if defined(SDL_BUILD_MAJOR_VERSION)
 SDL_COMPILE_TIME_ASSERT(SDL_BUILD_MAJOR_VERSION,
                         SDL_TTF_MAJOR_VERSION == SDL_BUILD_MAJOR_VERSION);
 SDL_COMPILE_TIME_ASSERT(SDL_BUILD_MINOR_VERSION,
                         SDL_TTF_MINOR_VERSION == SDL_BUILD_MINOR_VERSION);
 SDL_COMPILE_TIME_ASSERT(SDL_BUILD_MICRO_VERSION,
-                        SDL_TTF_PATCHLEVEL == SDL_BUILD_MICRO_VERSION);
+                        SDL_TTF_MICRO_VERSION == SDL_BUILD_MICRO_VERSION);
 #endif
 
-#if defined(SDL_COMPILE_TIME_ASSERT)
+/* Limited by its encoding in SDL_VERSIONNUM */
 SDL_COMPILE_TIME_ASSERT(SDL_TTF_MAJOR_VERSION_min, SDL_TTF_MAJOR_VERSION >= 0);
-/* Limited only by the need to fit in SDL_Version */
-SDL_COMPILE_TIME_ASSERT(SDL_TTF_MAJOR_VERSION_max, SDL_TTF_MAJOR_VERSION <= 255);
-
+SDL_COMPILE_TIME_ASSERT(SDL_TTF_MAJOR_VERSION_max, SDL_TTF_MAJOR_VERSION <= 10);
 SDL_COMPILE_TIME_ASSERT(SDL_TTF_MINOR_VERSION_min, SDL_TTF_MINOR_VERSION >= 0);
-/* Limited only by the need to fit in SDL_Version */
-SDL_COMPILE_TIME_ASSERT(SDL_TTF_MINOR_VERSION_max, SDL_TTF_MINOR_VERSION <= 255);
-
-SDL_COMPILE_TIME_ASSERT(SDL_TTF_PATCHLEVEL_min, SDL_TTF_PATCHLEVEL >= 0);
-/* Limited by its encoding in SDL_VERSIONNUM and in the ABI versions */
-SDL_COMPILE_TIME_ASSERT(SDL_TTF_PATCHLEVEL_max, SDL_TTF_PATCHLEVEL <= 99);
-#endif
+SDL_COMPILE_TIME_ASSERT(SDL_TTF_MINOR_VERSION_max, SDL_TTF_MINOR_VERSION <= 999);
+SDL_COMPILE_TIME_ASSERT(SDL_TTF_MICRO_VERSION_min, SDL_TTF_MICRO_VERSION >= 0);
+SDL_COMPILE_TIME_ASSERT(SDL_TTF_MICRO_VERSION_max, SDL_TTF_MICRO_VERSION <= 999);
 
 #if TTF_USE_HARFBUZZ
 #include <hb.h>
@@ -1601,11 +1595,9 @@ static SDL_Surface* Create_Surface_LCD(int width, int height, SDL_Color fg, SDL_
 
 
 /* rcg06192001 get linked library's version. */
-const SDL_Version* TTF_Linked_Version(void)
+int TTF_Version(void)
 {
-    static SDL_Version linked_version;
-    SDL_TTF_VERSION(&linked_version);
-    return &linked_version;
+    return SDL_TTF_VERSION;
 }
 
 /* This function tells the library whether UNICODE text is generally