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

Monospaced / fixed width font spacing #42

Closed
antonok-edm opened this issue May 25, 2020 · 3 comments · Fixed by #43
Closed

Monospaced / fixed width font spacing #42

antonok-edm opened this issue May 25, 2020 · 3 comments · Fixed by #43
Labels
bug Something isn't working
Milestone

Comments

@antonok-edm
Copy link
Contributor

It appears that the choice of anchor point for text positioning depends on the actual width of the text in pixels rather than the width of the glyphs. In general this is hard to notice, but it definitely causes issues with monospaced/fixed width fonts that are dynamically updated. For instance, consider a simple counter app, where the text of the current count is positioned with the following Layout:

wgpu_glyph::Layout::default_single_line()
    .h_align(wgpu_glyph::HorizontalAlign::Right)
    .v_align(wgpu_glyph::VerticalAlign::Center)

When the rightmost character of the text updates from a wide character (e.g. 0) to a narrow character (e.g. 1) or vice versa, there is a noticeable horizontal shift in the rest of the characters on the left.

@hecrj
Copy link
Owner

hecrj commented May 25, 2020

Yes, I have noticed this too.

However, wgpu_glyph doesn't contain any positioning/measurement logic. This logic lives in glyph-brush, a direct dependency.

A new glyph-brush version was released a couple of days ago, and I believe it may fix this. I will try to update the dependency this week. If it doesn't fix the problem, we should file an issue in glyph-brush.

@hecrj hecrj added the bug Something isn't working label May 25, 2020
@hecrj hecrj added this to the 0.9.0 milestone May 25, 2020
@hecrj
Copy link
Owner

hecrj commented May 25, 2020

I tested it and this seems to be fixed by #43. Let me know!

@antonok-edm
Copy link
Contributor Author

Awesome! I just tried it out and everything appears as expected now 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants