Skip to content

Commit bcabc62

Browse files
committed
Add a parameter for font_size_small
1 parent d05402e commit bcabc62

4 files changed

Lines changed: 19 additions & 7 deletions

File tree

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -382,6 +382,7 @@ Parameters that are enabled by default have to be explicitly disabled. These (cu
382382
| `font_scale_media_player` | Change size of media player text relative to `font_size` |
383383
| `font_size=` | Customizable font size. Default is `24` |
384384
| `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` |
385+
| `font_size_small=` | Customizable font size for small text (like units). Default is `0.55 * font_size`. |
385386
| `font_size_text=` | Customizable font size for other text like media metadata. Default is `24` |
386387
| `fps_color_change` | Change the FPS text color depepending on the FPS value |
387388
| `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:
687688
#### Intel notes
688689
- GPU temperature for `i915` requires **linux 6.13+**
689690
- Fan speed for `i915` requires **linux 6.12+**
690-
- GPU temperature and vram temperature for `xe` requires **linux 6.15+**
691+
- GPU temperature and vram temperature for `xe` requires **linux 6.15+**
691692
- Fan speed for `xe` requires **linux 6.16+**
692693
- GPU usage and memory usage shows usage of current process, not total system usage (it's an issue on intel's side)
693694
- https://gitlab.freedesktop.org/drm/i915/kernel/-/issues/14153

src/font.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ void create_fonts(ImFontAtlas* font_atlas, const overlay_params& params, ImFont*
2525
if (font_size_secondary > font_size || font_size_secondary < FLT_EPSILON)
2626
font_size_secondary = font_size;
2727

28+
float font_size_small = params.font_size_small;
29+
if (font_size_small > font_size || font_size_small < FLT_EPSILON)
30+
font_size_small = font_size;
31+
2832
static const ImWchar default_range[] =
2933
{
3034
0x0020, 0x00FF, // Basic Latin + Latin Supplement
@@ -82,8 +86,8 @@ void create_fonts(ImFontAtlas* font_atlas, const overlay_params& params, ImFont*
8286
if (params.no_small_font)
8387
small_font = font_atlas->Fonts[0];
8488
else {
85-
small_font = font_atlas->AddFontFromFileTTF(params.font_file.c_str(), font_size * 0.55f, nullptr, default_range);
86-
font_atlas->AddFontFromMemoryCompressedBase85TTF(forkawesome_compressed_data_base85, font_size * 0.55f, &config, icon_ranges);
89+
small_font = font_atlas->AddFontFromFileTTF(params.font_file.c_str(), font_size_small, nullptr, default_range);
90+
font_atlas->AddFontFromMemoryCompressedBase85TTF(forkawesome_compressed_data_base85, font_size_small, &config, icon_ranges);
8791
}
8892
if (secondary_same_size) {
8993
secondary_font = font_atlas->Fonts[0];
@@ -98,8 +102,8 @@ void create_fonts(ImFontAtlas* font_atlas, const overlay_params& params, ImFont*
98102
if (params.no_small_font)
99103
small_font = font_atlas->Fonts[0];
100104
else {
101-
small_font = font_atlas->AddFontFromMemoryCompressedBase85TTF(ttf_compressed_base85, font_size * 0.55f, nullptr, default_range);
102-
font_atlas->AddFontFromMemoryCompressedBase85TTF(forkawesome_compressed_data_base85, font_size * 0.55f, &config, icon_ranges);
105+
small_font = font_atlas->AddFontFromMemoryCompressedBase85TTF(ttf_compressed_base85, font_size_small, nullptr, default_range);
106+
font_atlas->AddFontFromMemoryCompressedBase85TTF(forkawesome_compressed_data_base85, font_size_small, &config, icon_ranges);
103107
}
104108
if (secondary_same_size) {
105109
secondary_font = font_atlas->Fonts[0];

src/overlay_params.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -597,6 +597,7 @@ parse_ftrace(const char *str) {
597597
#define parse_log_interval(s) parse_unsigned(s)
598598
#define parse_font_size(s) parse_float(s)
599599
#define parse_font_size_secondary(s) parse_float(s)
600+
#define parse_font_size_small(s) parse_float(s)
600601
#define parse_font_size_text(s) parse_float(s)
601602
#define parse_font_scale(s) parse_float(s)
602603
#define parse_background_alpha(s) parse_float(s)
@@ -1110,14 +1111,19 @@ parse_overlay_config(struct overlay_params *params,
11101111
params->font_size_secondary = params->font_size * coeff;
11111112
}
11121113

1114+
// If small font size not set, compute it from main font_size
1115+
if (!params->font_size_small)
1116+
params->font_size_small = params->font_size * 0.55f;
1117+
11131118
params->font_params_hash = get_hash(params->font_size,
11141119
params->font_size_text,
11151120
params->no_small_font,
11161121
params->font_file,
11171122
params->font_file_text,
11181123
params->font_glyph_ranges,
11191124
params->font_scale,
1120-
params->font_size_secondary
1125+
params->font_size_secondary,
1126+
params->font_size_small
11211127
);
11221128

11231129
// check if user specified an env for fps limiter instead

src/overlay_params.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ struct Tracepoint;
145145
OVERLAY_PARAM_CUSTOM(font_size) \
146146
OVERLAY_PARAM_CUSTOM(font_size_text) \
147147
OVERLAY_PARAM_CUSTOM(font_size_secondary) \
148+
OVERLAY_PARAM_CUSTOM(font_size_small) \
148149
OVERLAY_PARAM_CUSTOM(font_scale) \
149150
OVERLAY_PARAM_CUSTOM(font_scale_media_player) \
150151
OVERLAY_PARAM_CUSTOM(position) \
@@ -323,7 +324,7 @@ struct overlay_params {
323324
unsigned table_columns;
324325
bool no_small_font;
325326
float font_size, font_scale;
326-
float font_size_text, font_size_secondary;
327+
float font_size_text, font_size_secondary, font_size_small;
327328
float font_scale_media_player;
328329
float background_alpha, alpha;
329330
float cellpadding_y;

0 commit comments

Comments
 (0)