[英]Create java.awt.Font from google/noto font
I have noto fonts installed ( https://www.google.com/get/noto/ ) on my system but when I try to use some of the fonts (Chinese traditional, Chinese simplified) I receive just an empty space: 我的系统上没有安装字体( https://www.google.com/get/noto/ ),但是当我尝试使用某些字体(繁体中文,简体中文)时,我仅得到一个空白:
Font notoCJKtcfont= new Font("Noto Sans CJK TC Black", Font.PLAIN, 14);
JFrame frame = new JFrame("Test font");
JLabel chineseLable = new JLabel("大家好。 你好嗎&23latinsymbolsδ");
chineseLable.setFont(notoCJKtcfont);
frame.add(chineseLable);
frame.pack();
frame.setVisible(true);
Does it have something to do with OTF format and non-Latin symbols? 它与OTF格式和非拉丁符号有关吗? Is there any way to use those fonts - so they will display correctly?
有什么方法可以使用这些字体-这样它们才能正确显示?
I have researched that "Java seems not to render many CJK OpenType fonts correctly".So, this can be related to https://bugs.openjdk.java.net/browse/JDK-7140863 我研究了“ Java似乎无法正确渲染许多CJK OpenType字体”。因此,这可能与https://bugs.openjdk.java.net/browse/JDK-7140863有关
https://github.com/adobe-fonts/source-han-sans/issues/53 https://github.com/adobe-fonts/source-han-sans/issues/53
I installed the fonts like this 我安装了这样的字体
private void render(Graphics g)
{
try
{
Font font = Font.createFont(Font.TRUETYPE_FONT, new FileInputStream("font.ttf"));
font = font.deriveFont(24F);
g.setFont(font);
g.setColor(Color.BLUE);
g.drawString(String.valueOf(count), 50, 50);
} catch (FileNotFoundException ex)
{
Logger.getLogger(TestFont.class.getName()).log(Level.SEVERE, null, ex);
} catch (FontFormatException | IOException ex)
{
Logger.getLogger(TestFont.class.getName()).log(Level.SEVERE, null, ex);
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.