HOWTO: Using TrueType Fonts in Java

ID: Q184067


The information in this article applies to:
  • Microsoft virtual machine
  • Microsoft SDK for Java, versions 2.0, 2.01, 2.02, 3.0, 3.1, 3.2


SUMMARY

The java.awt.Font class represents a font in a platform-independent way. This class restricts the programmer to using a small subset of the fonts installed on a user's system. Microsoft's virtual machine exposes a class to access all of the TrueType fonts installed on the user's system.


MORE INFORMATION

The com.ms.awt.FontX class provides access to all of the fonts that are installed on the user's system. This class creates a new font with the specified name, style, and point size. It is used to access system fonts on the Microsoft Win32 platform not otherwise available in Java (for example, the "symbol" font). This class is available only for the Microsoft virtual machine.

Sample Code


   public AWTFontXDemo()
   {
      appFrame = new Frame("TrueType Font Demo");
      appFrame.setLayout(new BorderLayout());
      edit = new TextArea("Enter some text");
      button = new Button("Change Font");
      appFrame.add(edit,"Center");
      appFrame.add(button,"South");
      button.addActionListener(this);
      appFrame.setSize(320,200);
      appFrame.setVisible(true);
   }

   public void actionPerformed(ActionEvent ae)
   {
      UIFontDialog dialog = new
      UIFontDialog(FxToolkit.getHelperUIFrame());
 dialog.show();
 FontX font = (FontX)dialog.getFxFont();
      edit.setFont(font);
      edit.repaint();
   }
}
 


REFERENCES

For the latest Knowledge Base articles and other support information on Visual J++ and the SDK for Java, please see the following pages on the Microsoft Technical Support site:

http://support.microsoft.com/support/visualj/

http://support.microsoft.com/support/java/

Additional query words: font truetype

Keywords : kbSDKJava300 kbSDKJava310 AWTPkg kbSDKJava320
Version : WINDOWS:2.0,2.01,2.02,3.0,3.1,3.2
Platform : WINDOWS
Issue type : kbhowto


Last Reviewed: November 16, 1999
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.