Créer java.awt.Police de google / noto font


J'ai installé les polices noto (https://www.google.com/get/noto / ) sur mon système mais lorsque j'essaie d'utiliser certaines polices (chinois traditionnel, chinois simplifié), je reçois juste un espace vide:

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);

entrez la description de l'image ici

A-t-il quelque chose à voir avec le format OTF et les symboles non latins? Existe - t-il un moyen d'utiliser ces polices-afin qu'elles s'affichent correctement?

Author: Andrew Thompson, 2018-07-26

2 answers

J'ai recherché que "Java semble ne pas rendre correctement de nombreuses polices CJK OpenType". Donc, cela peut être lié à https://bugs.openjdk.java.net/browse/JDK-7140863

Https://github.com/adobe-fonts/source-han-sans/issues/53

 0
Author: Lesya, 2018-07-27 07:51:56

J'ai installé les polices comme ceci

    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);
        }
    }
 0
Author: , 2018-07-27 15:51:45