diff options
author | volzhs <volzhs@gmail.com> | 2017-12-27 03:14:48 +0900 |
---|---|---|
committer | volzhs <volzhs@gmail.com> | 2017-12-27 03:14:48 +0900 |
commit | 2c8ebab93b8bc534c8960cbbf876c19c9ac71967 (patch) | |
tree | 83fe232a45a0be6beac88fea1535bc53589f7b29 | |
parent | edd3bd8cb8a64c1c5bf770c7103809a0ba64a4f0 (diff) |
Use .ttf or .otf file for editor custom font
-rw-r--r-- | editor/editor_fonts.cpp | 17 | ||||
-rw-r--r-- | editor/editor_settings.cpp | 2 | ||||
-rw-r--r-- | editor/editor_themes.cpp | 11 |
3 files changed, 17 insertions, 13 deletions
diff --git a/editor/editor_fonts.cpp b/editor/editor_fonts.cpp index 8aca007e6b..c88f927236 100644 --- a/editor/editor_fonts.cpp +++ b/editor/editor_fonts.cpp @@ -77,12 +77,27 @@ static Ref<BitmapFont> make_font(int p_height, int p_ascent, int p_valign, int p Ref<DynamicFont> m_name; \ m_name.instance(); \ m_name->set_size(m_size); \ - m_name->set_font_data(DefaultFont); \ + if (CustomFont.is_valid()) { \ + m_name->set_font_data(CustomFont); \ + m_name->add_fallback(DefaultFont); \ + } else { \ + m_name->set_font_data(DefaultFont); \ + } \ m_name->set_spacing(DynamicFont::SPACING_TOP, -EDSCALE); \ m_name->set_spacing(DynamicFont::SPACING_BOTTOM, -EDSCALE); \ MAKE_FALLBACKS(m_name); void editor_register_fonts(Ref<Theme> p_theme) { + /* Custom font */ + + String custom_font = EditorSettings::get_singleton()->get("interface/editor/custom_font"); + Ref<DynamicFontData> CustomFont; + if (custom_font.length() > 0) { + CustomFont.instance(); + CustomFont->set_font_path(custom_font); + CustomFont->set_force_autohinter(true); //just looks better..i think? + } + /* Droid Sans */ Ref<DynamicFontData> DefaultFont; diff --git a/editor/editor_settings.cpp b/editor/editor_settings.cpp index 3bd592e934..7188685c09 100644 --- a/editor/editor_settings.cpp +++ b/editor/editor_settings.cpp @@ -264,7 +264,7 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) { _initial_set("interface/editor/source_font_size", 14); hints["interface/editor/source_font_size"] = PropertyInfo(Variant::INT, "interface/editor/source_font_size", PROPERTY_HINT_RANGE, "8,96,1", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED); _initial_set("interface/editor/custom_font", ""); - hints["interface/editor/custom_font"] = PropertyInfo(Variant::STRING, "interface/editor/custom_font", PROPERTY_HINT_GLOBAL_FILE, "*.font,*.tres,*.res", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED); + hints["interface/editor/custom_font"] = PropertyInfo(Variant::STRING, "interface/editor/custom_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); _initial_set("interface/editor/dim_amount", 0.6f); hints["interface/editor/dim_amount"] = PropertyInfo(Variant::REAL, "interface/editor/dim_amount", PROPERTY_HINT_RANGE, "0,1,0.01", PROPERTY_USAGE_DEFAULT); diff --git a/editor/editor_themes.cpp b/editor/editor_themes.cpp index 5610baa775..841d50e3d8 100644 --- a/editor/editor_themes.cpp +++ b/editor/editor_themes.cpp @@ -1100,16 +1100,5 @@ Ref<Theme> create_custom_theme(const Ref<Theme> p_theme) { theme = create_editor_theme(p_theme); } - String global_font = EditorSettings::get_singleton()->get("interface/editor/custom_font"); - if (global_font != "") { - Ref<Font> fnt = ResourceLoader::load(global_font); - if (fnt.is_valid()) { - if (!theme.is_valid()) { - theme.instance(); - } - theme->set_default_theme_font(fnt); - } - } - return theme; } |