Skip to content

Allow more precise scaling of HUD texts #16603

@Wuzzy2

Description

@Wuzzy2

Problem

Currently, if you display text with hud_add, you can set the font size with the size parameter like so:

player:hud_add({
  -- [...]
  type = "text",
  size = { x = 2, y = 2 },
  -- [...]
}

However, size.x only supports integer values, which means you can only double, triple, quadruple, etc. the text size and not increase it by like 25%. If you use the number 1.25 (for example), it gets rounded down to 1.

Note the visual font size difference between size 1 and size 2 is HUGE.

Solutions

Allow for more fine-grained text size control in HUD elements.

An obvious (and maybe naive?) change would be to recognize the numbers in the size argument as floating-point numbers, so that size = { x = 1.5, y = 1.5 } increases the size by 50%. But I don’t know if this could create issues with the rest of the HUD system.

Alternatives

  • Add new argument font_size instead (to avoid changing the number type of size.x and size.y)

Additional context

No response

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