* load overlay fonts with relative paths from steam_settings\fonts

* remove invalid parameters from `overlay_appearance.txt`
* example funny font!
This commit is contained in:
otavepto 2024-04-03 20:20:14 +02:00
parent 8b0f40deb2
commit 5ddbfccfdd
7 changed files with 125 additions and 27 deletions

View File

@ -1,3 +1,5 @@
# 2024/4/3
* **[detiam]** fix linking errors when building on archlinux
* **[detiam]** optimize Linux deps build script:
- new argument `-packages_skip`: allows skipping installation of distro packages, such as `build-essential`, `gcc-multilib`, etc...
@ -9,6 +11,7 @@
* **[detiam]** enhanced the overlay font
- replace the builtin font with `Unifont`
- allow loading a custom font whose location is defined in `overlay_appearance.txt`
fonts with relative paths will be loaded from `steam_settings\fonts`
* allow sharing leaderboards scores with connected players, adjust players ranks locally, and sort entries as needed by the game, suggested by **[M4RCK5]**
this will only work when people connected on the same network are playing the same game, once they disconnect their leaderboard entry will be lost (no data persistence for other players), also it doesn't work well with VPN clients.
this behavior could be enabled via `share_leaderboards_over_network.txt`
@ -17,7 +20,7 @@
you can also create `immediate_gameserver_stats.txt` to sync data immediately, but **not recommended**
* for windows: updated stub drm patterns and added a workaround for older variants,
this increases the compatibility, but makes it easier to be detected
* for windows: new stub/mock dll `GameOverlayRenderer(64).dll` for the experiemntal cold client setup,
* for windows: new stub/mock dll `GameOverlayRenderer(64).dll` for the experimental cold client setup,
some apps verify the existence of this dll, either on disk, or inside their memory space.
**not recommended** to ignore it
* separated the config file `disable_leaderboards_create_unknown.txt`, previously it was tied to `leaderboards.txt`,

View File

@ -112,9 +112,9 @@ struct Overlay_Appearance {
constexpr const static NotificationPosition default_pos = NotificationPosition::top_right;
std::filesystem::path font_override;
std::string font_override{}; // path to a custom user-provided font
float font_size = 16.0f;
float icon_size = 64.0f;
float font_glyph_extra_spacing_x = 1.0f;

View File

@ -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, std::string &program_path)
static void load_overlay_appearance(std::string appearance_filepath, Settings *settings_client, Settings *settings_server)
{
std::ifstream appearance_file(utf8_decode(appearance_filepath));
if (appearance_file.is_open()) {
@ -102,11 +102,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_Override") == 0) {
std::filesystem::path nfont_override = value;
if (nfont_override.is_relative())
nfont_override = program_path / nfont_override;
std::string nfont_override(common_helpers::to_absolute(value, Local_Storage::get_game_settings_path() + "fonts"));
if (common_helpers::file_exist(nfont_override)) {
settings_client->overlay_appearance.font_override = nfont_override;
settings_server->overlay_appearance.font_override = nfont_override;
} else {
PRINT_DEBUG(" ERROR font file '%s' doesn't exist and will be ignored\n", nfont_override.c_str());
}
} else if (name.compare("Font_Size") == 0) {
float nfont_size = std::stof(value, NULL);
settings_client->overlay_appearance.font_size = nfont_size;
@ -1419,8 +1421,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, program_path);
load_overlay_appearance(Local_Storage::get_game_settings_path() + "overlay_appearance.txt", settings_client, settings_server, program_path);
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);
parse_mods_folder(settings_client, settings_server, local_storage);
load_gamecontroller_settings(settings_client);

View File

