<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<!--NewPage-->
<html>
<head>
<!-- Generated by javadoc on Wed Jul 28 01:21:15 GMT 1999 -->
<title>
  Class java.awt.FontMetrics
</title>
</head>
<body>
<a name="_top_"></a>
<pre>
<a href="packages.html">All Packages</a>  <a href="tree.html">Class Hierarchy</a>  <a href="Package-java.awt.html">This Package</a>  <a href="java.awt.Font.html#_top_">Previous</a>  <a href="java.awt.Frame.html#_top_">Next</a>  <a href="AllNames.html">Index</a></pre>
<hr>
<h1>
  Class java.awt.FontMetrics
</h1>
<pre>
<a href="java.lang.Object.html#_top_">java.lang.Object</a>
   |
   +----java.awt.FontMetrics
</pre>
<hr>
<dl>
  <dt> public abstract class <b>FontMetrics</b>
  <dt> extends <a href="java.lang.Object.html#_top_">Object</a>
  <dt> implements <a href="java.io.Serializable.html#_top_">Serializable</a>
</dl>
A font metrics object, which gives information about the rendering 
 of a particular font on a particular screen. Note that the 
 implementations of these methods are inefficient, they are usually 
 overridden with more efficient toolkit-specific implementations.
 <p>
 <b>Note to subclassers</b>: Since many of these methods form closed
 mutually recursive loops, you must take care that you implement
 at least one of the methods in each such loop in order to prevent
 infinite recursion when your subclass is used.
 In particular, the following is the minimal suggested set of methods
 to override in order to ensure correctness and prevent infinite
 recursion (though other subsets are equally feasible):
 <ul>
 <li><a href=#getAscent>getAscent</a>()
 <li><a href=#getAscent>getDescent</a>()
 <li><a href=#getLeading>getLeading</a>()
 <li><a href=#getMaxAdvance>getMaxAdvance</a>()
 <li><a href="#charWidth(char)">charWidth</a>(char ch)
 <li><a href="#charsWidth(char[], int, int)">charsWidth</a>(char data[], int off, int len)
 </ul>
 <p>
 <img src="images-awt/FontMetrics-1.gif" border=15 align
 ALIGN=right HSPACE=10 VSPACE=7>
 When an application asks AWT to place a character at the position 
 (<i>x</i>,&nbsp;<i>y</i>), the character is placed so that its 
 reference point (shown as the dot in the accompanying image) is 
 put at that position. The reference point specifies a horizontal 
 line called the <i>baseline</i> of the character. In normal 
 printing, the baselines of characters should align. 
 <p> 
 In addition, every character in a font has an <i>ascent</i>, a 
 <i>descent</i>, and an <i>advance width</i>. The ascent is the 
 amount by which the character ascends above the baseline. The 
 descent is the amount by which the character descends below the 
 baseline. The advance width indicates the position at which AWT  
 should place the next character. 
 <p>
 If the current character is placed with its reference point 
 at the position (<i>x</i>,&nbsp;<i>y</i>), and 
 the character's advance width is <i>w</i>, then the following 
 character is placed with its reference point at the position 
 (<i>x&nbsp;</i><code>+</code><i>&nbsp;w</i>,&nbsp;<i>y</i>). 
 The advance width is often the same as the width of character's 
 bounding box, but need not be so. In particular, oblique and 
 italic fonts often have characters whose top-right corner extends 
 slightly beyond the advance width. 
 <p>
 An array of characters or a string can also have an ascent, a 
 descent, and an advance width. The ascent of the array is the 
 maximum ascent of any character in the array. The descent is the 
 maximum descent of any character in the array. The advance width 
 is the sum of the advance widths of each of the characters in the 
 array.
<p>
<dl>
    <dt> <b>See Also:</b>
    <dd> <a href="java.awt.Font.html#_top_">Font</a>
</dl>
<hr>
<a name="index"></a>
<h2>
  <img src="images/variable-index.gif" width=207 height=38 alt="Variable Index">
</h2>
<dl>
  <dt> <img src="images/magenta-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#font"><b>font</b></a>
  <dd>  The actual font.
</dl>
<h2>
  <img src="images/constructor-index.gif" width=275 height=38 alt="Constructor Index">
</h2>
<dl>
  <dt> <img src="images/yellow-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#FontMetrics(java.awt.Font)"><b>FontMetrics</b></a>(Font)
  <dd>  Creates a new <code>FontMetrics</code> object for finding out 
 height and width information about the specified font and  
 specific character glyphs in that font.
</dl>
<h2>
  <img src="images/method-index.gif" width=207 height=38 alt="Method Index">
</h2>
<dl>
  <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#bytesWidth(byte[], int, int)"><b>bytesWidth</b></a>(byte[], int, int)
  <dd> 
 Returns the total advance width for showing the specified array
 of bytes in this Font.
  <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#charsWidth(char[], int, int)"><b>charsWidth</b></a>(char[], int, int)
  <dd> 
 Returns the total advance width for showing the specified array
 of characters in this Font.
  <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#charWidth(char)"><b>charWidth</b></a>(char)
  <dd> 
 Returns the advance width of the specified character in this Font.
  <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#charWidth(int)"><b>charWidth</b></a>(int)
  <dd> 
 Returns the advance width of the specified character in this Font.
  <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#getAscent()"><b>getAscent</b></a>()
  <dd>  Determines the <em>font ascent</em> of the font described by this 
 font metric.
  <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#getDescent()"><b>getDescent</b></a>()
  <dd>  Determines the <em>font descent</em> of the font described by this 
 font metric.
  <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#getFont()"><b>getFont</b></a>()
  <dd>  Gets the font described by this font metric.
  <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#getHeight()"><b>getHeight</b></a>()
  <dd>  Gets the standard height of a line of text in this font.
  <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#getLeading()"><b>getLeading</b></a>()
  <dd>  Determines the <em>standard leading</em> of the font described by 
 this font metric.
  <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#getMaxAdvance()"><b>getMaxAdvance</b></a>()
  <dd>  Gets the maximum advance width of any character in this Font.
  <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#getMaxAscent()"><b>getMaxAscent</b></a>()
  <dd>  Determines the maximum ascent of the font described by this font 
 metric.
  <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#getMaxDecent()"><b>getMaxDecent</b></a>()
  <dd>  For backward compatibility only.
<b>Deprecated.</b>
  <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#getMaxDescent()"><b>getMaxDescent</b></a>()
  <dd>  Determines the maximum descent of the font described by this font 
 metric.
  <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#getWidths()"><b>getWidths</b></a>()
  <dd>  Gets the advance widths of the first 256 characters in the Font.
  <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#stringWidth(java.lang.String)"><b>stringWidth</b></a>(String)
  <dd> 
 Returns the total advance width for showing the specified String
 in this Font.
  <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#toString()"><b>toString</b></a>()
  <dd> 
 Returns a representation of this <code>FontMetric</code> 
 object's values as a string.
</dl>
<a name="variables"></a>
<h2>
  <img src="images/variables.gif" width=153 height=38 alt="Variables">
</h2>
<a name="font"><img src="images/magenta-ball.gif" width=12 height=12 alt=" o "></a>
<b>font</b>
<pre>
 protected <a href="java.awt.Font.html#_top_">Font</a> font
</pre>
<dl>
  <dd> The actual font.<p>
  <dd><dl> 
    <dt> <b>See Also:</b>
    <dd> <a href="#getFont">getFont</a>
  </dl></dd>
</dl>
<a name="constructors"></a>
<h2>
  <img src="images/constructors.gif" width=231 height=38 alt="Constructors">
</h2>
<a name="FontMetrics"></a>
<a name="FontMetrics(java.awt.Font)"><img src="images/yellow-ball.gif" width=12 height=12 alt=" o "></a>
<b>FontMetrics</b>
<pre>
 protected FontMetrics(<a href="java.awt.Font.html#_top_">Font</a> font)
</pre>
<dl>
  <dd> Creates a new <code>FontMetrics</code> object for finding out 
 height and width information about the specified font and  
 specific character glyphs in that font.
<p>
  <dd><dl>
    <dt> <b>Parameters:</b>
    <dd> font - the font
    <dt> <b>See Also:</b>
    <dd> <a href="java.awt.Font.html#_top_">Font</a>
  </dl></dd>
</dl>
<a name="methods"></a>
<h2>
  <img src="images/methods.gif" width=151 height=38 alt="Methods">
</h2>
<a name="getFont()"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a>
<a name="getFont"><b>getFont</b></a>
<pre>
 public <a href="java.awt.Font.html#_top_">Font</a> getFont()
</pre>
<dl>
  <dd> Gets the font described by this font metric.
<p>
  <dd><dl>
    <dt> <b>Returns:</b>
    <dd> the font described by this font metric.
  </dl></dd>
</dl>
<a name="getLeading()"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a>
<a name="getLeading"><b>getLeading</b></a>
<pre>
 public int getLeading()
</pre>
<dl>
  <dd> Determines the <em>standard leading</em> of the font described by 
 this font metric. The standard leading (interline spacing) is the 
 logical amount of space to be reserved between the descent of one 
 line of text and the ascent of the next line. The height metric is 
 calculated to include this extra space.
<p>
  <dd><dl>
    <dt> <b>Returns:</b>
    <dd> the standard leading of the font.
    <dt> <b>See Also:</b>
    <dd> <a href="#getHeight">getHeight</a>, <a href="#getAscent">getAscent</a>, <a href="#getDescent">getDescent</a>
  </dl></dd>
</dl>
<a name="getAscent()"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a>
<a name="getAscent"><b>getAscent</b></a>
<pre>
 public int getAscent()
</pre>
<dl>
  <dd> Determines the <em>font ascent</em> of the font described by this 
 font metric. The font ascent is the distance from the font's 
 baseline to the top of most alphanumeric characters. Some 
 characters in the font may extend above the font ascent line.
<p>
  <dd><dl>
    <dt> <b>Returns:</b>
    <dd> the font ascent of the font.
    <dt> <b>See Also:</b>
    <dd> <a href="#getMaxAscent">getMaxAscent</a>
  </dl></dd>
</dl>
<a name="getDescent()"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a>
<a name="getDescent"><b>getDescent</b></a>
<pre>
 public int getDescent()
</pre>
<dl>
  <dd> Determines the <em>font descent</em> of the font described by this 
 font metric. The font descent is the distance from the font's 
 baseline to the bottom of most alphanumeric characters with 
 descenders. Some characters in the font may extend below the font 
 descent line.
<p>
  <dd><dl>
    <dt> <b>Returns:</b>
    <dd> the font descent of the font.
    <dt> <b>See Also:</b>
    <dd> <a href="#getMaxDescent">getMaxDescent</a>
  </dl></dd>
</dl>
<a name="getHeight()"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a>
<a name="getHeight"><b>getHeight</b></a>
<pre>
 public int getHeight()
</pre>
<dl>
  <dd> Gets the standard height of a line of text in this font.  This
 is the distance between the baseline of adjacent lines of text.
 It is the sum of the leading + ascent + descent.  There is no
 guarantee that lines of text spaced at this distance will be
 disjoint; such lines may overlap if some characters overshoot
 either the standard ascent or the standard descent metric.
<p>
  <dd><dl>
    <dt> <b>Returns:</b>
    <dd> the standard height of the font.
    <dt> <b>See Also:</b>
    <dd> <a href="#getLeading">getLeading</a>, <a href="#getAscent">getAscent</a>, <a href="#getDescent">getDescent</a>
  </dl></dd>
</dl>
<a name="getMaxAscent()"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a>
<a name="getMaxAscent"><b>getMaxAscent</b></a>
<pre>
 public int getMaxAscent()
</pre>
<dl>
  <dd> Determines the maximum ascent of the font described by this font 
 metric. No character extends further above the font's baseline 
 than this height.
<p>
  <dd><dl>
    <dt> <b>Returns:</b>
    <dd> the maximum ascent of any character in the font.
    <dt> <b>See Also:</b>
    <dd> <a href="#getAscent">getAscent</a>
  </dl></dd>
</dl>
<a name="getMaxDescent()"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a>
<a name="getMaxDescent"><b>getMaxDescent</b></a>
<pre>
 public int getMaxDescent()
</pre>
<dl>
  <dd> Determines the maximum descent of the font described by this font 
 metric. No character extends further below the font's baseline 
 than this height.
<p>
  <dd><dl>
    <dt> <b>Returns:</b>
    <dd> the maximum descent of any character in the font.
    <dt> <b>See Also:</b>
    <dd> <a href="#getDescent">getDescent</a>
  </dl></dd>
</dl>
<a name="getMaxDecent()"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a>
<a name="getMaxDecent"><b>getMaxDecent</b></a>
<pre>
 public int getMaxDecent()
</pre>
<dl>
<dd><b> Note: getMaxDecent() is deprecated.</b>
<i>As of JDK version 1.1.1,
 replaced by <code>getMaxDescent()</code>.</i>
<p>
  <dd> For backward compatibility only.
<p>
  <dd><dl>
    <dt> <b>See Also:</b>
    <dd> <a href="#getMaxDescent">getMaxDescent</a>
  </dl></dd>
</dl>
<a name="getMaxAdvance()"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a>
<a name="getMaxAdvance"><b>getMaxAdvance</b></a>
<pre>
 public int getMaxAdvance()
</pre>
<dl>
  <dd> Gets the maximum advance width of any character in this Font. 
 The advance width is the amount by which the current point is
 moved from one character to the next in a line of text.
<p>
  <dd><dl>
    <dt> <b>Returns:</b>
    <dd> the maximum advance width of any character
            in the font, or <code>-1</code> if the 
            maximum advance width is not known.
  </dl></dd>
</dl>
<a name="charWidth(int)"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a>
<a name="charWidth"><b>charWidth</b></a>
<pre>
 public int charWidth(int ch)
</pre>
<dl>
  <dd> Returns the advance width of the specified character in this Font.
 The advance width is the amount by which the current point is
 moved from one character to the next in a line of text.
<p>
  <dd><dl>
    <dt> <b>Parameters:</b>
    <dd> ch - the character to be measured
    <dt> <b>Returns:</b>
    <dd> the advance width of the specified <code>char</code>
                 in the font described by this font metric.
    <dt> <b>See Also:</b>
    <dd> <a href="#charsWidth">charsWidth</a>, <a href="#stringWidth">stringWidth</a>
  </dl></dd>
</dl>
<a name="charWidth(char)"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a>
<a name="charWidth"><b>charWidth</b></a>
<pre>
 public int charWidth(char ch)
</pre>
<dl>
  <dd> Returns the advance width of the specified character in this Font.
 The advance width is the amount by which the current point is
 moved from one character to the next in a line of text.
<p>
  <dd><dl>
    <dt> <b>Parameters:</b>
    <dd> ch - the character to be measured
    <dt> <b>Returns:</b>
    <dd> the advance width of the specified <code>char</code> >
                  in the font described by this font metric.
    <dt> <b>See Also:</b>
    <dd> <a href="#charsWidth">charsWidth</a>, <a href="#stringWidth">stringWidth</a>
  </dl></dd>
</dl>
<a name="stringWidth(java.lang.String)"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a>
<a name="stringWidth"><b>stringWidth</b></a>
<pre>
 public int stringWidth(<a href="java.lang.String.html#_top_">String</a> str)
</pre>
<dl>
  <dd> Returns the total advance width for showing the specified String
 in this Font.
 The advance width is the amount by which the current point is
 moved from one character to the next in a line of text.
<p>
  <dd><dl>
    <dt> <b>Parameters:</b>
    <dd> str - the String to be measured
    <dt> <b>Returns:</b>
    <dd> the advance width of the specified string
                  in the font described by this font metric.
    <dt> <b>See Also:</b>
    <dd> <a href="#bytesWidth">bytesWidth</a>, <a href="#charsWidth">charsWidth</a>
  </dl></dd>
</dl>
<a name="charsWidth(char[], int, int)"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a>
<a name="charsWidth"><b>charsWidth</b></a>
<pre>
 public int charsWidth(char data[],
                       int off,
                       int len)
</pre>
<dl>
  <dd> Returns the total advance width for showing the specified array
 of characters in this Font.
 The advance width is the amount by which the current point is
 moved from one character to the next in a line of text.
<p>
  <dd><dl>
    <dt> <b>Parameters:</b>
    <dd> data - the array of characters to be measured
    <dd> off - the start offset of the characters in the array
    <dd> len - the number of characters to be measured from the array
    <dt> <b>Returns:</b>
    <dd> the advance width of the subarray of the specified
               <code>char</code> array in the font described by 
               this font metric.
    <dt> <b>See Also:</b>
    <dd> <a href="#charWidth(int)">charWidth</a>, <a href="#charWidth(char)">charWidth</a>, <a href="#bytesWidth">bytesWidth</a>, <a href="#stringWidth">stringWidth</a>
  </dl></dd>
</dl>
<a name="bytesWidth(byte[], int, int)"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a>
<a name="bytesWidth"><b>bytesWidth</b></a>
<pre>
 public int bytesWidth(byte data[],
                       int off,
                       int len)
</pre>
<dl>
  <dd> Returns the total advance width for showing the specified array
 of bytes in this Font.
 The advance width is the amount by which the current point is
 moved from one character to the next in a line of text.
<p>
  <dd><dl>
    <dt> <b>Parameters:</b>
    <dd> data - the array of bytes to be measured
    <dd> off - the start offset of the bytes in the array
    <dd> len - the number of bytes to be measured from the array
    <dt> <b>Returns:</b>
    <dd> the advance width of the subarray of the specified
               <code>byte</code> array in the font described by 
               this font metric.
    <dt> <b>See Also:</b>
    <dd> <a href="#charsWidth">charsWidth</a>, <a href="#stringWidth">stringWidth</a>
  </dl></dd>
</dl>
<a name="getWidths()"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a>
<a name="getWidths"><b>getWidths</b></a>
<pre>
 public int[] getWidths()
</pre>
<dl>
  <dd> Gets the advance widths of the first 256 characters in the Font.
 The advance width is the amount by which the current point is
 moved from one character to the next in a line of text.
<p>
  <dd><dl>
    <dt> <b>Returns:</b>
    <dd> an array giving the advance widths of the
                 characters in the font 
                 described by this font metric.
  </dl></dd>
</dl>
<a name="toString()"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a>
<a name="toString"><b>toString</b></a>
<pre>
 public <a href="java.lang.String.html#_top_">String</a> toString()
</pre>
<dl>
  <dd> Returns a representation of this <code>FontMetric</code> 
 object's values as a string.
<p>
  <dd><dl>
    <dt> <b>Returns:</b>
    <dd> a string representation of this font metric.
    <dt> <b>Overrides:</b>
    <dd> <a href="java.lang.Object.html#toString()">toString</a> in class <a href="java.lang.Object.html#_top_">Object</a>
  </dl></dd>
</dl>
<hr>
<pre>
<a href="packages.html">All Packages</a>  <a href="tree.html">Class Hierarchy</a>  <a href="Package-java.awt.html">This Package</a>  <a href="java.awt.Font.html#_top_">Previous</a>  <a href="java.awt.Frame.html#_top_">Next</a>  <a href="AllNames.html">Index</a></pre>
</body>
</html>
