summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <rverschelde@gmail.com>2019-10-25 07:13:58 +0200
committerGitHub <noreply@github.com>2019-10-25 07:13:58 +0200
commit7a0a39cd52e3e8ce5d6b0cfd9d3b4d27f82c2a68 (patch)
tree00653c43bf5c57afc02fb8b230d09449059b6bcd
parent930d6d8ca4c34b0383d232335902f7f808806a66 (diff)
parent69c5d637f2fe0cdcc2e741ed8fb710ac7c28ea6a (diff)
Merge pull request #33041 from volzhs/help-font-size
Recalculate margin based on help source font size
-rw-r--r--editor/editor_help.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/editor/editor_help.cpp b/editor/editor_help.cpp
index 690538f44c..d2306abfd7 100644
--- a/editor/editor_help.cpp
+++ b/editor/editor_help.cpp
@@ -172,7 +172,9 @@ void EditorHelp::_class_desc_input(const Ref<InputEvent> &p_input) {
void EditorHelp::_class_desc_resized() {
// Add extra horizontal margins for better readability.
// The margins increase as the width of the editor help container increases.
- const int display_margin = MAX(30 * EDSCALE, get_parent_anchorable_rect().size.width - 900 * EDSCALE) * 0.5;
+ Ref<Font> doc_code_font = get_font("doc_source", "EditorFonts");
+ real_t char_width = doc_code_font->get_char_size('x').width;
+ const int display_margin = MAX(30 * EDSCALE, get_parent_anchorable_rect().size.width - char_width * 120 * EDSCALE) * 0.5;
Ref<StyleBox> class_desc_stylebox = EditorNode::get_singleton()->get_theme_base()->get_stylebox("normal", "RichTextLabel")->duplicate();
class_desc_stylebox->set_default_margin(MARGIN_LEFT, display_margin);