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

Ligatures not Rendering for TrueType Fonts

    Details

    • Subcomponent:
      2d
    • CPU:
      x86_64
    • OS:
      generic

      Description

      ADDITIONAL SYSTEM INFORMATION :
      I'm running a mac with OSX on the latest release of Java 10 (build 10.0.1+10), using NetBeans IDE 8.2 (Build 201609300101)

      A DESCRIPTION OF THE PROBLEM :
      NOTE: I have marked this as an OSX problem, but have also reproduced it on Windows environments

      I've encountered a bug that appears when using TrueType fonts. Specifically those created in FontForge (although they appear when rendered outside of Java environments).

      Here is a very simple font I've which activates the bug: https://drive.google.com/file/d/1I0mzw_cX-WFXddji0GHEu9AhoBDJ81OA/view?usp=sharing

      If you load the font via another text program (notepad in Windows or TextEdit in OSX), typing capital "AB" will result in the correct behavior (see Expected Result) of a ligature for AB being rendered.

      REGRESSION : Last worked in version 10.0.1

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      1) Install linked font (in description) to local environment (only necessary if selecting font from OS based on family name)
      2) Create font object via
          - Font font = new Font("Untitled1", Font.PLAIN, 42);
          OR
          - Font font = Font.createFont(Font.TRUETYPE_FONT, new File(<PATH TO FONT>));
      3) On a simple Swing form, create a JTextField and set its font to what you've just loaded.
      4) Run the Form
      5) In the JTextBox on the running form, type capital "AB" with no spaces

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      As you type A, a crude "1" should be displayed. As you type B, a crude "3" should not be displayed. The "3" character is the ligature which represents a combination of A and B when typed together with no spaces.
      ACTUAL -
      As you type A, a crude "1" appears. As you type B, a crude "2" appears. No ligature for the two is displayed.

      ---------- BEGIN SOURCE ----------
      // You must install the linked font to the local environment before this code will run correctly
      // OR use the commented code with the path to the font (which you still must download)
      import java.awt.Font;

      public class TestFontBug extends javax.swing.JFrame {
          public TestFontBug() {
              initComponents();
      Font font = new Font("Untitled1", Font.PLAIN, 42);

              // ALTERNATE FONT LOADING METHOD (results will be the same)
              // Font font = Font.createFont(Font.TRUETYPE_FONT, new File(<PATH TO FONT>));

              jTextField1.setFont(font);
          }
                           
          private void initComponents() {

              jTextField1 = new javax.swing.JTextField();

              setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

              jTextField1.setText("jTextField1");

              javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
              getContentPane().setLayout(layout);
              layout.setHorizontalGroup(
                  layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                  .addGroup(layout.createSequentialGroup()
                      .addGap(136, 136, 136)
                      .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, 197, javax.swing.GroupLayout.PREFERRED_SIZE)
                      .addContainerGap(67, Short.MAX_VALUE))
              );
              layout.setVerticalGroup(
                  layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                  .addGroup(layout.createSequentialGroup()
                      .addGap(108, 108, 108)
                      .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, 122, javax.swing.GroupLayout.PREFERRED_SIZE)
                      .addContainerGap(70, Short.MAX_VALUE))
              );

              pack();
          }

          public static void main(String args[]) {
              new TestFontBug().setVisible(true);
          }
                     
          private javax.swing.JTextField jTextField1;
      }
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      I have not found one.

      FREQUENCY : always


        Attachments

          Activity

            People

            • Assignee:
              prr Philip Race
              Reporter:
              webbuggrp Webbug Group
            • Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: