United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: JDK-6320281 Type1 hinting support is missing
JDK-6320281 : Type1 hinting support is missing

Details
Type:
Bug
Submit Date:
2005-09-06
Status:
Resolved
Updated Date:
2010-04-04
Project Name:
JDK
Resolved Date:
2005-09-19
Component:
client-libs
OS:
generic
Sub-Component:
2d
CPU:
generic
Priority:
P4
Resolution:
Fixed
Affected Versions:
6
Fixed Versions:

Related Reports
Relates:

Sub Tasks

Description
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);
 }
}

                                    

Comments
EVALUATION

Some basic support for type1 hints was implemented
(enabled by default for all type1 fonts).
At the moment following hint functionality is supported:
  - hstem/vstem
  - dotsection
  - BlueValues/OtherBlues
  - type1 hint replacements

Obviously, hinting support is not complete and need to be 
enhanced further but this will be tracked under separate bug ids.
                                     
2005-09-12



Hardware and Software, Engineered to Work Together