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

Type1 hinting support is missing

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 6
    • 6
    • client-libs
    • None
    • 2d
    • b53
    • generic
    • generic

      At the moment java font rasterizer only supports hinting for Truetype fonts.
      However, Type1 fonts are commonplace on Solaris/Linux platforms and they
      often look not very good without hinting.

      To reproduce one may use following test
      (cour.pfa font is required, results are saved to new.png file):

      import java.io.*;
      import java.util.*;
      import java.awt.*;
      import java.awt.image.*;
      import javax.imageio.*;

      public class Visual {

       private static void tryFont(String fontFile, String testStr, float sz1, float sz2) {
        try {
          System.err.println("Testing "+fontFile);

          Font f = Font.createFont(Font.TYPE1_FONT, new FileInputStream(fontFile));

          BufferedImage bi = new BufferedImage(1000, 400, BufferedImage.TYPE_INT_RGB);
          Graphics2D g2 = (Graphics2D) bi.getGraphics();
          g2.setColor(Color.WHITE);
          g2.setFont(f);

          int off = 10;

          for(float sz=sz1; sz < sz2; sz+=1.0) {
            off += (int) sz+5;
            f = f.deriveFont(Font.PLAIN, sz);
            g2.setFont(f);
            g2.drawString(""+sz+" "+testStr, 10, off);
          }

          ImageIO.write(bi, "png", new File("new.png"));
          
          System.err.println("Test done");
         } catch (Exception e) {
           System.err.println("Failed to test "+fontFile+" because of " + e);
         }
       }

       public static void main(String[] args) {
           tryFont("cour.pfa", "0123456789 abcdefghijklmnopqrstxyz ABCDEFGHIJKLMNOPQRSTXYZ !\"()[]/\\%$#@^&*-+=_", 7, 20);
       }
      }

            igor Igor Nekrestyanov (Inactive)
            igor Igor Nekrestyanov (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: