JDK-4279855 : drawString() displays wrong glyphs in symbol fonts (e.g., Wingding)
  • Type: Bug
  • Component: client-libs
  • Sub-Component: 2d
  • Affected Version: 1.2.2
  • Priority: P4
  • Status: Closed
  • Resolution: Not an Issue
  • OS: windows_nt
  • CPU: x86
  • Submitted: 1999-10-11
  • Updated: 1999-12-16
  • Resolved: 1999-12-16

Name: dbT83986			Date: 10/10/99

The following program draws a string "& W w h q e" to a graphic object with the font Wingding.ttf (this one is installed on all Win platforms). This should result in glyphs like a book, a cross and waves - but only rectangles are displayed.

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

public class FontTest extends JPanel{
    public FontTest() {
        GraphicsEnvironment gEnv = GraphicsEnvironment.getLocalGraphicsEnvironment();
        String envfonts[] = gEnv.getAvailableFontFamilyNames();

        setFont(new Font("Wingdings",Font.PLAIN, 48));

    public void paintComponent (Graphics g) {
        super.paintComponent( g );
        Graphics2D g2 = (Graphics2D) g;
        int w = getWidth();
        int h = getHeight();

        String text = "& W w h q e";
        FontMetrics metrics = g2.getFontMetrics();
        int width = metrics.stringWidth( text );
        int height = metrics.getHeight();
        g2.drawString( text, w/2-width/2, h/2-height/2 );

    public static void main(String s[]) {
        JFrame f = new JFrame("FontTest");
        f.addWindowListener(new WindowAdapter() {
            public void windowClosing(WindowEvent e) {System.exit(0);}
        f.getContentPane().add(new FontTest(), BorderLayout.CENTER);

        f.setSize(new Dimension(550,250));
(Review ID: 96318) 

EVALUATION The font being used is "Wingding" which has a special encoding - the string that is being entered is the Uincode equivalent of ascii - if you enter the correct range of Unicode Dingbats range in 0x2700 to 0x27be - you should get the right glyphs to display. In this case what you are asking to do is by using the font "Wingding" display the characters "& W w h" etc. the font does not have these so obviously it is going to draw missing glyphs ( boxes ). Thus it is not a bug. parry.kejriwal@eng 1999-12-16