mirror of
https://github.com/Detanup01/gbe_fork.git
synced 2024-12-28 03:14:15 +08:00
allow load custom ttf
This commit is contained in:
parent
ac709e78e6
commit
bfdca710f4
@ -112,6 +112,8 @@ struct Overlay_Appearance {
|
||||
|
||||
constexpr const static NotificationPosition default_pos = NotificationPosition::top_right;
|
||||
|
||||
std::filesystem::path font_override;
|
||||
|
||||
float font_size = 16.0f;
|
||||
float icon_size = 64.0f;
|
||||
|
||||
|
@ -71,7 +71,7 @@ static void load_subscribed_groups_clans(std::string clans_filepath, Settings *s
|
||||
}
|
||||
}
|
||||
|
||||
static void load_overlay_appearance(std::string appearance_filepath, Settings *settings_client, Settings *settings_server)
|
||||
static void load_overlay_appearance(std::string appearance_filepath, Settings *settings_client, Settings *settings_server, std::string &program_path)
|
||||
{
|
||||
std::ifstream appearance_file(utf8_decode(appearance_filepath));
|
||||
if (appearance_file.is_open()) {
|
||||
@ -101,7 +101,13 @@ static void load_overlay_appearance(std::string appearance_filepath, Settings *s
|
||||
|
||||
PRINT_DEBUG(" Overlay appearance line '%s' = '%s'\n", name.c_str(), value.c_str());
|
||||
try {
|
||||
if (name.compare("Font_Size") == 0) {
|
||||
if (name.compare("Font_Override") == 0) {
|
||||
std::filesystem::path nfont_override = value;
|
||||
if (nfont_override.is_relative())
|
||||
nfont_override = program_path / nfont_override;
|
||||
settings_client->overlay_appearance.font_override = nfont_override;
|
||||
settings_server->overlay_appearance.font_override = nfont_override;
|
||||
} else if (name.compare("Font_Size") == 0) {
|
||||
float nfont_size = std::stof(value, NULL);
|
||||
settings_client->overlay_appearance.font_size = nfont_size;
|
||||
settings_server->overlay_appearance.font_size = nfont_size;
|
||||
@ -1413,8 +1419,8 @@ uint32 create_localstorage_settings(Settings **settings_client_out, Settings **s
|
||||
load_subscribed_groups_clans(local_storage->get_global_settings_path() + "subscribed_groups_clans.txt", settings_client, settings_server);
|
||||
load_subscribed_groups_clans(Local_Storage::get_game_settings_path() + "subscribed_groups_clans.txt", settings_client, settings_server);
|
||||
|
||||
load_overlay_appearance(local_storage->get_global_settings_path() + "overlay_appearance.txt", settings_client, settings_server);
|
||||
load_overlay_appearance(Local_Storage::get_game_settings_path() + "overlay_appearance.txt", settings_client, settings_server);
|
||||
load_overlay_appearance(local_storage->get_global_settings_path() + "overlay_appearance.txt", settings_client, settings_server, program_path);
|
||||
load_overlay_appearance(Local_Storage::get_game_settings_path() + "overlay_appearance.txt", settings_client, settings_server, program_path);
|
||||
|
||||
parse_mods_folder(settings_client, settings_server, local_storage);
|
||||
load_gamecontroller_settings(settings_client);
|
||||
|
@ -232,7 +232,7 @@ void Steam_Overlay::create_fonts()
|
||||
fonts_atlas.Flags |= ImFontAtlasFlags_NoPowerOfTwoHeight;
|
||||
|
||||
float font_size = settings->overlay_appearance.font_size;
|
||||
|
||||
|
||||
static ImFontConfig font_cfg{};
|
||||
font_cfg.FontDataOwnedByAtlas = false; // https://github.com/ocornut/imgui/blob/master/docs/FONTS.md#loading-font-data-from-memory
|
||||
font_cfg.PixelSnapH = true;
|
||||
@ -294,7 +294,14 @@ void Steam_Overlay::create_fonts()
|
||||
font_builder.BuildRanges(&ranges);
|
||||
font_cfg.GlyphRanges = ranges.Data;
|
||||
|
||||
fonts_atlas.AddFontDefault(&font_cfg);
|
||||
std::filesystem::path font_override = settings->overlay_appearance.font_override;
|
||||
if (std::filesystem::exists(font_override)) {
|
||||
fonts_atlas.AddFontFromFileTTF(font_override.string().c_str(), font_size, &font_cfg);
|
||||
font_cfg.MergeMode = true; // merge next fonts into the first one, as if they were all just 1 font file
|
||||
} else {
|
||||
PRINT_DEBUG("Steam_Overlay::create_fonts override font not exists. %s\n", font_override.c_str());
|
||||
}
|
||||
|
||||
ImFont *font = fonts_atlas.AddFontFromMemoryCompressedTTF(unifont_compressed_data, unifont_compressed_size, font_size, &font_cfg);
|
||||
font_notif = font_default = font;
|
||||
|
||||
|
@ -1,6 +1,10 @@
|
||||
; override font path
|
||||
Font_Override unifont.ttf
|
||||
|
||||
; global font size
|
||||
; multiples of 16 is recommended, e.g. 16 32...
|
||||
; for built-in font, multiple of 16 is recommended. e.g. 16 32...
|
||||
Font_Size 16.0
|
||||
|
||||
; achievement icon size
|
||||
Icon_Size 64.0
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user