Add `no_small_font` option for unified font size

pull/395/head
jackun 4 years ago
parent 8349479026
commit 60ffab4350
No known key found for this signature in database
GPG Key ID: 119DB3F1D05A9ED3

@ -141,6 +141,7 @@ Parameters that are enabled by default have to be explicitly disabled. These (cu
| `font_file` | Change default font (set location to .TTF/.OTF file ) |
| `font_file_text` | Change text font. Otherwise `font_file` is used |
| `font_glyph_ranges` | Specify extra font glyph ranges, comma separated: `korean`, `chinese`, `chinese_simplified`, `japanese`, `cyrillic`, `thai`, `vietnamese`, `latin_ext_a`, `latin_ext_b`. If you experience crashes or text is just squares, reduce font size or glyph ranges. |
| `no_small_font` | Use primary font size for smaller text like units |
| `width=`<br>`height=` | Customizeable hud dimensions (in pixels) |
| `position=` | Location of the hud: `top-left` (default), `top-right`, `bottom-left`, `bottom-right`, `top-center` |
| `offset_x` `offset_y` | Hud position offsets |

@ -58,6 +58,7 @@ font_size=24
# font_scale=1.0
# font_size_text=24
# font_scale_media_player = 0.55
# no_small_font
### Change default font (set location to .TTF/.OTF file )
## Set font for the whole hud

@ -56,11 +56,17 @@ void create_fonts(const overlay_params& params, ImFont*& small_font, ImFont*& te
// ImGui takes ownership of the data, no need to free it
if (!params.font_file.empty() && file_exists(params.font_file)) {
io.Fonts->AddFontFromFileTTF(params.font_file.c_str(), font_size, nullptr, same_font && same_size ? glyph_ranges.Data : default_range);
small_font = io.Fonts->AddFontFromFileTTF(params.font_file.c_str(), font_size * 0.55f, nullptr, default_range);
if (params.no_small_font)
small_font = io.Fonts->Fonts[0];
else
small_font = io.Fonts->AddFontFromFileTTF(params.font_file.c_str(), font_size * 0.55f, nullptr, default_range);
} else {
const char* ttf_compressed_base85 = GetDefaultCompressedFontDataTTFBase85();
io.Fonts->AddFontFromMemoryCompressedBase85TTF(ttf_compressed_base85, font_size, nullptr, default_range);
small_font = io.Fonts->AddFontFromMemoryCompressedBase85TTF(ttf_compressed_base85, font_size * 0.55f, nullptr, default_range);
if (params.no_small_font)
small_font = io.Fonts->Fonts[0];
else
small_font = io.Fonts->AddFontFromMemoryCompressedBase85TTF(ttf_compressed_base85, font_size * 0.55f, nullptr, default_range);
}
auto font_file_text = params.font_file_text;

@ -343,6 +343,7 @@ parse_font_glyph_ranges(const char *str)
#define parse_background_alpha(s) parse_float(s)
#define parse_alpha(s) parse_float(s)
#define parse_permit_upload(s) parse_unsigned(s)
#define parse_no_small_font(s) parse_unsigned(s) != 0
#define parse_cpu_color(s) parse_color(s)
#define parse_gpu_color(s) parse_color(s)
@ -651,6 +652,9 @@ parse_overlay_config(struct overlay_params *params,
} else {
params->width = params->font_size * params->font_scale * 11.7;
}
// Treat it like hud would need to be ~7 characters wider with default font.
if (params->no_small_font)
params->width += 7 * params->font_size * params->font_scale;
}
// set frametime limit

@ -62,6 +62,7 @@ typedef unsigned long KeySym;
OVERLAY_PARAM_CUSTOM(font_file) \
OVERLAY_PARAM_CUSTOM(font_file_text) \
OVERLAY_PARAM_CUSTOM(font_glyph_ranges) \
OVERLAY_PARAM_CUSTOM(no_small_font) \
OVERLAY_PARAM_CUSTOM(font_size) \
OVERLAY_PARAM_CUSTOM(font_size_text) \
OVERLAY_PARAM_CUSTOM(font_scale) \
@ -176,6 +177,7 @@ struct overlay_params {
std::vector<unsigned> cpu_load_value;
unsigned media_player_color;
unsigned tableCols;
bool no_small_font;
float font_size, font_scale;
float font_size_text;
float font_scale_media_player;

Loading…
Cancel
Save