@ -244,9 +244,9 @@ void Steam_Overlay::create_fonts()
font_cfg.GlyphExtraSpacing.y = settings->overlay_appearance.font_glyph_extra_spacing_y;
static ImFontGlyphRangesBuilder font_builder{};
for (auto &x : achievements) {
font_builder.AddText(x.title.c_str());
font_builder.AddText(x.description.c_str());
for (const auto &ach : achievements) {
font_builder.AddText(ach.title.c_str());
font_builder.AddText(ach.description.c_str());
}
for (int i = 0; i < TRANSLATION_NUMBER_OF_LANGUAGES; i++) {
font_builder.AddText(translationChat[i]);
@ -294,14 +294,12 @@ void Steam_Overlay::create_fonts()
font_builder.BuildRanges(&ranges);
font_cfg.GlyphRanges = ranges.Data;
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);
if (settings->overlay_appearance.font_override.size()) {
fonts_atlas.AddFontFromFileTTF(settings->overlay_appearance.font_override.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());
}
// note: base85 compressed arrays caused a compiler heap allocation error, regular compression is more guaranteed
ImFont *font = fonts_atlas.AddFontFromMemoryCompressedTTF(unifont_compressed_data, unifont_compressed_size, font_size, &font_cfg);
font_notif = font_default = font;

View File

@ -0,0 +1,93 @@
Copyright 2008 The Bungee Project Authors (david@djr.com)
This Font Software is licensed under the SIL Open Font License, Version 1.1.
This license is copied below, and is also available with a FAQ at:
https://openfontlicense.org
-----------------------------------------------------------
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
-----------------------------------------------------------
PREAMBLE
The goals of the Open Font License (OFL) are to stimulate worldwide
development of collaborative font projects, to support the font creation
efforts of academic and linguistic communities, and to provide a free and
open framework in which fonts may be shared and improved in partnership
with others.
The OFL allows the licensed fonts to be used, studied, modified and
redistributed freely as long as they are not sold by themselves. The
fonts, including any derivative works, can be bundled, embedded,
redistributed and/or sold with any software provided that any reserved
names are not used by derivative works. The fonts and derivatives,
however, cannot be released under any other type of license. The
requirement for fonts to remain under this license does not apply
to any document created using the fonts or their derivatives.
DEFINITIONS
"Font Software" refers to the set of files released by the Copyright
Holder(s) under this license and clearly marked as such. This may
include source files, build scripts and documentation.
"Reserved Font Name" refers to any names specified as such after the
copyright statement(s).
"Original Version" refers to the collection of Font Software components as
distributed by the Copyright Holder(s).
"Modified Version" refers to any derivative made by adding to, deleting,
or substituting -- in part or in whole -- any of the components of the
Original Version, by changing formats or by porting the Font Software to a
new environment.
"Author" refers to any designer, engineer, programmer, technical
writer or other person who contributed to the Font Software.
PERMISSION & CONDITIONS
Permission is hereby granted, free of charge, to any person obtaining
a copy of the Font Software, to use, study, copy, merge, embed, modify,
redistribute, and sell modified and unmodified copies of the Font
Software, subject to the following conditions:
1) Neither the Font Software nor any of its individual components,
in Original or Modified Versions, may be sold by itself.
2) Original or Modified Versions of the Font Software may be bundled,
redistributed and/or sold with any software, provided that each copy
contains the above copyright notice and this license. These can be
included either as stand-alone text files, human-readable headers or
in the appropriate machine-readable metadata fields within text or
binary files as long as those fields can be easily viewed by the user.
3) No Modified Version of the Font Software may use the Reserved Font
Name(s) unless explicit written permission is granted by the corresponding
Copyright Holder. This restriction only applies to the primary font name as
presented to the users.
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
Software shall not be used to promote, endorse or advertise any
Modified Version, except to acknowledge the contribution(s) of the
Copyright Holder(s) and the Author(s) or with their explicit written
permission.
5) The Font Software, modified or unmodified, in part or in whole,
must be distributed entirely under this license, and must not be
distributed under any other license. The requirement for fonts to
remain under this license does not apply to any document created
using the Font Software.
TERMINATION
This license becomes null and void if any of the above conditions are
not met.
DISCLAIMER
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
OTHER DEALINGS IN THE FONT SOFTWARE.

View File

@ -1,5 +1,11 @@
; override font path
Font_Override unifont.ttf
; ---------------------------
; you don't need to specify all the parameters when using this file
; only set the parameters relevant to your use case
; ---------------------------
; load custom font from a path
; path could be absolute, or relative to steam_settings/fonts
Font_Override BungeeSpice-Regular.ttf
; global font size
; for built-in font, multiple of 16 is recommended. e.g. 16 32...
@ -12,10 +18,6 @@ Icon_Size 64.0
Font_Glyph_Extra_Spacing_x 1.0
Font_Glyph_Extra_Spacing_y 0.0
; increase these values by 1 if the font is blurry
Font_Oversample_H 1
Font_Oversample_V 1
Notification_R 0.16
Notification_G 0.29
Notification_B 0.48