diff options
author | toger5 <toger5@hotmail.de> | 2018-04-10 17:26:26 +0200 |
---|---|---|
committer | toger5 <toger5@hotmail.de> | 2018-04-19 22:00:58 +0200 |
commit | 29216b2bad4677e0ded77ea777c9cb4bc8bae6b4 (patch) | |
tree | 185943ba56124a6a9c0705f1284a64e4c14a7842 | |
parent | 48890b15c5b5ff54ea2cf416a9d3157f2d5dee5b (diff) |
added bold font to editor (support for coustom bold font)
-rw-r--r-- | editor/editor_fonts.cpp | 65 | ||||
-rw-r--r-- | editor/editor_settings.cpp | 2 | ||||
-rw-r--r-- | thirdparty/fonts/NotoSansUI_Bold.ttf | bin | 0 -> 311496 bytes |
3 files changed, 55 insertions, 12 deletions
diff --git a/editor/editor_fonts.cpp b/editor/editor_fonts.cpp index 2ec3cdb08f..26f16e282e 100644 --- a/editor/editor_fonts.cpp +++ b/editor/editor_fonts.cpp @@ -85,6 +85,20 @@ static Ref<BitmapFont> make_font(int p_height, int p_ascent, int p_valign, int p m_name->set_spacing(DynamicFont::SPACING_BOTTOM, -EDSCALE); \ MAKE_FALLBACKS(m_name); +#define MAKE_BOLD_FONT(m_name, m_size) \ + Ref<DynamicFont> m_name; \ + m_name.instance(); \ + m_name->set_size(m_size); \ + if (CustomFont.is_valid()) { \ + m_name->set_font_data(CustomFontBold); \ + m_name->add_fallback(DefaultFontBold); \ + } else { \ + m_name->set_font_data(DefaultFontBold); \ + } \ + m_name->set_spacing(DynamicFont::SPACING_TOP, -EDSCALE); \ + m_name->set_spacing(DynamicFont::SPACING_BOTTOM, -EDSCALE); \ + MAKE_FALLBACKS(m_name); + #define MAKE_SOURCE_FONT(m_name, m_size) \ Ref<DynamicFont> m_name; \ m_name.instance(); \ @@ -102,25 +116,37 @@ static Ref<BitmapFont> make_font(int p_height, int p_ascent, int p_valign, int p void editor_register_fonts(Ref<Theme> p_theme) { /* Custom font */ - String custom_font = EditorSettings::get_singleton()->get("interface/editor/main_font"); DynamicFontData::Hinting font_hinting = (DynamicFontData::Hinting)(int)EditorSettings::get_singleton()->get("interface/editor/main_font_hinting"); + + String custom_font_path = EditorSettings::get_singleton()->get("interface/editor/main_font"); Ref<DynamicFontData> CustomFont; - if (custom_font.length() > 0) { + if (custom_font_path.length() > 0) { CustomFont.instance(); CustomFont->set_hinting(font_hinting); - CustomFont->set_font_path(custom_font); + CustomFont->set_font_path(custom_font_path); CustomFont->set_force_autohinter(true); //just looks better..i think? } + /* Custom Bold font */ + + String custom_font_path_bold = EditorSettings::get_singleton()->get("interface/editor/main_font_bold"); + Ref<DynamicFontData> CustomFontBold; + if (custom_font_path_bold.length() > 0) { + CustomFontBold.instance(); + CustomFontBold->set_hinting(font_hinting); + CustomFontBold->set_font_path(custom_font_path_bold); + CustomFontBold->set_force_autohinter(true); //just looks better..i think? + } + /* Custom source code font */ - String custom_font_source = EditorSettings::get_singleton()->get("interface/editor/code_font"); + String custom_font_path_source = EditorSettings::get_singleton()->get("interface/editor/code_font"); DynamicFontData::Hinting font_source_hinting = (DynamicFontData::Hinting)(int)EditorSettings::get_singleton()->get("interface/editor/code_font_hinting"); Ref<DynamicFontData> CustomFontSource; - if (custom_font_source.length() > 0) { + if (custom_font_path_source.length() > 0) { CustomFontSource.instance(); CustomFontSource->set_hinting(font_source_hinting); - CustomFontSource->set_font_path(custom_font_source); + CustomFontSource->set_font_path(custom_font_path_source); } /* Droid Sans */ @@ -131,6 +157,12 @@ void editor_register_fonts(Ref<Theme> p_theme) { DefaultFont->set_font_ptr(_font_NotoSansUI_Regular, _font_NotoSansUI_Regular_size); DefaultFont->set_force_autohinter(true); //just looks better..i think? + Ref<DynamicFontData> DefaultFontBold; + DefaultFontBold.instance(); + DefaultFont->set_hinting(font_hinting); + DefaultFontBold->set_font_ptr(_font_NotoSansUI_Bold, _font_NotoSansUI_Bold_size); + DefaultFontBold->set_force_autohinter(true); // just looks better..i think? + Ref<DynamicFontData> FontFallback; FontFallback.instance(); FontFallback->set_hinting(font_hinting); @@ -170,29 +202,38 @@ void editor_register_fonts(Ref<Theme> p_theme) { //dfd->set_force_autohinter(true); //just looks better..i think? int default_font_size = int(EditorSettings::get_singleton()->get("interface/editor/main_font_size")) * EDSCALE; - MAKE_DEFAULT_FONT(df, default_font_size); + // Default font + MAKE_DEFAULT_FONT(df, default_font_size); p_theme->set_default_theme_font(df); - MAKE_DEFAULT_FONT(df_title, default_font_size + 2 * EDSCALE); + // Bold font + MAKE_BOLD_FONT(df_bold, default_font_size); + p_theme->set_font("bold", "EditorFonts", df_bold); + + // Title font + MAKE_BOLD_FONT(df_title, default_font_size + 2 * EDSCALE); p_theme->set_font("title", "EditorFonts", df_title); - MAKE_DEFAULT_FONT(df_doc_title, int(EDITOR_DEF("text_editor/help/help_title_font_size", 23)) * EDSCALE); + // Doc font + MAKE_BOLD_FONT(df_doc_title, int(EDITOR_DEF("text_editor/help/help_title_font_size", 23)) * EDSCALE); MAKE_DEFAULT_FONT(df_doc, int(EDITOR_DEF("text_editor/help/help_font_size", 15)) * EDSCALE); p_theme->set_font("doc", "EditorFonts", df_doc); p_theme->set_font("doc_title", "EditorFonts", df_doc_title); + MAKE_SOURCE_FONT(df_doc_code, int(EDITOR_DEF("text_editor/help/help_source_font_size", 14)) * EDSCALE); + p_theme->set_font("doc_source", "EditorFonts", df_doc_code); + + // Ruler font MAKE_DEFAULT_FONT(df_rulers, 8 * EDSCALE); p_theme->set_font("rulers", "EditorFonts", df_rulers); + // Code font MAKE_SOURCE_FONT(df_code, int(EditorSettings::get_singleton()->get("interface/editor/code_font_size")) * EDSCALE); p_theme->set_font("source", "EditorFonts", df_code); - MAKE_SOURCE_FONT(df_doc_code, int(EDITOR_DEF("text_editor/help/help_source_font_size", 14)) * EDSCALE); - p_theme->set_font("doc_source", "EditorFonts", df_doc_code); - MAKE_SOURCE_FONT(df_output_code, int(EDITOR_DEF("run/output/font_size", 13)) * EDSCALE); p_theme->set_font("output_source", "EditorFonts", df_output_code); diff --git a/editor/editor_settings.cpp b/editor/editor_settings.cpp index 85f6d99c67..6746ce4ed3 100644 --- a/editor/editor_settings.cpp +++ b/editor/editor_settings.cpp @@ -298,6 +298,8 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) { hints["interface/editor/code_font_hinting"] = PropertyInfo(Variant::INT, "interface/editor/code_font_hinting", PROPERTY_HINT_ENUM, "None,Light,Normal", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED); _initial_set("interface/editor/main_font", ""); hints["interface/editor/main_font"] = PropertyInfo(Variant::STRING, "interface/editor/main_font", PROPERTY_HINT_GLOBAL_FILE, "*.ttf,*.otf", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED); + _initial_set("interface/editor/main__bold_font", ""); + hints["interface/editor/main_font_bold"] = PropertyInfo(Variant::STRING, "interface/editor/main_bold_font", PROPERTY_HINT_GLOBAL_FILE, "*.ttf,*.otf", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED); _initial_set("interface/editor/code_font", ""); hints["interface/editor/code_font"] = PropertyInfo(Variant::STRING, "interface/editor/code_font", PROPERTY_HINT_GLOBAL_FILE, "*.ttf,*.otf", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED); _initial_set("interface/editor/dim_editor_on_dialog_popup", true); diff --git a/thirdparty/fonts/NotoSansUI_Bold.ttf b/thirdparty/fonts/NotoSansUI_Bold.ttf Binary files differnew file mode 100644 index 0000000000..810450aa81 --- /dev/null +++ b/thirdparty/fonts/NotoSansUI_Bold.ttf |