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

Chinese characters not displaying - Font Issue? #469

Open
benda opened this issue Aug 7, 2024 · 1 comment
Open

Chinese characters not displaying - Font Issue? #469

benda opened this issue Aug 7, 2024 · 1 comment

Comments

@benda
Copy link

benda commented Aug 7, 2024

If I set the Text property of a button to Chinese text, for example "新游戏", the characters are not displayed. If I mix Chinese and English, e.g. "abc新游戏xyz" the English characters are displayed but not the Chinese. I expect the Chinese characters to be displayed.

I realize this is a font issue, however, the following code doesn't fix it for Chinese fonts.

byte[] ttfData = File.ReadAllBytes("C:\windows\fonts\simsunb.ttf");
FontSystem ordinaryFontSystem = new FontSystem();
ordinaryFontSystem.AddFont(ttfData);
Label title = //removed code that retrieves title
title.Font = ordinaryFontSystem.GetFont(12);

If instead of
byte[] ttfData = File.ReadAllBytes("C:\windows\fonts\simsunb.ttf");
I use
byte[] ttfData = File.ReadAllBytes("C:\windows\fonts\gabriola.ttf");

I can display Latin characters in Gabriola font. But why don't the Chinese characters appear in the SimSunB font? Both font ttf files exist on my machine.

In MonoGame itself, adding SpriteFont via the content pipeline and using SpriteBatch.DrawString works as expected, properly displaying the Chinese characters. The MonoGame SprintFont appears to be an incompatible implementation from Myra's SpriteFontBase (from FontStashSharp). Also with MonoGame when importing the font I needed to specify Character Regions, is that not necessary with FontStashSharp or am I missing a step?

@benda benda closed this as completed Aug 8, 2024
@benda benda reopened this Aug 8, 2024
@benda benda changed the title Chinese characters not displaying (Button.Text) Chinese characters not displaying - Font Issue? Aug 8, 2024
@CodeRabbit957
Copy link

CodeRabbit957 commented Oct 13, 2024

Not all fonts support foreign language characters. I'm currently using a font I've added for Japanese characters. If I paste in the input "abc新游戏xyz", all the characters display with the exception of 戏.
If the font you are using isn't displaying Chinese characters, you should try a font designed for Chinese characters. (Maybe Noto Sans Simplified Chinese.)

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