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

TextBox do not support Chinese charset? #3780

Closed
jzlhll opened this issue Apr 13, 2020 · 18 comments
Closed

TextBox do not support Chinese charset? #3780

jzlhll opened this issue Apr 13, 2020 · 18 comments

Comments

@jzlhll
Copy link

jzlhll commented Apr 13, 2020

OSX: MacBook Pro (Retina, 15-inch, Mid 2015)
Avalonia: 0.9.7

TextBox input issue.

When input Chinese charset such as "我们",it shows two blank rectangles.
You can try it with commond + C to paste it.

Maybe it is an issue about unicode / ascii charset, something like this.

Finally, I found that change the font family will be help.
If the TextBlock/TextBox FontFamily change to "黑体", "宋体", it works well.
For Chinese guys or other ones.

@Gillibald
Copy link
Contributor

Current TextBox is very limited and needs a rework that will come at some point this year.

@jzlhll jzlhll closed this as completed Apr 13, 2020
@Codexiaoyi
Copy link

OSX: MacBook Pro (Retina, 15-inch, Mid 2015)
Avalonia: 0.9.7

TextBox input issue.

When input Chinese charset such as "我们",it shows two blank rectangles.
You can try it with commond + C to paste it.

Maybe it is an issue about unicode / ascii charset, something like this.

Finally, I found that change the font family will be help.
If the TextBlock/TextBox FontFamily change to "黑体", "宋体", it works well.
For Chinese guys or other ones.

您这边在mac上可以正常使用TextBox输入中文吗?

@jzlhll
Copy link
Author

jzlhll commented Apr 15, 2020

OSX: MacBook Pro (Retina, 15-inch, Mid 2015)
Avalonia: 0.9.7
TextBox input issue.
When input Chinese charset such as "我们",it shows two blank rectangles.
You can try it with commond + C to paste it.
Maybe it is an issue about unicode / ascii charset, something like this.
Finally, I found that change the font family will be help.
If the TextBlock/TextBox FontFamily change to "黑体", "宋体", it works well.
For Chinese guys or other ones.

您这边在mac上可以正常使用TextBox输入中文吗?

修改TextBox的fontFamily可以解决。

@Codexiaoyi
Copy link

修改TextBox的fontFamily可以解决。

我是在linux上跑,修改fontfamily确实可以解决显示问题,不过还是不能正常打字输入,是可以复制粘贴进去,原因是无法支持输入法。我在前面的issue中提过,官方说在适配输入法,我还是想先找到一个可以暂时替代的方案,如果您有临时的解决方案,麻烦您告诉我一下谢谢。

@jzlhll
Copy link
Author

jzlhll commented Apr 15, 2020

修改TextBox的fontFamily可以解决。

我是在linux上跑,修改fontfamily确实可以解决显示问题,不过还是不能正常打字输入,是可以复制粘贴进去,原因是无法支持输入法。我在前面的issue中提过,官方说在适配输入法,我还是想先找到一个可以暂时替代的方案,如果您有临时的解决方案,麻烦您告诉我一下谢谢。

mac看来是可以的。linux没试过。也许是linux独有的bug吧。

@FreezeSoul
Copy link

关注这个问题

@wuzlai
Copy link

wuzlai commented Aug 21, 2020

OSX: MacBook Pro (Retina, 15-inch, Mid 2015)
Avalonia: 0.9.7
TextBox input issue.
When input Chinese charset such as "我们",it shows two blank rectangles.
You can try it with commond + C to paste it.
Maybe it is an issue about unicode / ascii charset, something like this.
Finally, I found that change the font family will be help.
If the TextBlock/TextBox FontFamily change to "黑体", "宋体", it works well.
For Chinese guys or other ones.

您这边在mac上可以正常使用TextBox输入中文吗?

修改TextBox的fontFamily可以解决。
你好,我现在我也遇到了这个问题,在mac系统显示中文是乱码的。请问是怎么解决的了? Content="写邮件" FontFamily="宋体" ??

@Codexiaoyi
Copy link

你好,我现在我也遇到了这个问题,在mac系统显示中文是乱码的。请问是怎么解决的了? Content="写邮件" FontFamily="宋体" ??

按理来说是可以的。我在linux发现你想要的字体可能系统没有,所以我干脆找到Avalonia源码,模仿源码的添加字体方式,添加自己的字体并引用,效果不错。

@wuzlai
Copy link

wuzlai commented Aug 24, 2020

你好,我现在我也遇到了这个问题,在mac系统显示中文是乱码的。请问是怎么解决的了? Content="写邮件" FontFamily="宋体" ??

按理来说是可以的。我在linux发现你想要的字体可能系统没有,所以我干脆找到Avalonia源码,模仿源码的添加字体方式,添加自己的字体并引用,效果不错。

你好,我直接修改FontFamily,在mac下还是乱码,能不能给个例子。我参考下你之前 添加的字体代码了。或者麻烦告诉下源代码中哪个目录文件是 自定义字体的了,谢谢了

@Codexiaoyi
Copy link

你好,我直接修改FontFamily,在mac下还是乱码,能不能给个例子。我参考下你之前 添加的字体代码了。或者麻烦告诉下源代码中哪个目录文件是 自定义字体的了,谢谢了

https://github.com/AvaloniaUI/Avalonia/blob/master/samples/ControlCatalog/Pages/TextBlockPage.xaml
抱歉,例子不能给您,就是模仿上面的37行这样写在全局(记得添加字体文件),我记得Avalonia文档里面也有类似的自定义字体的介绍。

@wuzlai
Copy link

wuzlai commented Aug 24, 2020

你好,我直接修改FontFamily,在mac下还是乱码,能不能给个例子。我参考下你之前 添加的字体代码了。或者麻烦告诉下源代码中哪个目录文件是 自定义字体的了,谢谢了

https://github.com/AvaloniaUI/Avalonia/blob/master/samples/ControlCatalog/Pages/TextBlockPage.xaml
抱歉,例子不能给您,就是模仿上面的37行这样写在全局(记得添加字体文件),我记得Avalonia文档里面也有类似的自定义字体的介绍。

好的, 非常感谢!

@JasonGrass
Copy link

我这里直接设置系统字体可以解决,将 FontFamily 设置为 "Microsoft YaHei,Simsun,苹方-简,宋体-简"
详见:AvaloniaUI TextBox 不能显示中文的问题解决 - J.晒太阳的猫

@wuzlai
Copy link

wuzlai commented Dec 3, 2020

我这里直接设置系统字体可以解决,将 FontFamily 设置为 "Microsoft YaHei,Simsun,苹方-简,宋体-简"
详见:AvaloniaUI TextBox 不能显示中文的问题解决 - J.晒太阳的猫

谢谢。提供的方法很有效果。解决了大问题,感谢!

@tianxia467099532
Copy link

ubuntu18.0.4上把系统语言设置成中文简体,运行程序没有响应界面都不会显示出来, 如果把系统语言设置英文,则可以运行成功。

@chenjing1294
Copy link

As of May 13, 2022, it is still not possible to input Chinese characters

@Gillibald
Copy link
Contributor

Only current master supports this. Please try out a current nightly build.

@kekekeks
Copy link
Member

@chenjing1294 you need to use WenQuanYi Micro Hei font:

<TextBox AcceptsReturn="True" TextWrapping="Wrap" Height="200" MaxWidth="400"
FontFamily="avares://ControlCatalog/Assets/Fonts#WenQuanYi Micro Hei"
Text="计算机科学(是系统性研究信息与计算的理论基础以及它们在计算机系统中如何实现与应用的实用技术的学科。它通常被形容为对那些创造、描述以及转换信息的算法处理的系统研究。计算机科学包含很多分支领域;有些强调特定结果的计算,比如计算机图形学;而有些是探討计算问题的性质,比如计算复杂性理论;还有一些领域專注于怎样实现计算,比如程式語言理論是研究描述计算的方法,而程式设计是应用特定的程式語言解决特定的计算问题,人机交互则是專注于怎样使计算机和计算变得有用、好用,以及随时随地为人所用。&#xD;&#xD;有时公众会误以为计算机科学就是解决计算机问题的事业(比如信息技术),或者只是与使用计算机的经验有关,如玩游戏、上网或者文字处理。其实计算机科学所关注的,不仅仅是去理解实现类似游戏、浏览器这些软件的程序的性质,更要通过现有的知识创造新的程序或者改进已有的程序。" />
</StackPanel>

@sky92archangel
Copy link

Just add this :

<Window.Styles>		 
	<Style Selector="TextBox">
		<Setter Property="FontFamily" Value="Microsoft YaHei,Simsun,苹方-简,宋体-简"/>
	</Style>
	<Style Selector="DataGrid">
		<Setter Property="FontFamily" Value="Microsoft YaHei,Simsun,苹方-简,宋体-简"/>
	</Style>
</Window.Styles>

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

10 participants