Skip to content

Commit 8ea11ad

Browse files
committed
Add a parameter for font_size_small
1 parent eb7fe42 commit 8ea11ad

4 files changed

Lines changed: 18 additions & 6 deletions

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -381,6 +381,7 @@ Parameters that are enabled by default have to be explicitly disabled. These (cu
381381
| `font_scale_media_player` | Change size of media player text relative to `font_size` |
382382
| `font_size=` | Customizable font size. Default is `24` |
383383
| `font_size_secondary=` | Customizable font size for secondary metrics. Default is `0.55 * font_size`. |
384+
| `font_size_small=` | Customizable font size for small text (like units). Default is `0.55 * font_size`. |
384385
| `font_size_text=` | Customizable font size for other text like media metadata. Default is `24` |
385386
| `fps_color_change` | Change the FPS text color depepending on the FPS value |
386387
| `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` |

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
@@ -80,8 +84,8 @@ void create_fonts(ImFontAtlas* font_atlas, const overlay_params& params, ImFont*
8084
if (params.no_small_font)
8185
small_font = font_atlas->Fonts[0];
8286
else {
83-
small_font = font_atlas->AddFontFromFileTTF(params.font_file.c_str(), font_size * 0.55f, nullptr, default_range);
84-
font_atlas->AddFontFromMemoryCompressedBase85TTF(forkawesome_compressed_data_base85, font_size * 0.55f, &config, icon_ranges);
87+
small_font = font_atlas->AddFontFromFileTTF(params.font_file.c_str(), font_size_small, nullptr, default_range);
88+
font_atlas->AddFontFromMemoryCompressedBase85TTF(forkawesome_compressed_data_base85, font_size_small, &config, icon_ranges);
8589
}
8690
if (secondary_same_size) {
8791
secondary_font = font_atlas->Fonts[0];
@@ -96,8 +100,8 @@ void create_fonts(ImFontAtlas* font_atlas, const overlay_params& params, ImFont*
96100
if (params.no_small_font)
97101
small_font = font_atlas->Fonts[0];
98102
else {
99-
small_font = font_atlas->AddFontFromMemoryCompressedBase85TTF(ttf_compressed_base85, font_size * 0.55f, nullptr, default_range);
100-
font_atlas->AddFontFromMemoryCompressedBase85TTF(forkawesome_compressed_data_base85, font_size * 0.55f, &config, icon_ranges);
103+
small_font = font_atlas->AddFontFromMemoryCompressedBase85TTF(ttf_compressed_base85, font_size_small, nullptr, default_range);
104+
font_atlas->AddFontFromMemoryCompressedBase85TTF(forkawesome_compressed_data_base85, font_size_small, &config, icon_ranges);
101105
}
102106
if (secondary_same_size) {
103107
secondary_font = font_atlas->Fonts[0];

src/overlay_params.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -545,6 +545,7 @@ parse_ftrace(const char *str) {
545545
#define parse_log_interval(s) parse_unsigned(s)
546546
#define parse_font_size(s) parse_float(s)
547547
#define parse_font_size_secondary(s) parse_float(s)
548+
#define parse_font_size_small(s) parse_float(s)
548549
#define parse_font_size_text(s) parse_float(s)
549550
#define parse_font_scale(s) parse_float(s)
550551
#define parse_background_alpha(s) parse_float(s)
@@ -1049,14 +1050,19 @@ parse_overlay_config(struct overlay_params *params,
10491050
if (!params->font_size_secondary)
10501051
params->font_size_secondary = params->font_size * 0.55f;
10511052

1053+
// If small font size not set, compute it from main font_size
1054+
if (!params->font_size_small)
1055+
params->font_size_small = params->font_size * 0.55f;
1056+
10521057
params->font_params_hash = get_hash(params->font_size,
10531058
params->font_size_text,
10541059
params->no_small_font,
10551060
params->font_file,
10561061
params->font_file_text,
10571062
params->font_glyph_ranges,
10581063
params->font_scale,
1059-
params->font_size_secondary
1064+
params->font_size_secondary,
1065+
params->font_size_small
10601066
);
10611067

10621068
// 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
@@ -137,6 +137,7 @@ struct Tracepoint;
137137
OVERLAY_PARAM_CUSTOM(font_size) \
138138
OVERLAY_PARAM_CUSTOM(font_size_text) \
139139
OVERLAY_PARAM_CUSTOM(font_size_secondary) \
140+
OVERLAY_PARAM_CUSTOM(font_size_small) \
140141
OVERLAY_PARAM_CUSTOM(font_scale) \
141142
OVERLAY_PARAM_CUSTOM(font_scale_media_player) \
142143
OVERLAY_PARAM_CUSTOM(position) \
@@ -312,7 +313,7 @@ struct overlay_params {
312313
unsigned table_columns;
313314
bool no_small_font;
314315
float font_size, font_scale;
315-
float font_size_text, font_size_secondary;
316+
float font_size_text, font_size_secondary, font_size_small;
316317
float font_scale_media_player;
317318
float background_alpha, alpha;
318319
float cellpadding_y;

0 commit comments

Comments
 (0)