USE_PRIVATE_FONTS

This commit is contained in:
SoftFever 2023-04-10 20:44:20 +08:00
parent ef3614a21a
commit 07d048ef36
2 changed files with 10 additions and 9 deletions

View File

@ -1,15 +1,13 @@
set(_wx_git_tag v3.1.5) set(_wx_git_tag v3.1.5)
set(_wx_toolkit "") set(_wx_toolkit "")
if(CMAKE_SYSTEM_NAME STREQUAL "Linux") set(_wx_private_font "-DwxUSE_PRIVATE_FONTS=1")
if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
set(_gtk_ver 2) set(_gtk_ver 2)
if (DEP_WX_GTK3) if (DEP_WX_GTK3)
set(_gtk_ver 3) set(_gtk_ver 3)
endif () endif ()
set(_wx_toolkit "-DwxBUILD_TOOLKIT=gtk${_gtk_ver}") set(_wx_toolkit "-DwxBUILD_TOOLKIT=gtk${_gtk_ver}")
set(_wx_private_font "-DwxUSE_PRIVATE_FONTS=1")
else ()
set(_wx_private_font "-DwxUSE_PRIVATE_FONTS=0")
endif() endif()
if (MSVC) if (MSVC)
@ -19,7 +17,7 @@ else ()
endif () endif ()
if (MSVC) if (MSVC)
set(_patch_cmd ${PATCH_CMD} ${CMAKE_CURRENT_LIST_DIR}/0001-wxWidget-fix.patch) # set(_patch_cmd ${PATCH_CMD} ${CMAKE_CURRENT_LIST_DIR}/0001-wxWidget-fix.patch)
else () else ()
set(_patch_cmd test -f WXWIDGETS_PATCHED || ${PATCH_CMD} ${CMAKE_CURRENT_LIST_DIR}/0001-wxWidget-fix.patch && touch WXWIDGETS_PATCHED) set(_patch_cmd test -f WXWIDGETS_PATCHED || ${PATCH_CMD} ${CMAKE_CURRENT_LIST_DIR}/0001-wxWidget-fix.patch && touch WXWIDGETS_PATCHED)
endif () endif ()

View File

@ -15,9 +15,12 @@ wxFont Label::sysFont(int size, bool bold)
wxFont font{size, wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL, bold ? wxFONTWEIGHT_BOLD : wxFONTWEIGHT_NORMAL, false, face}; wxFont font{size, wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL, bold ? wxFONTWEIGHT_BOLD : wxFONTWEIGHT_NORMAL, false, face};
font.SetFaceName(face); font.SetFaceName(face);
if (!font.IsOk()) { if (!font.IsOk()) {
font = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT); BOOST_LOG_TRIVIAL(warning) << boost::format("Cann't find HarmonyOS Sans SC font");
if (bold) font.MakeBold(); font = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT);
font.SetPointSize(size); BOOST_LOG_TRIVIAL(warning) << boost::format("Use system font instead: %1%") % font.GetFaceName();
if (bold)
font.MakeBold();
font.SetPointSize(size);
} }
return font; return font;
} }
@ -44,7 +47,7 @@ wxFont Label::Body_9;
void Label::initSysFont() void Label::initSysFont()
{ {
#ifdef __linux__ #if defined(__linux__) || defined(_WIN32)
const std::string& resource_path = Slic3r::resources_dir(); const std::string& resource_path = Slic3r::resources_dir();
wxString font_path = wxString::FromUTF8(resource_path+"/fonts/HarmonyOS_Sans_SC_Bold.ttf"); wxString font_path = wxString::FromUTF8(resource_path+"/fonts/HarmonyOS_Sans_SC_Bold.ttf");
bool result = wxFont::AddPrivateFont(font_path); bool result = wxFont::AddPrivateFont(font_path);