Skip to content
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

font metrics wrong for monospace font. #7900

Closed
d954mas opened this issue Aug 19, 2023 · 1 comment · Fixed by #8886
Closed

font metrics wrong for monospace font. #7900

d954mas opened this issue Aug 19, 2023 · 1 comment · Fixed by #8886
Labels
bug Something is not working as expected engine Issues related to the Defold engine font Issues related to font rendering/handling label Issues related to labels

Comments

@d954mas
Copy link
Contributor

d954mas commented Aug 19, 2023

Describe the bug (REQUIRED)
I try to make timer for my game. I try monospace font, but it possition is jittering
https://github.com/defold/defold/assets/2655263/dd34fd9a-8a5e-4c25-8b57-cb4df677796c

I try to make small repro case. Label with same number of symbols in monospace font have different width.
2023-08-19_13-31-32

1-2 labels is center
3-4 labels is west

DEBUG:SCRIPT: time:00:00 width:188
DEBUG:SCRIPT: time:11:11 width:179

Last symbol right border not added to width?

To Reproduce (REQUIRED)
Look at repro case.

Expected behavior (REQUIRED)
Width should be same

Defold version (REQUIRED):

  • Version 1.5.0

Platforms (REQUIRED):

  • Windows

Minimal repro case project (OPTIONAL):
FontWidth.zip

@d954mas d954mas added the bug Something is not working as expected label Aug 19, 2023
@britzl britzl added engine Issues related to the Defold engine label Issues related to labels font Issues related to font rendering/handling labels Aug 21, 2023
@AGulev
Copy link
Contributor

AGulev commented May 5, 2024

This part doesn't take into account monospaced fonts

if (n > 0 && 0 != last)
{
uint32_t last_width = (measure_trailing_space && last->m_Character == ' ') ? (int16_t)last->m_Advance : last->m_Width;
float last_end_point = last->m_LeftBearing + last_width;
float last_right_bearing = last->m_Advance - last_end_point;
width = width - last_right_bearing - tracking;
}

https://docs.aspose.com/font/net/what-is-font/glyph/
image
image

These changes should be taken into account too #5911

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something is not working as expected engine Issues related to the Defold engine font Issues related to font rendering/handling label Issues related to labels
Projects
No open projects
Status: Done
Development

Successfully merging a pull request may close this issue.

3 participants