From 9ec5a1239d8818d45513a1e95bc39b78d0cde0b7 Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Thu, 26 Sep 2024 22:47:41 -0700
Subject: [PATCH] Updated the font creation property names to match SDL 3.0
convention
---
include/SDL3_ttf/SDL_ttf.h | 42 +++++++++++++++++++-------------------
src/SDL_ttf.c | 28 ++++++++++++-------------
2 files changed, 35 insertions(+), 35 deletions(-)
diff --git a/include/SDL3_ttf/SDL_ttf.h b/include/SDL3_ttf/SDL_ttf.h
index 2677dea0..af278ffe 100644
--- a/include/SDL3_ttf/SDL_ttf.h
+++ b/include/SDL3_ttf/SDL_ttf.h
@@ -192,27 +192,27 @@ extern SDL_DECLSPEC TTF_Font * SDLCALL TTF_OpenFontIO(SDL_IOStream *src, bool cl
*
* These are the supported properties:
*
- * - `TTF_PROP_FONT_FILENAME_STRING`: the font file to open, if an
+ * - `TTF_PROP_FONT_CREATE_FILENAME_STRING`: the font file to open, if an
* SDL_IOStream isn't being used. This is required if
- * `TTF_PROP_FONT_IOSTREAM_POINTER` isn't set.
- * - `TTF_PROP_FONT_IOSTREAM_POINTER`: an SDL_IOStream containing the font to
+ * `TTF_PROP_FONT_CREATE_IOSTREAM_POINTER` isn't set.
+ * - `TTF_PROP_FONT_CREATE_IOSTREAM_POINTER`: an SDL_IOStream containing the font to
* be opened. This should not be closed until the font is closed. This is
- * required if `TTF_PROP_FONT_FILENAME_STRING` isn't set.
- * - `TTF_PROP_FONT_IOSTREAM_OFFSET_NUMBER`: the offset in the iostream for
+ * required if `TTF_PROP_FONT_CREATE_FILENAME_STRING` isn't set.
+ * - `TTF_PROP_FONT_CREATE_IOSTREAM_OFFSET_NUMBER`: the offset in the iostream for
* the beginning of the font, defaults to 0.
- * - `TTF_PROP_FONT_IOSTREAM_AUTOCLOSE_BOOLEAN`: true if closing the font
+ * - `TTF_PROP_FONT_CREATE_IOSTREAM_AUTOCLOSE_BOOLEAN`: true if closing the font
* should also close the associated SDL_IOStream.
- * - `TTF_PROP_FONT_SIZE_NUMBER`: the point size of the font. Some .fon fonts
+ * - `TTF_PROP_FONT_CREATE_SIZE_NUMBER`: the point size of the font. Some .fon fonts
* will have several sizes embedded in the file, so the point size becomes
* the index of choosing which size. If the value is too high, the last
* indexed size will be the default.
- * - `TTF_PROP_FONT_FACE_NUMBER`: the face index of the font, if the font
+ * - `TTF_PROP_FONT_CREATE_FACE_NUMBER`: the face index of the font, if the font
* contains multiple font faces.
- * - `TTF_PROP_FONT_HORIZONTAL_DPI_NUMBER`: the horizontal DPI to use for font
- * rendering, defaults to `TTF_PROP_FONT_VERTICAL_DPI_NUMBER` if set, or 72
+ * - `TTF_PROP_FONT_CREATE_HORIZONTAL_DPI_NUMBER`: the horizontal DPI to use for font
+ * rendering, defaults to `TTF_PROP_FONT_CREATE_VERTICAL_DPI_NUMBER` if set, or 72
* otherwise.
- * - `TTF_PROP_FONT_VERTICAL_DPI_NUMBER`: the vertical DPI to use for font
- * rendering, defaults to `TTF_PROP_FONT_HORIZONTAL_DPI_NUMBER` if set, or
+ * - `TTF_PROP_FONT_CREATE_VERTICAL_DPI_NUMBER`: the vertical DPI to use for font
+ * rendering, defaults to `TTF_PROP_FONT_CREATE_HORIZONTAL_DPI_NUMBER` if set, or
* 72 otherwise.
*
* \param props the properties to use.
@@ -227,14 +227,14 @@ extern SDL_DECLSPEC TTF_Font * SDLCALL TTF_OpenFontIO(SDL_IOStream *src, bool cl
*/
extern SDL_DECLSPEC TTF_Font * SDLCALL TTF_OpenFontWithProperties(SDL_PropertiesID props);
-#define TTF_PROP_FONT_FILENAME_STRING "SDL_ttf.font.filename"
-#define TTF_PROP_FONT_IOSTREAM_POINTER "SDL_ttf.font.iostream"
-#define TTF_PROP_FONT_IOSTREAM_OFFSET_NUMBER "SDL_ttf.font.iostream.offset"
-#define TTF_PROP_FONT_IOSTREAM_AUTOCLOSE_BOOLEAN "SDL_ttf.font.iostream.autoclose"
-#define TTF_PROP_FONT_SIZE_FLOAT "SDL_ttf.font.size"
-#define TTF_PROP_FONT_FACE_NUMBER "SDL_ttf.font.face"
-#define TTF_PROP_FONT_HORIZONTAL_DPI_NUMBER "SDL_ttf.font.hdpi"
-#define TTF_PROP_FONT_VERTICAL_DPI_NUMBER "SDL_ttf.font.vdpi"
+#define TTF_PROP_FONT_CREATE_FILENAME_STRING "SDL_ttf.font.create.filename"
+#define TTF_PROP_FONT_CREATE_IOSTREAM_POINTER "SDL_ttf.font.create.iostream"
+#define TTF_PROP_FONT_CREATE_IOSTREAM_OFFSET_NUMBER "SDL_ttf.font.create.iostream.offset"
+#define TTF_PROP_FONT_CREATE_IOSTREAM_AUTOCLOSE_BOOLEAN "SDL_ttf.font.create.iostream.autoclose"
+#define TTF_PROP_FONT_CREATE_SIZE_FLOAT "SDL_ttf.font.create.size"
+#define TTF_PROP_FONT_CREATE_FACE_NUMBER "SDL_ttf.font.create.face"
+#define TTF_PROP_FONT_CREATE_HORIZONTAL_DPI_NUMBER "SDL_ttf.font.create.hdpi"
+#define TTF_PROP_FONT_CREATE_VERTICAL_DPI_NUMBER "SDL_ttf.font.create.vdpi"
/**
* Get the properties associated with a font.
@@ -253,7 +253,7 @@ extern SDL_DECLSPEC TTF_Font * SDLCALL TTF_OpenFontWithProperties(SDL_Properties
*/
extern SDL_DECLSPEC SDL_PropertiesID SDLCALL TTF_GetFontProperties(TTF_Font *font);
-#define TTF_PROP_FONT_FACE_POINTER "SDL_ttf.font.face"
+#define TTF_PROP_FONT_FACE_POINTER "SDL_ttf.font.face"
/**
* Set a font's size dynamically.
diff --git a/src/SDL_ttf.c b/src/SDL_ttf.c
index dd347fc6..2fa48811 100644
--- a/src/SDL_ttf.c
+++ b/src/SDL_ttf.c
@@ -1752,14 +1752,14 @@ static unsigned long IOread(
TTF_Font *TTF_OpenFontWithProperties(SDL_PropertiesID props)
{
- const char *file = SDL_GetStringProperty(props, TTF_PROP_FONT_FILENAME_STRING, NULL);
- SDL_IOStream *src = SDL_GetPointerProperty(props, TTF_PROP_FONT_IOSTREAM_POINTER, NULL);
- Sint64 src_offset = SDL_GetNumberProperty(props, TTF_PROP_FONT_IOSTREAM_OFFSET_NUMBER, 0);
- bool closeio = SDL_GetBooleanProperty(props, TTF_PROP_FONT_IOSTREAM_AUTOCLOSE_BOOLEAN, false);
- float ptsize = SDL_GetFloatProperty(props, TTF_PROP_FONT_SIZE_FLOAT, 0);
- long index = (long)SDL_GetNumberProperty(props, TTF_PROP_FONT_FACE_NUMBER, 0);
- unsigned int hdpi = (unsigned int)SDL_GetNumberProperty(props, TTF_PROP_FONT_HORIZONTAL_DPI_NUMBER, 0);
- unsigned int vdpi = (unsigned int)SDL_GetNumberProperty(props, TTF_PROP_FONT_VERTICAL_DPI_NUMBER, 0);
+ const char *file = SDL_GetStringProperty(props, TTF_PROP_FONT_CREATE_FILENAME_STRING, NULL);
+ SDL_IOStream *src = SDL_GetPointerProperty(props, TTF_PROP_FONT_CREATE_IOSTREAM_POINTER, NULL);
+ Sint64 src_offset = SDL_GetNumberProperty(props, TTF_PROP_FONT_CREATE_IOSTREAM_OFFSET_NUMBER, 0);
+ bool closeio = SDL_GetBooleanProperty(props, TTF_PROP_FONT_CREATE_IOSTREAM_AUTOCLOSE_BOOLEAN, false);
+ float ptsize = SDL_GetFloatProperty(props, TTF_PROP_FONT_CREATE_SIZE_FLOAT, 0);
+ long index = (long)SDL_GetNumberProperty(props, TTF_PROP_FONT_CREATE_FACE_NUMBER, 0);
+ unsigned int hdpi = (unsigned int)SDL_GetNumberProperty(props, TTF_PROP_FONT_CREATE_HORIZONTAL_DPI_NUMBER, 0);
+ unsigned int vdpi = (unsigned int)SDL_GetNumberProperty(props, TTF_PROP_FONT_CREATE_VERTICAL_DPI_NUMBER, 0);
TTF_Font *font;
FT_Error error;
FT_Face face;
@@ -1779,7 +1779,7 @@ TTF_Font *TTF_OpenFontWithProperties(SDL_PropertiesID props)
if (!src) {
if (!file) {
- SDL_SetError("You must set either TTF_PROP_FONT_FILENAME_STRING or TTF_PROP_FONT_IOSTREAM_POINTER");
+ SDL_SetError("You must set either TTF_PROP_FONT_CREATE_FILENAME_STRING or TTF_PROP_FONT_CREATE_IOSTREAM_POINTER");
return NULL;
}
@@ -1929,8 +1929,8 @@ TTF_Font *TTF_OpenFont(const char *file, float ptsize)
TTF_Font *font = NULL;
SDL_PropertiesID props = SDL_CreateProperties();
if (props) {
- SDL_SetStringProperty(props, TTF_PROP_FONT_FILENAME_STRING, file);
- SDL_SetFloatProperty(props, TTF_PROP_FONT_SIZE_FLOAT, ptsize);
+ SDL_SetStringProperty(props, TTF_PROP_FONT_CREATE_FILENAME_STRING, file);
+ SDL_SetFloatProperty(props, TTF_PROP_FONT_CREATE_SIZE_FLOAT, ptsize);
font = TTF_OpenFontWithProperties(props);
SDL_DestroyProperties(props);
}
@@ -1942,9 +1942,9 @@ TTF_Font *TTF_OpenFontIO(SDL_IOStream *src, bool closeio, float ptsize)
TTF_Font *font = NULL;
SDL_PropertiesID props = SDL_CreateProperties();
if (props) {
- SDL_SetPointerProperty(props, TTF_PROP_FONT_IOSTREAM_POINTER, src);
- SDL_SetBooleanProperty(props, TTF_PROP_FONT_IOSTREAM_AUTOCLOSE_BOOLEAN, closeio);
- SDL_SetFloatProperty(props, TTF_PROP_FONT_SIZE_FLOAT, ptsize);
+ SDL_SetPointerProperty(props, TTF_PROP_FONT_CREATE_IOSTREAM_POINTER, src);
+ SDL_SetBooleanProperty(props, TTF_PROP_FONT_CREATE_IOSTREAM_AUTOCLOSE_BOOLEAN, closeio);
+ SDL_SetFloatProperty(props, TTF_PROP_FONT_CREATE_SIZE_FLOAT, ptsize);
font = TTF_OpenFontWithProperties(props);
SDL_DestroyProperties(props);
}