Added variables to build SDL2_ttf with HarfBuzz and added functions to
the engine to support defining the text direction and script name
This commit is contained in:
1 parent
e04effec37
commit
79944cfa13
3 files changed
+37
No files matched your search
Vendored
+2
@@ -6,6 +6,8 @@ set(SDL2_DISABLE_UNINSTALL OFF CACHE BOOL "" FORCE)
|
||||
set(SDL2IMAGE_VENDORED ON CACHE BOOL "" FORCE)
|
||||
set(SDL2MIXER_VENDORED ON CACHE BOOL "" FORCE)
|
||||
set(SDL2TTF_VENDORED ON CACHE BOOL "" FORCE)
|
||||
set(SDL2TTF_HARFBUZZ ON CACHE BOOL "" FORCE)
|
||||
set(TTF_USE_HARFBUZZ ON CACHE BOOL "" FORCE)
|
||||
set(SDL2IMAGE_TIF ON CACHE BOOL "" FORCE)
|
||||
|
||||
add_subdirectory(SDL)
|
||||
|
||||
@@ -14,6 +14,13 @@
|
||||
extern "C" {
|
||||
#endif // !__cplusplus
|
||||
|
||||
typedef enum {
|
||||
FONT_DIRECTION_LTR = TTF_DIRECTION_LTR,
|
||||
FONT_DIRECTION_RTL = TTF_DIRECTION_RTL,
|
||||
FONT_DIRECTION_TTB = TTF_DIRECTION_TTB,
|
||||
FONT_DIRECTION_BTT = TTF_DIRECTION_BTT,
|
||||
} FontDirection;
|
||||
|
||||
// GENERAL ENGINE API
|
||||
|
||||
/**
|
||||
@@ -80,6 +87,8 @@ TextSize get_text_size_from_font_asset(AssetID id, const char *text);
|
||||
void render_text_with_font_asset(AssetID id, const char *text, f32 x, f32 y,
|
||||
SDL_Color color);
|
||||
void set_font_asset_size(AssetID id, u32 size);
|
||||
i32 set_font_direction(AssetID id, FontDirection direction);
|
||||
i32 set_font_script_name(AssetID id, const char *script);
|
||||
// END RENDERING API
|
||||
|
||||
// AUDIO API
|
||||
|
||||
@@ -413,6 +413,32 @@ void set_font_asset_size(AssetID id, u32 size) {
|
||||
TTF_SetFontSize(font, size);
|
||||
}
|
||||
|
||||
i32 set_font_direction(AssetID id, FontDirection direction) {
|
||||
if (id < 0) {
|
||||
return -2;
|
||||
}
|
||||
|
||||
TTF_Font *font = get_font(GameEngine.asset_manager, id);
|
||||
if (!font) {
|
||||
return -2;
|
||||
}
|
||||
|
||||
return TTF_SetFontDirection(font, (TTF_Direction)direction);
|
||||
}
|
||||
|
||||
i32 set_font_script_name(AssetID id, const char *script) {
|
||||
if (id < 0) {
|
||||
return -2;
|
||||
}
|
||||
|
||||
TTF_Font *font = get_font(GameEngine.asset_manager, id);
|
||||
if (!font) {
|
||||
return -2;
|
||||
}
|
||||
|
||||
return TTF_SetFontScriptName(font, script);
|
||||
}
|
||||
|
||||
i8 play_audio_asset(AssetID id, i16 loops, bool fade_in,
|
||||
u32 fade_length_in_ms) {
|
||||
if (id < 0) {
|
||||
|
||||
Reference in new issue
Block a user