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

[Bug]: Font::getStringWidth gives incorrect width for non-latin text #1424

Open
1 task done
royhcj opened this issue Sep 4, 2024 · 0 comments
Open
1 task done

[Bug]: Font::getStringWidth gives incorrect width for non-latin text #1424

royhcj opened this issue Sep 4, 2024 · 0 comments

Comments

@royhcj
Copy link

royhcj commented Sep 4, 2024

Detailed steps on how to reproduce the bug

The string width from Font::getStringWidth with a text containing non-latin characters is short by a few pixels.
When drawing the text with the calculated width, the text is displayed truncated with ellipses at the end.

String text = CharPointer_UTF8("Test Label中文測試"); // A string containing Chinese characters
auto font = Font(FontOptions( "Arial", 24.0, Font::plain));
int width = font.getStringWidth( text );

g.drawText( text, 0, 0, width, height, Justification::left ); // The text is rendered as "Test Label中文..."

Note that the returned width is correct when using Chinese fonts such as "PingFang TC".

What is the expected behaviour?

Font::getStringWidth should give a correct width for strings containing non-latin characters.
Hence, the rendered text should not be truncated.

Operating systems

macOS

What versions of the operating systems?

Sonoma 14.5

Architectures

ARM

Stacktrace

No response

Plug-in formats (if applicable)

No response

Plug-in host applications (DAWs) (if applicable)

No response

Testing on the develop branch

The bug is present on the develop branch

Code of Conduct

  • I agree to follow the Code of Conduct
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

1 participant