Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8236996

Incorrect Roboto font rendering on Windows with subpixel antialiasing

    XMLWordPrintable

Details

    • 2d
    • b10
    • windows

    Backports

      Description

        The problem can be reproduced on Windows 10 (in particular, version 1809, build 17763.914) for an old version of Roboto font, attached to this ticket.
        Steps to reproduce:
        1) Install all font variants from the provided archive one-by-one in alphabetical order (black, bold, light, medium, regular, thin).
        2) Run the program with source code given below.

        Expected result: "Hello, world!" text is rendered.
        Actual result: unrelated glyphs are rendered (see attached image).

        --- Test program source code ---
        import javax.swing.*;
        import java.awt.*;

        public class FontDrawingTest {
            public static void main(String[] args) {
                SwingUtilities.invokeLater(() -> {
                    JFrame frame = new JFrame();
                    frame.add(new MyComponent());
                    frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
                    frame.setSize(200, 100);
                    frame.setLocationRelativeTo(null);
                    frame.setVisible(true);
                });
            }

            private static class MyComponent extends JComponent {
                @Override
                protected void paintComponent(Graphics g) {
                    ((Graphics2D) g).setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,
                                                      RenderingHints.VALUE_TEXT_ANTIALIAS_LCD_HRGB);
                    g.setFont(new Font("Roboto", Font.PLAIN, 24));
                    g.drawString("Hello, world!", 25, 35);
                }
            }
        }
        --------------------------------

        Attachments

          Issue Links

            Activity

              People

                dbatrak Dmitry Batrak
                dbatrak Dmitry Batrak
                Votes:
                0 Vote for this issue
                Watchers:
                5 Start watching this issue

                Dates

                  Created:
                  Updated:
                  Resolved: