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

Styled font selection still not working.

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P2 P2
    • None
    • 1.3.0
    • client-libs
    • 2d
    • x86
    • windows_nt



      Name: krT82822 Date: 10/14/99


      [10/14/99 eval1127@eng -- as of the RA (1.3.0 build "I"), this problem still occurs. While at least one of the bugs below is marked as being fixed in kestrel, there's
      no way for me to verify this directly. Thus, am filing reference bug, to clarify what build the problem is fixed by.]

      Bug reports about Fonts have been reported several times in the past. Every so often they are reported to be fixed. However the problems reported in Bug ID: 4209476, 4261014 and 4209476 still persist in jdk 1.3beta.

      The following Application demonstrates this. It creates a JTable that is filled with all fonts returned from GraphicsEnvironment.getLocalGraphicsEnvironment().getAllFonts()
      and then creates Bold and/or Italic variants.

      This sample exposes several bugs.

      1. Once a font of a certain family and style has been created
      all attempts to create a font of the same size with different styles fail.

      1.a For the fonts installed with the JDK it works once and then fails.

      2. The old fonts dialog etc. create bad family names.
      E.g. dialog.bold is not a family name.

      3. Creating the bold variant of family dialog.bold returns a completely different font namely Arial.

      Version information:
      java version "1.3beta"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.3beta-O)
      Java(TM) HotSpot Client VM (build 1.3beta-O, mixed mode)

      It is very important for font selection to work flawlessly
      compared to Windows/MFC otherwise Java Apps are not competitive in the marketplace.

      Source for sample:

      package fonttest;

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

      public class Frame1 extends JFrame {
      BorderLayout borderLayout1 = new BorderLayout();
      JScrollPane jScrollPane1 = new JScrollPane();
      FontTableModel ftm = new FontTableModel(GraphicsEnvironment.getLocalGraphicsEnvironment().getAllFonts());
      JTable jTable1 = new JTable(ftm);
      JLabel l = new JLabel();

      //Construct the frame
        public Frame1() {
      enableEvents(AWTEvent.WINDOW_EVENT_MASK);
      this.getContentPane().setLayout(borderLayout1);
      this.setSize(new Dimension(400, 300));
      this.setTitle("Frame Title");
      this.getContentPane().add(jScrollPane1, BorderLayout.CENTER);
      jScrollPane1.getViewport().add(jTable1, null);
      jTable1.setDefaultRenderer(Font.class, ftm);
      validate();
      show();
      }

        protected void processWindowEvent(WindowEvent e) {
      super.processWindowEvent(e);
      if(e.getID() == WindowEvent.WINDOW_CLOSING) System.exit(0);
      }
        public static void main(String[] args) {
      new Frame1();
      }

      class FontTableModel extends AbstractTableModel implements TableCellRenderer
      {

      Font[] fl;
      String headers[] = new String[] {"Family", "Face", "Plain 12", "Bold 12", "Bold 13", "Plain 13", "Italic 13", "BoldItalic 13"};

      public FontTableModel() {fl = new Font[0];}

      public FontTableModel(Font[] f){fl = f;}

      public int getRowCount(){return fl.length;}

      public int getColumnCount(){return 8;}

      public String getColumnName(int parm1){return headers[parm1];}

      public Class getColumnClass(int parm1) {
      if (parm1 < 2)
      return String.class;
      else
      return Font.class;
      }
      public Object getValueAt(int parm1, int parm2)
      {
      switch (parm2)
      {
      case 0: return fl[parm1].getFamily();
      case 1: return fl[parm1].getFontName();
      case 2: return fl[parm1].deriveFont(12f);
      case 3: return new Font(fl[parm1].getFamily(),Font.BOLD, 12);
      case 4: return new Font(fl[parm1].getFamily(),Font.BOLD, 13);
      case 5: return new Font(fl[parm1].getFamily(),Font.PLAIN, 13);
      case 6: return new Font(fl[parm1].getFamily(),Font.ITALIC, 13);
      case 7: return new Font(fl[parm1].getFamily(),Font.ITALIC+Font.BOLD,13);
      }
      return "??";
      }

      public Component getTableCellRendererComponent(JTable t, Object v, boolean issel, boolean parm4, int r, int c)
      {
      Font f = (Font) v;
      l.setText(f.getFontName());
      l.setFont(f);
      return l;
      }
      }
      }
      (Review ID: 96230)
      ======================================================================

            pkejriwasunw Parry Kejriwal (Inactive)
            kryansunw Kevin Ryan (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: