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

Wrong rendering of variation sequences

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P4
    • Resolution: Fixed
    • Affects Version/s: 9, 10
    • Fix Version/s: 11
    • Component/s: client-libs
    • Labels:
      None
    • Subcomponent:
      2d
    • Resolved In Build:
      b20
    • OS:
      windows_10

      Backports

        Description

        If text contains a variation selector character, its base character is not rendered.

        Reproducer:

        -------- BEGIN SOURCE ----------

        import javax.swing.*;
        import java.awt.*;
        import java.awt.font.*;

        public class VariationSelectorTest {
            // A font supporting Unicode variation selectors is required
            private static final Font FONT = new Font("DejaVu Sans", Font.PLAIN, 12);

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

            private static class MyComponent extends JComponent {
                @Override
                protected void paintComponent(Graphics g) {
                    Graphics2D g2d = (Graphics2D) g;
                    FontRenderContext frc = g2d.getFontRenderContext();
                    String text = "a";
                    GlyphVector gv = FONT.layoutGlyphVector(frc, text.toCharArray(), 0, text.length(), Font.LAYOUT_LEFT_TO_RIGHT);
                    g2d.drawGlyphVector(gv, 80, 50);
                    String text2 = "a\ufe00";
                    GlyphVector gv2 = FONT.layoutGlyphVector(frc, text2.toCharArray(), 0, text2.length(), Font.LAYOUT_LEFT_TO_RIGHT);
                    g2d.drawGlyphVector(gv2, 80, 100);
                }
            }
        }

        -------- END SOURCE ----------

        Before running this sample application, 'DejaVu Sans' font (https://dejavu-fonts.github.io/) should be installed onto the system.

        Expected result - two identical letters 'a' are rendered (variation sequence being used is not standard, so it should be rendered just like the base character alone).
        Actual result - only one letter 'a' is rendered (base character case).

        The application runs as expected on latest Java 8 version (1.8.0_144).

          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  srl Steven Loomis
                  Reporter:
                  dbatrak Dmitry Batrak
                • Votes:
                  1 Vote for this issue
                  Watchers:
                  3 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved: