/***************************************************************************** FontInfo.java An applet to show FontMetrics information bruce.miller@nist.gov (NIST is a part of the US Government; software is therefore not subject to copyright) ******************************************************************************/ package test; import java.applet.*; import java.awt.*; import gui.*; public class FontInfo extends Applet { Toolkit toolkit; String fontnames[], stylenames[] = new String[3]; ChoiceInput fontChoice, styleChoice; IntegerInput sizeField; Checkbox patchField; Button describeButton; SampleCanvas sample; TextArea output; public void init() { stylenames[Font.PLAIN] = "Plain"; stylenames[Font.BOLD] = "Bold"; stylenames[Font.ITALIC] = "Italic"; setLayout(new StackLayout(StackLayout.VERTICAL)); toolkit = getToolkit(); fontnames = toolkit.getFontList(); add("TopLeft",fontChoice = new ChoiceInput("Font Name",fontnames)); add("TopLeft",sizeField = new IntegerInput("Font Size",12,10,2,32)); add("TopLeft",styleChoice=new ChoiceInput("Font Style",stylenames)); add("TopLeft",patchField = new Checkbox("Apply Patch?",null,false)); add("TopCenter", describeButton = new Button("Describe Font")); add("Fill",sample = new SampleCanvas()); add("Fill",output = new TextArea()); } void describeFont() { try { String name = fontChoice.getChoice(); int size = sizeField.intValue(); int snum = styleChoice.getSelectedIndex(); String style = styleChoice.getChoice(); boolean patched = patchField.getState(); Font font = new Font(name,snum,size); FontMetrics orig = getFontMetrics(font); FontMetrics metrics = (patched ? PatchFontMetrics.patch(orig) : orig); sample.setMetrics(font,metrics); output.setText("Font : " + name + " size = " + size + " style= " + style+ ", Is " + (patched ? "" : "not") + " patched\n"); output.appendText("Height = " + metrics.getHeight() + "\n"); output.appendText("Ascent = " + metrics.getAscent() + " MaxAscent = " + metrics.getMaxAscent() + "\n"); output.appendText("Descent = " + metrics.getDescent() + " MaxDescent = " + metrics.getMaxDescent() + "\n"); output.appendText("Leading = " + metrics.getLeading() + "\n"); output.appendText("MaxAdvance = " + metrics.getMaxAdvance() + "\n"); String interesting = "Wix"; for(int i=0; i