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

[macosx] A font has different behaviour for ligatures depending on its creation mode

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P2
    • 9
    • 7, 8, 9
    • client-libs
    • 2d
    • b96
    • x86
    • os_x

    Backports

      Description

        FULL PRODUCT VERSION :
        version "1.7.0-u6-b01"
        OpenJDK Runtime Environment (build 1.7.0-u6-b01-20120314)
        OpenJDK 64-Bit Server VM (build 23.0-b16, mixed mode)


        ADDITIONAL OS VERSION INFORMATION :
        Mac OS 10.6.8


        A DESCRIPTION OF THE PROBLEM :
        Latin ligatures are only active for fonts which where created using
        Font.createFont(). The exact same font, created with new Font(), does not honour the TextAttribute.LIGATURES attribute correctly.



        STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
        Get the LinuxLibertine font from http://www.linuxlibertine.org/.
        Install the font LinLibertine_R_G.ttf and put a copy of it in the same folder as the java test code.
        Compile and run the test code.


        EXPECTED VERSUS ACTUAL BEHAVIOR :
        EXPECTED -
        Same display for both labels, with "ff" ligature in the word "efficace".

        ACTUAL -
        The "ff" ligature is done for the lower label (whose font is directly opened by java), but is not available for the upper label (whose font is taken from the system).


        REPRODUCIBILITY :
        This bug can be reproduced always.

        ---------- BEGIN SOURCE ----------
        import java.awt.Dimension;
        import java.awt.Font;
        import java.awt.FontFormatException;
        import java.awt.Graphics;
        import java.awt.Graphics2D;
        import java.awt.font.TextAttribute;
        import java.awt.font.TextLayout;
        import java.io.FileInputStream;
        import java.io.FileNotFoundException;
        import java.io.IOException;
        import java.util.HashMap;
        import java.util.Map;

        import javax.swing.BoxLayout;
        import javax.swing.JFrame;
        import javax.swing.JLabel;
        import javax.swing.JPanel;
        import javax.swing.SwingUtilities;


        public class TestLiber {

        Font createFont1() {
        Font f= new Font("Linux Libertine G", Font.PLAIN, 28);

        Map<TextAttribute, Object> map= new HashMap<TextAttribute, Object>();
        map.put(TextAttribute.SIZE, 60);
        map.put(TextAttribute.KERNING, TextAttribute.KERNING_ON);
        map.put(TextAttribute.LIGATURES, TextAttribute.LIGATURES_ON);
        f= f.deriveFont(map);
        return f;
        }

        Font createFont2() {
        try {
        Font f= Font.createFont(Font.TRUETYPE_FONT, new FileInputStream("LinLibertine_R_G.ttf"));

        Map<TextAttribute, Object> map= new HashMap<TextAttribute, Object>();
        map.put(TextAttribute.SIZE, 60);
        map.put(TextAttribute.KERNING, TextAttribute.KERNING_ON);
        map.put(TextAttribute.LIGATURES, TextAttribute.LIGATURES_ON);
        f= f.deriveFont(map);
        return f;
        } catch (Exception e) {
        throw new RuntimeException(e);
        }
        }

        public TestLiber() throws FileNotFoundException, FontFormatException, IOException {
        JFrame frame= new JFrame();

        String string = "il estoit efficace ect. nettoyer";


        JLabel label= new JLabel(string);
        JLabel label2= new JLabel(string);

        label.setFont(createFont1());
        label2.setFont(createFont2());
        frame.getContentPane().setLayout(new BoxLayout(frame.getContentPane(),BoxLayout.PAGE_AXIS));
        frame.add(label);
        frame.add(label2);
        frame.pack();
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.setVisible(true);
        }


        public static void main(String[] args) {
        SwingUtilities.invokeLater(new Runnable() {

        public void run() {
        try {
        new TestLiber();
        } catch (Exception e) {
        e.printStackTrace();
        throw new RuntimeException(e);

        }
        }

        });
        }
        }

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

        CUSTOMER SUBMITTED WORKAROUND :
        directly use the files for the fonts and bypass the system ?

        Attachments

          Issue Links

            Activity

              People

                prr Philip Race
                webbuggrp Webbug Group
                Votes:
                0 Vote for this issue
                Watchers:
                5 Start watching this issue

                Dates

                  Created:
                  Updated:
                  Resolved:
                  Imported:
                  Indexed: