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

Some OpenType CFF fonts don't render correctly.

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P4
    • Resolution: Duplicate
    • Affects Version/s: 7u51
    • Fix Version/s: None
    • Component/s: client-libs
    • Labels:
    • Subcomponent:
      2d
    • CPU:
      x86_64
    • OS:
      linux_ubuntu

      Description

      FULL PRODUCT VERSION :
      java version "1.7.0_55"
      OpenJDK Runtime Environment (IcedTea 2.4.7) (7u55-2.4.7-1ubuntu1~0.12.04.2)
      OpenJDK 64-Bit Server VM (build 24.51-b03, mixed mode)


      ADDITIONAL OS VERSION INFORMATION :
      Linux xxxxxxxx 3.13.0-30-generic #54~precise2-Ubuntu SMP Wed Jun 11 16:11:17 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux

      Also on Windows 7 and Mac OSX Maverick

      A DESCRIPTION OF THE PROBLEM :
      Originally reported here:
      https://github.com/adobe-fonts/source-han-sans/issues/53

      As clearly visible from the screenshots attached, the fonts don't render the strings correctly. For some fonts, there is not drawing. For others, the glyphs are drawn on top of one another. For yet others, the rendering quality is inferior.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Try to draw some text with the SourceHanSans-Regular.otf which is available from the following github project: https://github.com/adobe-fonts/source-han-sans/

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Proper font rendering.
      ACTUAL -
      Poor rendering.

      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      There was no error reported. Even Font.canDisplayUpTo() returned -1 indicating that the font is capable of drawing the text.

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      package com.otf;

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

      public class Main extends JPanel {

          private Font mOriginalFont;

          @Override
          public void paint(Graphics g) {
              super.paint(g);
              try {
                  mOriginalFont = g.getFont();
                  g.drawString("Default font:", 50, 50);
                  g.drawString("Java version: " + System.getProperty("java.version"), 300, 50);
                  Graphics2D g2 = (Graphics2D) g;
                  draw("SourceHanSansSC-Regular.otf", "镺陯 曋橪橤 馻噈嫶 ", g2, 100);
                  draw("SourceHanSansK-Regular.otf", "아무 것도 선택 안하면 모든 소스에서 단어를 가져옵니다", g2, 150);
                  draw("SourceHanSans-Regular.otf", "镺陯 曋橪橤 馻噈嫶 ", g2, 200);

              } catch (Exception e) {
                  e.printStackTrace();
              }
          }

          private void draw(String fontName, String text, Graphics2D g, int y) throws Exception {
              Font font = Font.createFont(Font.TRUETYPE_FONT, getClass().getClassLoader().getResourceAsStream(fontName));
              font = font.deriveFont(40f);
              g.drawString(fontName + ":", 50, y);
              g.setFont(font);
              if (font.canDisplayUpTo(text) != -1) {
                  System.out.println("Can't display all chars of \"" + text + "\" using font " + font.getName());
              }
              g.drawString(text, 300, y);
              g.setFont(mOriginalFont);
          }

          public static void main(String args[]) {
              Main main = new Main();
              JFrame jFrame = new JFrame();
              jFrame.setContentPane(main);
              jFrame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
              jFrame.setBounds(0,0,600,500);
              jFrame.setVisible(true);
          }
      }

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

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                webbuggrp Webbug Group
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: