Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use SDL_TTF_VERSION_ATLEAST #3003

Merged
merged 1 commit into from
Jul 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 3 additions & 10 deletions src_c/font.c
Original file line number Diff line number Diff line change
Expand Up @@ -919,10 +919,7 @@ font_set_script(PyObject *self, PyObject *arg)
return RAISE_FONT_QUIT_ERROR();
}

/*Sadly, SDL_TTF_VERSION_ATLEAST is new in SDL_ttf 2.0.15, still too
* new to use */
#if SDL_VERSIONNUM(SDL_TTF_MAJOR_VERSION, SDL_TTF_MINOR_VERSION, \
SDL_TTF_PATCHLEVEL) >= SDL_VERSIONNUM(2, 20, 0)
#if SDL_TTF_VERSION_ATLEAST(2, 20, 0)
TTF_Font *font = PyFont_AsFont(self);
Py_ssize_t size;
const char *script_code;
Expand Down Expand Up @@ -956,10 +953,7 @@ font_set_direction(PyObject *self, PyObject *arg, PyObject *kwarg)
return RAISE_FONT_QUIT_ERROR();
}

/* Can't use SDL_TTF_VERSION_ATLEAST until SDL_ttf 2.0.15 is minimum supported
*/
#if SDL_VERSIONNUM(SDL_TTF_MAJOR_VERSION, SDL_TTF_MINOR_VERSION, \
SDL_TTF_PATCHLEVEL) >= SDL_VERSIONNUM(2, 20, 0)
#if SDL_TTF_VERSION_ATLEAST(2, 20, 0)
TTF_Font *font = PyFont_AsFont(self);
int direction;
char *kwds[] = {"direction", NULL};
Expand Down Expand Up @@ -989,8 +983,7 @@ font_set_direction(PyObject *self, PyObject *arg, PyObject *kwarg)
writing this) This bug flips the top-to-bottom and bottom-to-top rendering.
So, this is a compat patch for that behavior
*/
#if SDL_VERSIONNUM(SDL_TTF_MAJOR_VERSION, SDL_TTF_MINOR_VERSION, \
SDL_TTF_PATCHLEVEL) < SDL_VERSIONNUM(2, 22, 0)
#if !SDL_TTF_VERSION_ATLEAST(2, 22, 0)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now that you made this PR, it got me thinking of whether this should be a compiled-version check or a linked-version check.

It isn't a big deal as probably over 99% of our users have matching compiled and linked versions, but it could be something to look into if you'd like.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think for the purposes of compat with the original code, it should be kept as-is in this pull. If we want to change that extreme edge-case behavior, that should be a separate pull IMO (maybe one that addresses it in a bunch of places that I'm sure have a similar problem)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it would dynamically link if it was lower.

case 2: {
dir = TTF_DIRECTION_BTT;
break;
Expand Down
Loading