Use binary font headerfile instead of ttf file

This commit is contained in:
dijunkun
2024-06-28 10:01:34 +08:00
parent ad6f2c2c70
commit 3f717f1df2
4 changed files with 768005 additions and 5683 deletions

768001
fonts/OPPOSans-Regular.h Normal file

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

Binary file not shown.

View File

@@ -5,8 +5,8 @@
#include <string> #include <string>
#include "IconsFontAwesome6.h" #include "IconsFontAwesome6.h"
#include "OPPOSans-Regular.h"
#include "device_controller_factory.h" #include "device_controller_factory.h"
#include "fa-regular-400.h"
#include "fa-solid-900.h" #include "fa-solid-900.h"
#include "layout_style.h" #include "layout_style.h"
#include "localization.h" #include "localization.h"
@@ -226,31 +226,10 @@ int Render::Run() {
io.ConfigFlags |= io.ConfigFlags |=
ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls
if (config_center_.GetLanguage() == ConfigCenter::LANGUAGE::CHINESE) {
// Load Fonts // Load Fonts
#ifdef _WIN32 io.Fonts->AddFontFromMemoryTTF(OPPOSans_Regular_ttf,
std::string default_font_path = "fonts/OPPOSans-Regular.ttf"; sizeof(OPPOSans_Regular_ttf), 32.0f, NULL,
// std::string default_font_path = "c:/windows/fonts/simhei.ttf";
std::ifstream font_path_f(default_font_path.c_str());
std::string font_path = font_path_f.good() ? default_font_path : "";
if (!font_path.empty()) {
io.Fonts->AddFontFromFileTTF(font_path.c_str(), 32.0f, NULL,
io.Fonts->GetGlyphRangesChineseFull()); io.Fonts->GetGlyphRangesChineseFull());
}
#elif __APPLE__
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());
#endif
}
ImFontConfig config; ImFontConfig config;
config.MergeMode = true; config.MergeMode = true;