diff options
Diffstat (limited to 'scene/main/scene_tree.cpp')
-rw-r--r-- | scene/main/scene_tree.cpp | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/scene/main/scene_tree.cpp b/scene/main/scene_tree.cpp index deb40800bc..7c31b72bb5 100644 --- a/scene/main/scene_tree.cpp +++ b/scene/main/scene_tree.cpp @@ -38,6 +38,7 @@ #include "os/os.h" #include "print_string.h" #include "project_settings.h" +#include "scene/resources/dynamic_font.h" #include "scene/resources/material.h" #include "scene/resources/mesh.h" #include "scene/resources/packed_scene.h" @@ -495,6 +496,11 @@ bool SceneTree::idle(float p_time) { Size2 win_size = Size2(OS::get_singleton()->get_video_mode().width, OS::get_singleton()->get_video_mode().height); if (win_size != last_screen_size) { + if (use_font_oversampling) { + DynamicFontAtSize::font_oversampling = OS::get_singleton()->get_window_size().width / root->get_visible_rect().size.width; + DynamicFont::update_oversampling(); + } + last_screen_size = win_size; _update_root_rect(); @@ -2195,6 +2201,9 @@ void SceneTree::_bind_methods() { ClassDB::bind_method(D_METHOD("_connection_failed"), &SceneTree::_connection_failed); ClassDB::bind_method(D_METHOD("_server_disconnected"), &SceneTree::_server_disconnected); + ClassDB::bind_method(D_METHOD("set_use_font_oversampling", "enable"), &SceneTree::set_use_font_oversampling); + ClassDB::bind_method(D_METHOD("is_using_font_oversampling"), &SceneTree::is_using_font_oversampling); + ADD_SIGNAL(MethodInfo("tree_changed")); ADD_SIGNAL(MethodInfo("node_added", PropertyInfo(Variant::OBJECT, "node"))); ADD_SIGNAL(MethodInfo("node_removed", PropertyInfo(Variant::OBJECT, "node"))); @@ -2244,6 +2253,20 @@ void SceneTree::add_idle_callback(IdleCallback p_callback) { idle_callbacks[idle_callback_count++] = p_callback; } +void SceneTree::set_use_font_oversampling(bool p_oversampling) { + + use_font_oversampling = p_oversampling; + if (use_font_oversampling) { + DynamicFontAtSize::font_oversampling = OS::get_singleton()->get_window_size().width / root->get_visible_rect().size.width; + } else { + DynamicFontAtSize::font_oversampling = 1.0; + } +} + +bool SceneTree::is_using_font_oversampling() const { + return use_font_oversampling; +} + SceneTree::SceneTree() { singleton = this; @@ -2327,7 +2350,7 @@ SceneTree::SceneTree() { ProjectSettings::get_singleton()->set("rendering/environment/default_environment", ""); } else { //file was erased, notify user. - ERR_PRINTS(RTR("Default Environment as specified in Project Setings (Rendering -> Viewport -> Default Environment) could not be loaded.")); + ERR_PRINTS(RTR("Default Environment as specified in Project Setings (Rendering -> Environment -> Default Environment) could not be loaded.")); } } } @@ -2380,6 +2403,8 @@ SceneTree::SceneTree() { last_send_cache_id = 1; #endif + + use_font_oversampling = false; } SceneTree::~SceneTree() { |