X11TK: Introduce Thai support and rewrite/cleanup messagebox positioning code (#14474)

This commit is contained in:
eafton
2025-11-21 02:26:46 +03:00
committed by GitHub
parent 92eaa34277
commit 36976ecb43
10 changed files with 840 additions and 441 deletions
+76
View File
@@ -0,0 +1,76 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2025 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#include "SDL_internal.h"
#ifdef HAVE_LIBTHAI_H
#include "SDL_libthai.h"
#ifdef SDL_LIBTHAI_DYNAMIC
SDL_ELF_NOTE_DLOPEN(
"Thai",
"Thai language support",
SDL_ELF_NOTE_DLOPEN_PRIORITY_SUGGESTED,
SDL_LIBTHAI_DYNAMIC
);
#endif
SDL_LibThai *SDL_LibThai_Create(void)
{
SDL_LibThai *th;
th = (SDL_LibThai *)SDL_malloc(sizeof(SDL_LibThai));
if (!th) {
return NULL;
}
#ifdef SDL_LIBTHAI_DYNAMIC
#define SDL_LIBTHAI_LOAD_SYM(a, x, n, t) x = ((t)SDL_LoadFunction(a->lib, n)); if (!x) { SDL_UnloadObject(a->lib); SDL_free(a); return NULL; }
th->lib = SDL_LoadObject(SDL_LIBTHAI_DYNAMIC);
if (!th->lib) {
SDL_free(th);
return NULL;
}
SDL_LIBTHAI_LOAD_SYM(th, th->make_cells, "th_make_cells", SDL_LibThaiMakeCells);
#else
th->make_cells = th_make_cells;
#endif
return th;
}
void SDL_LibThai_Destroy(SDL_LibThai *th)
{
if (!th) {
return;
}
#ifdef SDL_LIBTHAI_DYNAMIC
SDL_UnloadObject(th->lib);
#endif
SDL_free(th);
}
#endif
+43
View File
@@ -0,0 +1,43 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2025 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#include "SDL_internal.h"
#ifndef SDL_libthai_h_
#define SDL_libthai_h_
#ifdef HAVE_LIBTHAI_H
#include <thai/thcell.h>
typedef size_t (*SDL_LibThaiMakeCells)(const thchar_t *s, size_t, struct thcell_t cells[], size_t *, int);
typedef struct SDL_LibThai {
SDL_SharedObject *lib;
SDL_LibThaiMakeCells make_cells;
} SDL_LibThai;
extern SDL_LibThai *SDL_LibThai_Create(void);
extern void SDL_LibThai_Destroy(SDL_LibThai *th);
#endif // HAVE_LIBTHAI_H
#endif // SDL_libthai_h_