Generate simulated bold font from the custom font if no custom bold font set.

This commit is contained in:
bruvzg 2022-03-14 08:02:43 +02:00
parent 7a454842d4
commit 4f1660dad7
No known key found for this signature in database
GPG key ID: 7960FCF39844EC38

View file

@ -206,7 +206,8 @@ void editor_register_fonts(Ref<Theme> p_theme) {
break;
}
int default_font_size = int(EDITOR_GET("interface/editor/main_font_size")) * EDSCALE;
const int default_font_size = int(EDITOR_GET("interface/editor/main_font_size")) * EDSCALE;
const float embolden_strength = 0.6;
String custom_font_path = EditorSettings::get_singleton()->get("interface/editor/main_font");
Ref<FontData> CustomFont;
@ -226,6 +227,11 @@ void editor_register_fonts(Ref<Theme> p_theme) {
EditorSettings::get_singleton()->set_manually("interface/editor/main_font_bold", "");
}
if (CustomFont.is_valid() && !CustomFontBold.is_valid()) {
CustomFontBold = CustomFont->duplicate();
CustomFontBold->set_embolden(embolden_strength);
}
/* Custom source code font */
String custom_font_path_source = EditorSettings::get_singleton()->get("interface/editor/code_font");
@ -268,8 +274,6 @@ void editor_register_fonts(Ref<Theme> p_theme) {
Ref<FontData> FontFallback = load_cached_internal_font(_font_DroidSansFallback, _font_DroidSansFallback_size, font_hinting, font_antialiased, true, font_subpixel_positioning);
Ref<FontData> FontJapanese = load_cached_internal_font(_font_DroidSansJapanese, _font_DroidSansJapanese_size, font_hinting, font_antialiased, true, font_subpixel_positioning);
const float embolden_strength = 0.6;
Ref<FontData> FontFallbackBold = FontFallback->duplicate();
FontFallbackBold->set_embolden(embolden_strength);
Ref<FontData> FontJapaneseBold = FontJapanese->duplicate();