Skip to content

text measure function #19415

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft

Conversation

ickshonpe
Copy link
Contributor

@ickshonpe ickshonpe commented May 28, 2025

Objective

Fixes #19382

Solution

Function measure_text creates a temporary cosmic buffer to shape the text and return the size of the laid out text.
This isn't very good but should work.

Testing

@ickshonpe ickshonpe added C-Feature A new feature, making something new possible A-UI Graphical user interfaces, styles, layouts, and widgets labels May 28, 2025
@alice-i-cecile alice-i-cecile added this to the 0.17 milestone May 28, 2025
@alice-i-cecile alice-i-cecile moved this to Widget-ready in Alice's Work Planning May 28, 2025
@alice-i-cecile alice-i-cecile requested a review from viridia May 28, 2025 21:40
Copy link
Contributor

@viridia viridia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great. We can always improve it later.

@viridia
Copy link
Contributor

viridia commented May 28, 2025

Release note suggestion:

Game worlds often have in-game text for signboards and placards. The measure_text function can be used to determine the width and height of a text string (using a specified font) so that the words can be appropriate scaled to fit the available space.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-UI Graphical user interfaces, styles, layouts, and widgets C-Feature A new feature, making something new possible
Projects
Status: Widget-ready
Development

Successfully merging this pull request may close these issues.

Cosmic text: provide API to measure text without drawing it.
3 participants