From 759078ef7f2a7786398fa2530df2c907c6f40c4c Mon Sep 17 00:00:00 2001 From: dijunkun Date: Tue, 28 May 2024 15:25:16 +0800 Subject: [PATCH] 1.Use PingFang.ttc as Chinese default fonts on MacOS;2.Fix link error for FFmpeg --- src/gui/main.cpp | 30 ++++++++++++++++++------------ thirdparty/projectx | 2 +- xmake.lua | 5 +++++ 3 files changed, 24 insertions(+), 13 deletions(-) diff --git a/src/gui/main.cpp b/src/gui/main.cpp index 05ad6df..fff8fae 100644 --- a/src/gui/main.cpp +++ b/src/gui/main.cpp @@ -453,8 +453,14 @@ int main(int argc, char *argv[]) { io.Fonts->GetGlyphRangesChineseFull()); } #elif __APPLE__ - io.Fonts->AddFontFromFileTTF("c:/windows/fonts/msyh.ttc", 13.0f, NULL, - io.Fonts->GetGlyphRangesChineseFull()); + std::string default_font_path = "/System/Library/Fonts/PingFang.ttc"; + std::ifstream font_path_f(default_font_path.c_str()); + std::string font_path = + font_path_f.good() ? "/System/Library/Fonts/PingFang.ttc" : ""; + if (!font_path.empty()) { + io.Fonts->AddFontFromFileTTF(font_path.c_str(), 13.0f, NULL, + io.Fonts->GetGlyphRangesChineseFull()); + } #elif __linux__ io.Fonts->AddFontFromFileTTF("c:/windows/fonts/msyh.ttc", 13.0f, NULL, io.Fonts->GetGlyphRangesChineseFull()); @@ -609,7 +615,7 @@ int main(int argc, char *argv[]) { #endif #if CHINESE_FONT - ImGui::Begin(u8"菜单", nullptr, + ImGui::Begin(u8"鑿滃崟", nullptr, ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoMove); #else @@ -619,7 +625,7 @@ int main(int argc, char *argv[]) { { menu_hovered = ImGui::IsWindowHovered(); #if CHINESE_FONT - ImGui::Text(u8"本机ID:"); + ImGui::Text(u8"鏈満ID:"); #else ImGui::Text("LOCAL ID:"); #endif @@ -636,7 +642,7 @@ int main(int argc, char *argv[]) { ImGuiInputTextFlags_CharsUppercase | ImGuiInputTextFlags_ReadOnly); #if CHINESE_FONT - ImGui::Text(u8"密码:"); + ImGui::Text(u8"瀵嗙爜:"); #else ImGui::Text("PASSWORD:"); #endif @@ -647,7 +653,7 @@ int main(int argc, char *argv[]) { ImGui::SetNextItemWidth(90); #if CHINESE_FONT ImGui::SetCursorPosX(60.0f); - ImGui::InputTextWithHint("##server_pwd", u8"最长6个字符", + ImGui::InputTextWithHint("##server_pwd", u8"鏈闀6涓瓧绗", input_password, IM_ARRAYSIZE(input_password), ImGuiInputTextFlags_CharsNoBlank); #else @@ -678,7 +684,7 @@ int main(int argc, char *argv[]) { { static char remote_id[20] = ""; #if CHINESE_FONT - ImGui::Text(u8"远端ID:"); + ImGui::Text(u8"杩滅ID:"); #else ImGui::Text("REMOTE ID:"); #endif @@ -697,7 +703,7 @@ int main(int argc, char *argv[]) { ImGui::Spacing(); #if CHINESE_FONT - ImGui::Text(u8"密码:"); + ImGui::Text(u8"瀵嗙爜:"); #else ImGui::Text("PASSWORD:"); #endif @@ -706,7 +712,7 @@ int main(int argc, char *argv[]) { static char client_password[20] = ""; #if CHINESE_FONT ImGui::SetCursorPosX(60.0f); - ImGui::InputTextWithHint("##client_pwd", u8"最长6个字符", + ImGui::InputTextWithHint("##client_pwd", u8"鏈闀6涓瓧绗", client_password, IM_ARRAYSIZE(client_password), ImGuiInputTextFlags_CharsNoBlank); @@ -722,7 +728,7 @@ int main(int argc, char *argv[]) { ImGui::Separator(); ImGui::Spacing(); #if CHINESE_FONT - if (ImGui::Button(u8"连接")) { + if (ImGui::Button(u8"杩炴帴")) { #else if (ImGui::Button("Connect")) { #endif @@ -762,7 +768,7 @@ int main(int argc, char *argv[]) { { #if CHINESE_FONT - if (ImGui::Button(u8"重置窗口")) { + if (ImGui::Button(u8"閲嶇疆绐楀彛")) { #else if (ImGui::Button("Resize Window")) { #endif @@ -779,7 +785,7 @@ int main(int argc, char *argv[]) { ImGui::SameLine(); #if CHINESE_FONT - if (ImGui::Button(u8"全屏")) { + if (ImGui::Button(u8"鍏ㄥ睆")) { #else if (ImGui::Button("FULLSCREEN")) { #endif diff --git a/thirdparty/projectx b/thirdparty/projectx index 5deb52c..5d68612 160000 --- a/thirdparty/projectx +++ b/thirdparty/projectx @@ -1 +1 @@ -Subproject commit 5deb52ce2d5bc6179b46f899db5ebf92e810ed1e +Subproject commit 5d6861233e54e290c559ca679401b32bd6a95e79 diff --git a/xmake.lua b/xmake.lua index dea9b13..db6ea4e 100644 --- a/xmake.lua +++ b/xmake.lua @@ -92,6 +92,11 @@ target("device_controller") target("remote_desk") set_kind("binary") add_deps("log", "common", "screen_capturer", "device_controller", "projectx") + if is_os("macosx") then + add_packages("ffmpeg") + elseif is_os("linux") then + add_packages("ffmpeg") + end add_files("src/gui/main.cpp") -- after_install(function (target)