Index of every page on this site: llms.txt
All skills
jame581 avatar

/responsive-ui

@426e8ab
by Jan Mesarčjame581/godotprompter979 stars
63
Run it yourself

Use when handling multiple resolutions — stretch modes, aspect ratios, DPI scaling, and mobile/desktop adaptation

Use this Skill: https://skilld.dev/gh/jame581/godotprompter/responsive-ui

Nothing lands on disk. Nothing to clean up.

Fork this Skill

Edit a local copy. It keeps the author and licence.

referencesdpi-scaling.md

≈490 tokens on demand. Your agent reads this file only when SKILL.md points to it.

DPI Scaling

Reference for skills/responsive-ui/SKILL.md — content_scale_factor, querying DPI at runtime for retina/high-DPI handling.

← Back to SKILL.md


5. DPI Scaling

content_scale_factor

Window.content_scale_factor multiplies all UI element sizes uniformly in the canvas_items and disabled stretch modes (in viewport mode it divides the render resolution instead). Increase it on high-DPI (Retina) displays so text and controls are not microscopic.

GDScript:

# autoload/dpi_scaler.gd
extends Node

func _ready() -> void:
    _apply_dpi_scale()


func _apply_dpi_scale() -> void:
    var dpi := DisplayServer.screen_get_dpi()
    # 96 dpi is the standard desktop reference
    var scale := clampf(dpi / 96.0, 1.0, 3.0)
    # Round to nearest 0.25 to avoid blurry half-pixel rendering
    scale = roundf(scale * 4.0) / 4.0
    get_window().content_scale_factor = scale


func get_dpi() -> int:
    return DisplayServer.screen_get_dpi()

C#:

// autoload/DpiScaler.cs
using Godot;

public partial class DpiScaler : Node
{
    public override void _Ready() => ApplyDpiScale();

    private void ApplyDpiScale()
    {
        float dpi   = DisplayServer.ScreenGetDpi();
        float scale = Mathf.Clamp(dpi / 96f, 1f, 3f);
        // Round to nearest 0.25
        scale = Mathf.Round(scale * 4f) / 4f;
        GetWindow().ContentScaleFactor = scale;
    }

    public int GetDpi() => DisplayServer.ScreenGetDpi();
}

Querying DPI at Runtime

GDScript:

var dpi: int = DisplayServer.screen_get_dpi()
print("Screen DPI: %d" % dpi)  # 96 on standard, 192+ on Retina

C#:

int dpi = DisplayServer.ScreenGetDpi();
GD.Print($"Screen DPI: {dpi}");

Tip: On macOS Retina displays screen_get_dpi() returns 220+. On Windows with 200 % scaling it returns 192. Use these thresholds to decide whether to enable a 2x UI scale.


Source: SKILL.md on GitHub

skilld matched fixed text patterns in SKILL.md and file names. Patterns miss obfuscated code.

skilld run checks every file with the same patterns. It asks for approval before it loads a Skill with a behavior marked Needs approval.

No alerts29d3 checks · Risk SAFE
  • Gen Agent Trust Hub29d

    The skill provides comprehensive documentation and code snippets for creating responsive user interfaces in Godot 4.3+. It covers project settings, DPI scaling, mobile safe areas, and pixel art configurations. No security issues were detected.

  • Socket29d

    No alerts

  • Snyk29d

    Risk: LOW · No issues

Signed by skilld at 426e8ab. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub 6 days ago.

Activeupdated last month

README badge

README badge for jame581/godotprompter/responsive-ui