Merge pull request #18170 from hch12907/sdl-ttf
ci: use pkgconfig as a fallback for finding SDL2_ttf
This commit is contained in:
commit
3aed81d51b
3 changed files with 18 additions and 4 deletions
2
.github/workflows/build.yml
vendored
2
.github/workflows/build.yml
vendored
|
@ -333,7 +333,7 @@ jobs:
|
||||||
run: |
|
run: |
|
||||||
sudo add-apt-repository -y "deb http://archive.ubuntu.com/ubuntu `lsb_release -sc` main universe restricted multiverse"
|
sudo add-apt-repository -y "deb http://archive.ubuntu.com/ubuntu `lsb_release -sc` main universe restricted multiverse"
|
||||||
sudo apt-get update -y -qq
|
sudo apt-get update -y -qq
|
||||||
sudo apt-get install libsdl2-dev libgl1-mesa-dev libglu1-mesa-dev
|
sudo apt-get install libsdl2-dev libgl1-mesa-dev libglu1-mesa-dev libsdl2-ttf-dev libfontconfig1-dev
|
||||||
|
|
||||||
- name: Install macOS dependencies
|
- name: Install macOS dependencies
|
||||||
if: runner.os == 'macOS'
|
if: runner.os == 'macOS'
|
||||||
|
|
|
@ -261,6 +261,14 @@ if(NOT LIBRETRO AND NOT IOS AND NOT MACOSX)
|
||||||
find_package(SDL2)
|
find_package(SDL2)
|
||||||
find_package(SDL2_ttf)
|
find_package(SDL2_ttf)
|
||||||
find_package(Fontconfig)
|
find_package(Fontconfig)
|
||||||
|
|
||||||
|
# TODO: this can be removed once CI supports newer SDL2_ttf
|
||||||
|
if (NOT SDL2_ttf_FOUND)
|
||||||
|
find_package(PkgConfig)
|
||||||
|
if(PkgConfig_FOUND)
|
||||||
|
pkg_check_modules(SDL2_ttf_PKGCONFIG IMPORTED_TARGET SDL2_ttf)
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(MACOSX AND NOT IOS)
|
if(MACOSX AND NOT IOS)
|
||||||
|
@ -1335,15 +1343,19 @@ else()
|
||||||
SDL/SDLVulkanGraphicsContext.cpp
|
SDL/SDLVulkanGraphicsContext.cpp
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
if(SDL2_ttf_FOUND)
|
if(SDL2_ttf_FOUND OR SDL2_ttf_PKGCONFIG_FOUND)
|
||||||
add_definitions(-DUSE_SDL2_TTF)
|
add_definitions(-DUSE_SDL2_TTF)
|
||||||
set(nativeExtraLibs ${nativeExtraLibs} SDL2_ttf::SDL2_ttf)
|
|
||||||
|
|
||||||
if(FONTCONFIG_FOUND)
|
if(FONTCONFIG_FOUND)
|
||||||
add_definitions(-DUSE_SDL2_TTF_FONTCONFIG)
|
add_definitions(-DUSE_SDL2_TTF_FONTCONFIG)
|
||||||
set(nativeExtraLibs ${nativeExtraLibs} Fontconfig::Fontconfig)
|
set(nativeExtraLibs ${nativeExtraLibs} Fontconfig::Fontconfig)
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
if(SDL2_ttf_FOUND)
|
||||||
|
set(nativeExtraLibs ${nativeExtraLibs} SDL2_ttf::SDL2_ttf)
|
||||||
|
elseif(SDL2_ttf_PKGCONFIG_FOUND)
|
||||||
|
add_definitions(-DUSE_SDL2_TTF_PKGCONFIG)
|
||||||
|
set(nativeExtraLibs ${nativeExtraLibs} PkgConfig::SDL2_ttf_PKGCONFIG)
|
||||||
|
endif()
|
||||||
if(APPLE)
|
if(APPLE)
|
||||||
set(nativeExtra ${nativeExtra}
|
set(nativeExtra ${nativeExtra}
|
||||||
SDL/SDLMain.h
|
SDL/SDLMain.h
|
||||||
|
|
|
@ -378,12 +378,14 @@ void TextDrawerSDL::DrawStringBitmap(std::vector<uint8_t> &bitmapData, TextStrin
|
||||||
font = fallbackFonts_[0];
|
font = fallbackFonts_[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef USE_SDL2_TTF_PKGCONFIG
|
||||||
if (align & ALIGN_HCENTER)
|
if (align & ALIGN_HCENTER)
|
||||||
TTF_SetFontWrappedAlign(font, TTF_WRAPPED_ALIGN_CENTER);
|
TTF_SetFontWrappedAlign(font, TTF_WRAPPED_ALIGN_CENTER);
|
||||||
else if (align & ALIGN_RIGHT)
|
else if (align & ALIGN_RIGHT)
|
||||||
TTF_SetFontWrappedAlign(font, TTF_WRAPPED_ALIGN_RIGHT);
|
TTF_SetFontWrappedAlign(font, TTF_WRAPPED_ALIGN_RIGHT);
|
||||||
else
|
else
|
||||||
TTF_SetFontWrappedAlign(font, TTF_WRAPPED_ALIGN_LEFT);
|
TTF_SetFontWrappedAlign(font, TTF_WRAPPED_ALIGN_LEFT);
|
||||||
|
#endif
|
||||||
|
|
||||||
SDL_Color fgColor = { 0xFF, 0xFF, 0xFF, 0xFF };
|
SDL_Color fgColor = { 0xFF, 0xFF, 0xFF, 0xFF };
|
||||||
SDL_Surface *text = TTF_RenderUTF8_Blended_Wrapped(font, processedStr.c_str(), fgColor, 0);
|
SDL_Surface *text = TTF_RenderUTF8_Blended_Wrapped(font, processedStr.c_str(), fgColor, 0);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue