From bcabc6288a75b4f8a7d695bddd4d051607a9b0a3 Mon Sep 17 00:00:00 2001 From: paypur Date: Tue, 26 Aug 2025 16:47:33 -0400 Subject: [PATCH] Add a parameter for font_size_small --- README.md | 3 ++- src/font.cpp | 12 ++++++++---- src/overlay_params.cpp | 8 +++++++- src/overlay_params.h | 3 ++- 4 files changed, 19 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 660dc9ddcf..7382e1eb53 100644 --- a/README.md +++ b/README.md @@ -382,6 +382,7 @@ Parameters that are enabled by default have to be explicitly disabled. These (cu | `font_scale_media_player` | Change size of media player text relative to `font_size` | | `font_size=` | Customizable font size. Default is `24` | | `font_size_secondary=` | Customizable font size for secondary metrics. Default is `0.55 * font_size`, except if `no_small_font` is set, in which case the default value is `font_size` | +| `font_size_small=` | Customizable font size for small text (like units). Default is `0.55 * font_size`. | | `font_size_text=` | Customizable font size for other text like media metadata. Default is `24` | | `fps_color_change` | Change the FPS text color depepending on the FPS value | | `fps_color=` | Choose the colors that the fps changes to when `fps_color_change` is enabled. Corresponds with fps_value. Default is `b22222,fdfd09,39f900` | @@ -687,7 +688,7 @@ Example output: #### Intel notes - GPU temperature for `i915` requires **linux 6.13+** - Fan speed for `i915` requires **linux 6.12+** -- GPU temperature and vram temperature for `xe` requires **linux 6.15+** +- GPU temperature and vram temperature for `xe` requires **linux 6.15+** - Fan speed for `xe` requires **linux 6.16+** - GPU usage and memory usage shows usage of current process, not total system usage (it's an issue on intel's side) - https://gitlab.freedesktop.org/drm/i915/kernel/-/issues/14153 diff --git a/src/font.cpp b/src/font.cpp index 2f2863a526..42d4a17bab 100644 --- a/src/font.cpp +++ b/src/font.cpp @@ -25,6 +25,10 @@ void create_fonts(ImFontAtlas* font_atlas, const overlay_params& params, ImFont* if (font_size_secondary > font_size || font_size_secondary < FLT_EPSILON) font_size_secondary = font_size; + float font_size_small = params.font_size_small; + if (font_size_small > font_size || font_size_small < FLT_EPSILON) + font_size_small = font_size; + static const ImWchar default_range[] = { 0x0020, 0x00FF, // Basic Latin + Latin Supplement @@ -82,8 +86,8 @@ void create_fonts(ImFontAtlas* font_atlas, const overlay_params& params, ImFont* if (params.no_small_font) small_font = font_atlas->Fonts[0]; else { - small_font = font_atlas->AddFontFromFileTTF(params.font_file.c_str(), font_size * 0.55f, nullptr, default_range); - font_atlas->AddFontFromMemoryCompressedBase85TTF(forkawesome_compressed_data_base85, font_size * 0.55f, &config, icon_ranges); + small_font = font_atlas->AddFontFromFileTTF(params.font_file.c_str(), font_size_small, nullptr, default_range); + font_atlas->AddFontFromMemoryCompressedBase85TTF(forkawesome_compressed_data_base85, font_size_small, &config, icon_ranges); } if (secondary_same_size) { secondary_font = font_atlas->Fonts[0]; @@ -98,8 +102,8 @@ void create_fonts(ImFontAtlas* font_atlas, const overlay_params& params, ImFont* if (params.no_small_font) small_font = font_atlas->Fonts[0]; else { - small_font = font_atlas->AddFontFromMemoryCompressedBase85TTF(ttf_compressed_base85, font_size * 0.55f, nullptr, default_range); - font_atlas->AddFontFromMemoryCompressedBase85TTF(forkawesome_compressed_data_base85, font_size * 0.55f, &config, icon_ranges); + small_font = font_atlas->AddFontFromMemoryCompressedBase85TTF(ttf_compressed_base85, font_size_small, nullptr, default_range); + font_atlas->AddFontFromMemoryCompressedBase85TTF(forkawesome_compressed_data_base85, font_size_small, &config, icon_ranges); } if (secondary_same_size) { secondary_font = font_atlas->Fonts[0]; diff --git a/src/overlay_params.cpp b/src/overlay_params.cpp index b10a0cea58..4f9b49b97a 100644 --- a/src/overlay_params.cpp +++ b/src/overlay_params.cpp @@ -597,6 +597,7 @@ parse_ftrace(const char *str) { #define parse_log_interval(s) parse_unsigned(s) #define parse_font_size(s) parse_float(s) #define parse_font_size_secondary(s) parse_float(s) +#define parse_font_size_small(s) parse_float(s) #define parse_font_size_text(s) parse_float(s) #define parse_font_scale(s) parse_float(s) #define parse_background_alpha(s) parse_float(s) @@ -1110,6 +1111,10 @@ parse_overlay_config(struct overlay_params *params, params->font_size_secondary = params->font_size * coeff; } + // If small font size not set, compute it from main font_size + if (!params->font_size_small) + params->font_size_small = params->font_size * 0.55f; + params->font_params_hash = get_hash(params->font_size, params->font_size_text, params->no_small_font, @@ -1117,7 +1122,8 @@ parse_overlay_config(struct overlay_params *params, params->font_file_text, params->font_glyph_ranges, params->font_scale, - params->font_size_secondary + params->font_size_secondary, + params->font_size_small ); // check if user specified an env for fps limiter instead diff --git a/src/overlay_params.h b/src/overlay_params.h index 0ff802cfcd..31ad062811 100644 --- a/src/overlay_params.h +++ b/src/overlay_params.h @@ -145,6 +145,7 @@ struct Tracepoint; OVERLAY_PARAM_CUSTOM(font_size) \ OVERLAY_PARAM_CUSTOM(font_size_text) \ OVERLAY_PARAM_CUSTOM(font_size_secondary) \ + OVERLAY_PARAM_CUSTOM(font_size_small) \ OVERLAY_PARAM_CUSTOM(font_scale) \ OVERLAY_PARAM_CUSTOM(font_scale_media_player) \ OVERLAY_PARAM_CUSTOM(position) \ @@ -323,7 +324,7 @@ struct overlay_params { unsigned table_columns; bool no_small_font; float font_size, font_scale; - float font_size_text, font_size_secondary; + float font_size_text, font_size_secondary, font_size_small; float font_scale_media_player; float background_alpha, alpha; float cellpadding_y;