mirror of
https://github.com/cemu-project/Cemu.git
synced 2024-11-22 17:19:18 +01:00
Non-windows: Link fontawesome into executable. (#442)
This commit is contained in:
parent
c3182aedd9
commit
dfa7774c4c
@ -43,6 +43,10 @@ void ImRotateEnd(float rad, ImVec2 center)
|
||||
uint8* extractCafeDefaultFont(sint32* size);
|
||||
sint32 g_font_size = 0;
|
||||
uint8* g_font_data = nullptr;
|
||||
#if !BOOST_OS_WINDOWS
|
||||
extern int const g_fontawesome_size;
|
||||
extern char const g_fontawesome_data[];
|
||||
#endif
|
||||
std::unordered_map<int, ImFont*> g_imgui_fonts;
|
||||
std::stack<int> g_font_requests;
|
||||
|
||||
@ -66,6 +70,14 @@ void ImGui_PrecacheFonts()
|
||||
//cfg.SizePixels = size;
|
||||
ImFont* font = io.Fonts->AddFontFromMemoryTTF(g_font_data, g_font_size, (float)size, &cfg);
|
||||
|
||||
ImFontConfig cfgmerge{};
|
||||
cfgmerge.FontDataOwnedByAtlas = false;
|
||||
cfgmerge.MergeMode = true;
|
||||
cfgmerge.GlyphMinAdvanceX = 20.0f;
|
||||
//cfgmerge.GlyphOffset = { 2,2 };
|
||||
|
||||
static const ImWchar icon_ranges[] = { ICON_MIN_FA, ICON_MAX_FA, 0 };
|
||||
|
||||
#if BOOST_OS_WINDOWS
|
||||
const auto hinstance = GetModuleHandle(nullptr);
|
||||
const HRSRC res = FindResource(hinstance, MAKEINTRESOURCE(IDR_FONTAWESOME), RT_RCDATA);
|
||||
@ -77,16 +89,11 @@ void ImGui_PrecacheFonts()
|
||||
void* data = LockResource(mem);
|
||||
const size_t len = SizeofResource(hinstance, res);
|
||||
|
||||
ImFontConfig cfgmerge{};
|
||||
cfgmerge.FontDataOwnedByAtlas = false;
|
||||
cfgmerge.MergeMode = true;
|
||||
cfgmerge.GlyphMinAdvanceX = 20.0f;
|
||||
//cfgmerge.GlyphOffset = { 2,2 };
|
||||
|
||||
static const ImWchar icon_ranges[] = { ICON_MIN_FA, ICON_MAX_FA, 0 };
|
||||
io.Fonts->AddFontFromMemoryTTF(data, (int)len, (float)size, &cfgmerge, icon_ranges);
|
||||
}
|
||||
}
|
||||
#else
|
||||
io.Fonts->AddFontFromMemoryTTF((void*)g_fontawesome_data, (int)g_fontawesome_size, (float)size, &cfgmerge, icon_ranges);
|
||||
#endif
|
||||
|
||||
g_imgui_fonts[(int)size] = font;
|
||||
|
@ -2,12 +2,22 @@ add_library(CemuResource)
|
||||
|
||||
set_property(TARGET CemuResource PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
|
||||
|
||||
enable_language(ASM)
|
||||
|
||||
# icon resources
|
||||
target_sources(CemuResource PRIVATE
|
||||
embedded/resources.cpp
|
||||
embedded/resources.h
|
||||
)
|
||||
|
||||
if(UNIX)
|
||||
if(NOT APPLE)
|
||||
target_sources(CemuResource PRIVATE embedded/fontawesome.S)
|
||||
else()
|
||||
target_sources(CemuResource PRIVATE embedded/fontawesome_macos.S)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
target_sources(CemuResource PRIVATE CafeDefaultFont.cpp)
|
||||
|
||||
target_include_directories(CemuResource PUBLIC "../")
|
||||
|
8
src/resource/embedded/fontawesome.S
Normal file
8
src/resource/embedded/fontawesome.S
Normal file
@ -0,0 +1,8 @@
|
||||
.section .text
|
||||
.global g_fontawesome_data, g_fontawesome_size
|
||||
|
||||
g_fontawesome_data:
|
||||
.incbin "fontawesome-webfont.ttf"
|
||||
g_fontawesome_size:
|
||||
.int g_fontawesome_size - g_fontawesome_data
|
||||
|
8
src/resource/embedded/fontawesome_macos.S
Normal file
8
src/resource/embedded/fontawesome_macos.S
Normal file
@ -0,0 +1,8 @@
|
||||
.section __DATA, __const
|
||||
.global _g_fontawesome_data, _g_fontawesome_size
|
||||
|
||||
_g_fontawesome_data:
|
||||
.incbin "fontawesome-webfont.ttf"
|
||||
_g_fontawesome_size:
|
||||
.int _g_fontawesome_size - _g_fontawesome_data
|
||||
|
Loading…
Reference in New Issue
Block a user