Skip to content

Font resolution wrong when setting content_scale_factor in size_changed signal handler #103703

@timoschwarzer

Description

@timoschwarzer

Tested versions

  • Reproducible in v4.4.stable.official [4c311cb]

System information

Godot v4.4.stable - Arch Linux #1 ZEN SMP PREEMPT_DYNAMIC Thu, 27 Feb 2025 18:09:27 +0000 on Wayland - X11 display driver, Multi-window, 3 monitors - Vulkan (Forward+) - dedicated Intel(R) Arc(tm) Pro A60M Graphics (DG2) - 13th Gen Intel(R) Core(TM) i9-13900H (20 threads)

Issue description

In my project I listen for changes of the main window size and scale its content by setting get_window().content_scale_factor accordingly.
I noticed that text in Labels (probably other text rendering Nodes too) gets blurry when making the Window larger (= increasing Viewport resolution) and increasing content_scale_factor in the size_changed event of the Window.

When you set content_scale_factor to the same value again after the size_changed event, text renders with the correct resolution again.

I was only able to replicate this inside side_changed signal handlers. Binding an input to change content_scale_factor does not result in this behavior for me.

Setting content_scale_factor with set_deferred also prevents this bug from happening.

Steps to reproduce

Screencast.From.2025-03-06.16-10-45.mp4

In the video I first shrink and enlarge the Window again to reproduce the bug. Then I press Enter, which assigns content_scale_factor to the same value again and fixes the blurry text.

Not immediately obvious, it is only text that gets blurry, not the entire viewport. If you place a big Sprite2D with a high resolution texture behind the Labels, that Sprite2D is always rendered correctly.

func _ready() -> void:
	get_window().size_changed.connect(_on_window_size_changed)

func _on_window_size_changed():
	get_window().content_scale_factor = get_window().size.x / 1920.0

func _unhandled_input(event: InputEvent) -> void:
	if event.is_action_pressed("ui_accept"):
		get_window().content_scale_factor = get_window().content_scale_factor

Minimal reproduction project (MRP)

label-scale-repro.zip

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions