summaryrefslogtreecommitdiff
path: root/scene/main/scene_tree.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'scene/main/scene_tree.cpp')
-rw-r--r--scene/main/scene_tree.cpp41
1 files changed, 28 insertions, 13 deletions
diff --git a/scene/main/scene_tree.cpp b/scene/main/scene_tree.cpp
index 5acb157279..689f18a09d 100644
--- a/scene/main/scene_tree.cpp
+++ b/scene/main/scene_tree.cpp
@@ -484,6 +484,14 @@ bool SceneTree::iteration(float p_time) {
return _quit;
}
+void SceneTree::_update_font_oversampling(float p_ratio) {
+
+ if (use_font_oversampling) {
+ DynamicFontAtSize::font_oversampling = p_ratio;
+ DynamicFont::update_oversampling();
+ }
+}
+
bool SceneTree::idle(float p_time) {
//print_line("ram: "+itos(OS::get_singleton()->get_static_memory_usage())+" sram: "+itos(OS::get_singleton()->get_dynamic_memory_usage()));
@@ -515,12 +523,6 @@ bool SceneTree::idle(float p_time) {
last_screen_size = win_size;
_update_root_rect();
-
- if (use_font_oversampling) {
- DynamicFontAtSize::font_oversampling = OS::get_singleton()->get_window_size().width / root->get_visible_rect().size.width;
- DynamicFont::update_oversampling();
- }
-
emit_signal("screen_resized");
}
@@ -1133,10 +1135,12 @@ void SceneTree::_update_root_rect() {
if (stretch_mode == STRETCH_MODE_DISABLED) {
+ _update_font_oversampling(1.0);
root->set_size((last_screen_size / stretch_shrink).floor());
root->set_attach_to_screen_rect(Rect2(Point2(), last_screen_size));
root->set_size_override_stretch(false);
root->set_size_override(false, Size2());
+ root->update_canvas_items();
return; //user will take care
}
@@ -1150,6 +1154,10 @@ void SceneTree::_update_root_rect() {
float viewport_aspect = desired_res.aspect();
float video_mode_aspect = video_mode.aspect();
+ if (use_font_oversampling && stretch_aspect == STRETCH_ASPECT_IGNORE) {
+ WARN_PRINT("Font oversampling only works with the resize modes 'Keep Width', 'Keep Height', and 'Expand'.");
+ }
+
if (stretch_aspect == STRETCH_ASPECT_IGNORE || ABS(viewport_aspect - video_mode_aspect) < CMP_EPSILON) {
//same aspect or ignore aspect
viewport_size = desired_res;
@@ -1208,21 +1216,30 @@ void SceneTree::_update_root_rect() {
switch (stretch_mode) {
case STRETCH_MODE_DISABLED: {
// Already handled above
+ _update_font_oversampling(1.0);
} break;
case STRETCH_MODE_2D: {
+ _update_font_oversampling(screen_size.x / viewport_size.x); //screen / viewport radio drives oversampling
root->set_size((screen_size / stretch_shrink).floor());
root->set_attach_to_screen_rect(Rect2(margin, screen_size));
root->set_size_override_stretch(true);
root->set_size_override(true, (viewport_size / stretch_shrink).floor());
+ root->update_canvas_items(); //force them to update just in case
} break;
case STRETCH_MODE_VIEWPORT: {
+ _update_font_oversampling(1.0);
root->set_size((viewport_size / stretch_shrink).floor());
root->set_attach_to_screen_rect(Rect2(margin, screen_size));
root->set_size_override_stretch(false);
root->set_size_override(false, Size2());
+ root->update_canvas_items(); //force them to update just in case
+
+ if (use_font_oversampling) {
+ WARN_PRINT("Font oversampling does not work in 'Viewport' stretch mode, only '2D'.")
+ }
} break;
}
@@ -1925,12 +1942,11 @@ void SceneTree::add_idle_callback(IdleCallback p_callback) {
void SceneTree::set_use_font_oversampling(bool p_oversampling) {
+ if (use_font_oversampling == p_oversampling)
+ return;
+
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;
- }
+ _update_root_rect();
}
bool SceneTree::is_using_font_oversampling() const {
@@ -1944,6 +1960,7 @@ SceneTree::SceneTree() {
accept_quit = true;
quit_on_go_back = true;
initialized = false;
+ use_font_oversampling = false;
#ifdef DEBUG_ENABLED
debug_collisions_hint = false;
debug_navigation_hint = false;
@@ -2079,8 +2096,6 @@ SceneTree::SceneTree() {
live_edit_root = NodePath("/root");
#endif
-
- use_font_oversampling = false;
}
SceneTree::~SceneTree() {