JUCE
JUCE copied to clipboard
[Bug]: Font::getStringWidth gives incorrect width for non-latin text
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
- [X] I agree to follow the Code of Conduct