Skip to content

C2D_Text's width seems truncated when using C2D_AlignCenter #47

@vaguerant

Description

@vaguerant

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions