diff options
author | RĂ©mi Verschelde <remi@verschelde.fr> | 2022-03-22 16:06:53 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-03-22 16:06:53 +0100 |
commit | a30d17fe23cab95716e4b1bff9dfac21b70b5481 (patch) | |
tree | 4b35d9b5577024877bb5f1a4fa5c47bf69a2d599 /editor | |
parent | 9433c1d70c67fe8294d2c5721cf7e4b6cb3d554b (diff) | |
parent | 803e1ae920a282a64c48d2623ca056362a3f2359 (diff) |
Merge pull request #59029 from bruvzg/help_slanted
Diffstat (limited to 'editor')
-rw-r--r-- | editor/editor_fonts.cpp | 56 | ||||
-rw-r--r-- | editor/editor_help.cpp | 4 |
2 files changed, 57 insertions, 3 deletions
diff --git a/editor/editor_fonts.cpp b/editor/editor_fonts.cpp index 7b72e09bd7..66fe3c4838 100644 --- a/editor/editor_fonts.cpp +++ b/editor/editor_fonts.cpp @@ -52,6 +52,23 @@ m_name->add_data(FontJapanese); \ m_name->add_data(FontFallback); +// Note: In some languages, the use of italic/slanted fonts is controversial. Therefore, we are limiting simulated slant to the main font (Latin, Cyrillic, and Greek) and using bold fonts for the rest. + +#define MAKE_FALLBACKS_SLANTED(m_name) \ + m_name->add_data(FontArabicBold); \ + m_name->add_data(FontBengaliBold); \ + m_name->add_data(FontDevanagariBold); \ + m_name->add_data(FontGeorgianBold); \ + m_name->add_data(FontHebrewBold); \ + m_name->add_data(FontMalayalamBold); \ + m_name->add_data(FontOriyaBold); \ + m_name->add_data(FontSinhalaBold); \ + m_name->add_data(FontTamilBold); \ + m_name->add_data(FontTeluguBold); \ + m_name->add_data(FontThaiBold); \ + m_name->add_data(FontJapaneseBold); \ + m_name->add_data(FontFallbackBold); + #define MAKE_FALLBACKS_BOLD(m_name) \ m_name->add_data(FontArabicBold); \ m_name->add_data(FontBengaliBold); \ @@ -93,6 +110,33 @@ m_name->set_spacing(TextServer::SPACING_BOTTOM, -EDSCALE); \ MAKE_FALLBACKS(m_name); +#define MAKE_SLANTED_FONT(m_name, m_variations) \ + Ref<Font> m_name; \ + m_name.instantiate(); \ + m_name.instantiate(); \ + if (CustomFontSlanted.is_valid()) { \ + m_name->add_data(CustomFontSlanted); \ + m_name->add_data(DefaultFontSlanted); \ + } else { \ + m_name->add_data(DefaultFontSlanted); \ + } \ + { \ + Dictionary variations; \ + if (!m_variations.is_empty()) { \ + Vector<String> variation_tags = m_variations.split(","); \ + for (int i = 0; i < variation_tags.size(); i++) { \ + Vector<String> tokens = variation_tags[i].split("="); \ + if (tokens.size() == 2) { \ + variations[tokens[0]] = tokens[1].to_float(); \ + } \ + } \ + } \ + m_name->set_variation_coordinates(variations); \ + } \ + m_name->set_spacing(TextServer::SPACING_TOP, -EDSCALE); \ + m_name->set_spacing(TextServer::SPACING_BOTTOM, -EDSCALE); \ + MAKE_FALLBACKS_SLANTED(m_name); + #define MAKE_BOLD_FONT(m_name, m_variations) \ Ref<Font> m_name; \ m_name.instantiate(); \ @@ -217,6 +261,12 @@ void editor_register_fonts(Ref<Theme> p_theme) { EditorSettings::get_singleton()->set_manually("interface/editor/main_font", ""); } + Ref<FontData> CustomFontSlanted; + if (CustomFont.is_valid()) { + CustomFontSlanted = CustomFont->duplicate(); + CustomFontSlanted->set_transform(Transform2D(1.0, 0.4, 0.0, 1.0, 0.0, 0.0)); + } + /* Custom Bold font */ String custom_font_path_bold = EditorSettings::get_singleton()->get("interface/editor/main_font_bold"); @@ -269,6 +319,9 @@ void editor_register_fonts(Ref<Theme> p_theme) { Ref<FontData> FontThai = load_cached_internal_font(_font_NotoSansThaiUI_Regular, _font_NotoSansThaiUI_Regular_size, font_hinting, font_antialiased, true, font_subpixel_positioning); Ref<FontData> FontThaiBold = load_cached_internal_font(_font_NotoSansThaiUI_Bold, _font_NotoSansThaiUI_Bold_size, font_hinting, font_antialiased, true, font_subpixel_positioning); + Ref<FontData> DefaultFontSlanted = DefaultFont->duplicate(); + DefaultFontSlanted->set_transform(Transform2D(1.0, 0.3, 0.0, 1.0, 0.0, 0.0)); + /* Droid Sans */ Ref<FontData> FontFallback = load_cached_internal_font(_font_DroidSansFallback, _font_DroidSansFallback_size, font_hinting, font_antialiased, true, font_subpixel_positioning); @@ -296,6 +349,7 @@ void editor_register_fonts(Ref<Theme> p_theme) { // Bold font MAKE_BOLD_FONT(df_bold, String()); + MAKE_SLANTED_FONT(df_italic, String()); p_theme->set_font_size("bold_size", "EditorFonts", default_font_size); p_theme->set_font("bold", "EditorFonts", df_bold); @@ -325,8 +379,8 @@ void editor_register_fonts(Ref<Theme> p_theme) { MAKE_SOURCE_FONT(df_code, code_font_custom_variations); p_theme->set_font_size("doc_size", "EditorFonts", int(EDITOR_GET("text_editor/help/help_font_size")) * EDSCALE); p_theme->set_font("doc", "EditorFonts", df); - p_theme->set_font_size("doc_bold_size", "EditorFonts", int(EDITOR_GET("text_editor/help/help_font_size")) * EDSCALE); p_theme->set_font("doc_bold", "EditorFonts", df_bold); + p_theme->set_font("doc_italic", "EditorFonts", df_italic); p_theme->set_font_size("doc_title_size", "EditorFonts", int(EDITOR_GET("text_editor/help/help_title_font_size")) * EDSCALE); p_theme->set_font("doc_title", "EditorFonts", df_bold); p_theme->set_font_size("doc_source_size", "EditorFonts", int(EDITOR_GET("text_editor/help/help_source_font_size")) * EDSCALE); diff --git a/editor/editor_help.cpp b/editor/editor_help.cpp index 622547f0a8..75dbe74e01 100644 --- a/editor/editor_help.cpp +++ b/editor/editor_help.cpp @@ -1476,10 +1476,10 @@ static void _add_text_to_rt(const String &p_bbcode, RichTextLabel *p_rt) { Ref<Font> doc_font = p_rt->get_theme_font(SNAME("doc"), SNAME("EditorFonts")); Ref<Font> doc_bold_font = p_rt->get_theme_font(SNAME("doc_bold"), SNAME("EditorFonts")); + Ref<Font> doc_italic_font = p_rt->get_theme_font(SNAME("doc_italic"), SNAME("EditorFonts")); Ref<Font> doc_code_font = p_rt->get_theme_font(SNAME("doc_source"), SNAME("EditorFonts")); Ref<Font> doc_kbd_font = p_rt->get_theme_font(SNAME("doc_keyboard"), SNAME("EditorFonts")); - Color headline_color = p_rt->get_theme_color(SNAME("headline_color"), SNAME("EditorHelp")); Color link_color = p_rt->get_theme_color(SNAME("link_color"), SNAME("EditorHelp")); Color code_color = p_rt->get_theme_color(SNAME("code_color"), SNAME("EditorHelp")); Color kbd_color = p_rt->get_theme_color(SNAME("kbd_color"), SNAME("EditorHelp")); @@ -1633,7 +1633,7 @@ static void _add_text_to_rt(const String &p_bbcode, RichTextLabel *p_rt) { tag_stack.push_front(tag); } else if (tag == "i") { //use italics font - p_rt->push_color(headline_color); + p_rt->push_font(doc_italic_font); pos = brk_end + 1; tag_stack.push_front(tag); } else if (tag == "code" || tag == "codeblock") { |