Incorrect rendering of Noto Sans Telugu font when using java.awt.Graphics drawString()

Viewed 71

I am using Java's java.awt.Graphics drawString() method to render some text on an image. The font that I am using is Noto Sans Telugu and java version is 1.8.0_291. But the rendering of the text on the image is incorrect. Text is getting rendered using code similar to below code:

        String key = "గ్గిం";
        BufferedImage bufferedImage = new BufferedImage(170, 30, BufferedImage.TYPE_INT_RGB);
        Graphics graphics = bufferedImage.getGraphics();
        graphics.setColor(Color.LIGHT_GRAY);
        graphics.fillRect(0, 0, 200, 50);
        graphics.setColor(Color.BLACK);
        graphics.setFont(Font.createFont(Font.TRUETYPE_FONT, new BufferedInputStream(new FileInputStream("/Users/abhishek.bansal/Downloads/Noto_Sans_Telugu/static/NotoSansTelugu/NotoSansTelugu-Regular.ttf"))).deriveFont(20f));
        graphics.drawString(key, 10, 25);
        ImageIO.write(bufferedImage, "jpg", new File("/Users/abhishek.bansal/Downloads/image.jpg"));
        System.out.println("Image Created");

The text should be rendered as in the first line of the code block, but instead gets rendered like this. Is this a problem with the font or a bug in the Java's graphics library? Or is it probably a bug in the implementation above?

0 Answers
Related