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

C2D_Text's width seems truncated when using C2D_AlignCenter #47

Open
vaguerant opened this issue Mar 6, 2024 · 2 comments
Open

C2D_Text's width seems truncated when using C2D_AlignCenter #47

vaguerant opened this issue Mar 6, 2024 · 2 comments

Comments

@vaguerant
Copy link

vaguerant commented Mar 6, 2024

Bug Report

What's the issue you encountered?

When using C2D_AlignCenter, characters at the edges of an individual C2D_DrawText can become clipped horizontally. In the below screenshot, it is most noticeable on the (B) buttons in the center button diamond, but it is also affecting the /L/ and (A) characters to a lesser extent. Notably, the (B) in the top row is also being aligned with C2D_AlignCenter but not showing the issue.

image
image

Each button glyph is a codepoint from the system font, (A) is \uE000 and (B) is \uE001. /L/ and \R\ are \uE07B and \uE07C, respectively. I have not made any changes to devkitPro tooling, I am using the official devkitpro/devkitarm 20240202 tag in Docker.

How can the issue be reproduced?

Building my repo at vaguerant/red-viper is probably a decent start. If you want to replicate just the problematic portion, it can be found here and in the preceding variables: https://github.com/vaguerant/red-viper/blob/5ba407fbe4ab4706d8b8ab26f6c9c2ab5cbef7a3/source/3ds/gui_hard.c#L507-L510

Environment?

  • What host OS are you using?
    • Linux via Docker tag of devkitpro/devkitarm 20240202
  • Official release or unofficial/self-compiled build:
    • Official release

Additional context?

  • Pure guesswork: Perhaps when centered, text is not on an exact pixel boundary and so the glyph's width is no longer representative of the necessary C2D_Text width? e.g. A single, centered glyph with an odd number of pixels in its width would need to be placed an off-integer pixel to be truly centered. If Citro2D is centering the glyph and anti-aliasing, that would mean the width of the glyph itself is two pixels less than the aliased version which is "half" in one pixel at either side. Again, just speculating, I have no idea how Citro2D renders text or does anything at all.
  • EDIT: I was able to work around this issue by adjusting the x position of the C2D_DrawText calls by 0.5, presumably forcing them back onto a pixel boundary.
@WinterMute
Copy link
Member

How can the issue be reproduced?

Building my repo at vaguerant/red-viper is probably a decent start. If you want to replicate just the problematic portion, it can be found here and in the preceding variables: https://github.com/vaguerant/red-viper/blob/5ba407fbe4ab4706d8b8ab26f6c9c2ab5cbef7a3/source/3ds/gui_hard.c#L507-L510

Help us to help you. It's much easier if we can build something simple to replicate the issue than to build an entire project and find the relevant part. The more work we have to put into replicating your issue the longer it's going to take for someone to find time to look.

  • EDIT: I was able to work around this issue by adjusting the x position of the C2D_DrawText calls by 0.5, presumably forcing them back onto a pixel boundary.

This sounds like possibly a rounding issue somewhere. Would be easier with a simple testcase to look at.

@vaguerant
Copy link
Author

Help us to help you. It's much easier if we can build something simple to replicate the issue than to build an entire project and find the relevant part. The more work we have to put into replicating your issue the longer it's going to take for someone to find time to look.

Fair, sorry. I have essentially zero coding knowledge, just whatever I've picked up bothering people with GitHub issues. I had a look and modified one of the 3ds-examples to repro this issue:

vaguerant/3ds-examples@e260673

I'm printing the ABXYLR glyphs twice, once at an x position of 180.0f and then again at 220.5f. The left version definitely looks like it's printing "off-pixel" with somewhat blurry output and clipping on the left side of the glyphs, while the right version looks sharp (drawn on-pixel) and shows no clipping.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants