最近在Ubuntu下用运行astah(一个依赖jvm的uml图形化工具)时, 无法显示中文. 所有的中文都以方框来显示.
在网上找相关的问题都说是缺失中文字体. 并将win的simsun.ttc拷贝到 jre/lib/fonts/fallback/下, 但试过后不管用.
所以考虑是否是jvm字体配置问题.
在本机/usr/lib/jvm/如下:
找到关于font相关的配置文件 /usr/lib/jvm/java-6-openjdk-amd64/jre/lib/fontconfig.properties
其实是link到了/etc/java-6-openjdk/fontconfig.properties
并在其中找到关于JVM中文支持的相关项.
# Version
# Uses Ubuntu 8.04 (hardy), Debian 6.0 (Squeeze) (and more recent releases) fonts and file paths.
version=1
# Component Font Mappings
# Chinese fonts
allfonts.umingcn=AR PL UMing CN
#allfonts.umingcn.motif=AR PL UMing CN
allfonts.uminghk=AR PL UMing HK
#allfonts.uminghk.motif=AR PL UMing HK
allfonts.umingtw=AR PL UMing TW
#allfonts.umingtw.motif=AR PL UMing TW
allfonts.wqy-microhei=WenQuanYi Micro Hei
allfonts.wqy-zenhei=WenQuanYi Zen Hei
#allfonts.wqy-zenhei.motif=WenQuanYi Zen Hei
allfonts.shanheisun=AR PL ShanHeiSun Uni
#allfonts.shanheisun.motif=AR PL ShanHeiSun Uni
................
................
................
# AWT X11 font paths
awtfontpath.latin-1=/usr/share/fonts/X11/Type1
awtfontpath.umingcn=/usr/share/fonts/truetype/arphic
awtfontpath.uminghk=/usr/share/fonts/truetype/arphic
awtfontpath.umingtw=/usr/share/fonts/truetype/arphic
awtfontpath.shanheisun=/usr/share/fonts/truetype/arphic
从中可以看到AWT使用的中文字体存在于/usr/share/fonts/truetype/arphic下
但是查看并不存在arphic目录.
所以可以肯定是少了字体umingXX, 所以google搜索相关的字体安装即可.
下载地址
https://packages.debian.org/wheezy/all/fonts-arphic-uming/download
在命令行安装执行安装.
sudo dpkg -i fonts-arphic-uming_0.2.20080216.2-4_all.deb
安装成功后会在arphic目录下找到uming.ttc 如下, 此时JVM环境下的AWT就可以使用中文了.