📄 defaultfontmetrics.java
字号:
/** * ======================================== * JFreeReport : a free Java report library * ======================================== * * Project Info: http://www.object-refinery.com/jfreereport/index.html * Project Lead: Thomas Morgner; * * (C) Copyright 2000-2002, by Simba Management Limited and Contributors. * * This library is free software; you can redistribute it and/or modify it under the terms * of the GNU Lesser General Public License as published by the Free Software Foundation; * either version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * See the GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License along with this * library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307, USA. * * */package com.jrefinery.report.ext.barcode;import java.awt.Font;import java.awt.FontMetrics;import java.awt.Graphics;import java.awt.font.LineMetrics;import java.awt.geom.Rectangle2D;import java.text.CharacterIterator;import com.jrefinery.report.targets.pageable.output.G2OutputTarget;import com.jrefinery.report.util.Log;public class DefaultFontMetrics extends FontMetrics{ private FontMetrics backend; public DefaultFontMetrics(Font font) { super(font); backend = G2OutputTarget.createEmptyGraphics().getFontMetrics(font); } /** * Gets the <code>Font</code> described by this * <code>FontMetrics</code> object. * @return the <code>Font</code> described by this * <code>FontMetrics</code> object. */ public Font getFont() { return backend.getFont(); } /** * Determines the <em>standard leading</em> of the * <code>Font</code> described by this <code>FontMetrics</code> * object. The standard leading, or * 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. * @return the standard leading of the <code>Font</code>. * @see #getHeight() * @see #getAscent() * @see #getDescent() */ public int getLeading() { return backend.getLeading(); } /** * Determines the <em>font ascent</em> of the <code>Font</code> * described by this <code>FontMetrics</code> object. The font ascent * is the distance from the font's baseline to the top of most * alphanumeric characters. Some characters in the <code>Font</code> * might extend above the font ascent line. * @return the font ascent of the <code>Font</code>. * @see #getMaxAscent() */ public int getAscent() { return backend.getAscent(); } /** * Determines the <em>font descent</em> of the <code>Font</code> * described by this * <code>FontMetrics</code> object. The font descent is the distance * from the font's baseline to the bottom of most alphanumeric * characters with descenders. Some characters in the * <code>Font</code> might extend * below the font descent line. * @return the font descent of the <code>Font</code>. * @see #getMaxDescent() */ public int getDescent() { return backend.getDescent(); } /** * 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 are * disjoint; such lines may overlap if some characters overshoot * either the standard ascent or the standard descent metric. * @return the standard height of the font. * @see #getLeading() * @see #getAscent() * @see #getDescent() */ public int getHeight() { return backend.getHeight(); } /** * Determines the maximum ascent of the <code>Font</code> * described by this <code>FontMetrics</code> object. No character * extends further above the font's baseline than this height. * @return the maximum ascent of any character in the * <code>Font</code>. * @see #getAscent() */ public int getMaxAscent() { return backend.getMaxAscent(); } /** * Determines the maximum descent of the <code>Font</code> * described by this <code>FontMetrics</code> object. No character * extends further below the font's baseline than this height. * @return the maximum descent of any character in the * <code>Font</code>. * @see #getDescent() */ public int getMaxDescent() { return backend.getMaxDescent(); } /** * For backward compatibility only. * @see #getMaxDescent() * @deprecated As of JDK version 1.1.1, * replaced by <code>getMaxDescent()</code>. */ public int getMaxDecent() { return backend.getMaxDecent(); } /** * Gets the maximum advance width of any character in this * <code>Font</code>. The advance is the * distance from the leftmost point to the rightmost point on the * string's baseline. The advance of a <code>String</code> is * not necessarily the sum of the advances of its characters. * @return the maximum advance width of any character * in the <code>Font</code>, or <code>-1</code> if the * maximum advance width is not known. */ public int getMaxAdvance() { return backend.getMaxAdvance(); } /** * Returns the advance width of the specified character in this * <code>Font</code>. The advance is the * distance from the leftmost point to the rightmost point on the * character's baseline. Note that the advance of a * <code>String</code> is not necessarily the sum of the advances * of its characters. * @param ch the character to be measured * @return the advance width of the specified <code>char</code> * in the <code>Font</code> described by this * <code>FontMetrics</code> object. * @see #charsWidth(char[], int, int) * @see #stringWidth(java.lang.String) */ public int charWidth(int ch) { return backend.charWidth(ch); } /** * Returns the advance width of the specified character in this * <code>Font</code>. The advance is the * distance from the leftmost point to the rightmost point on the * character's baseline. Note that the advance of a * <code>String</code> is not necessarily the sum of the advances * of its characters. * @return the advance width of the specified <code>char</code> * in the <code>Font</code> described by this * <code>FontMetrics</code> object. * @see #charsWidth(char[], int, int) * @see #stringWidth(java.lang.String) */ public int charWidth(char ch) { return backend.charWidth(ch); } /** * Returns the total advance width for showing the specified * <code>String</code> in this <code>Font</code>. The advance * is the distance from the leftmost point to the rightmost point * on the string's baseline. * <p> * Note that the total advance width returned from this method * does not take into account the rendering context. Therefore, * the anti-aliasing and fractional metrics hints can affect the * value of the advance. When enabling the anti-aliasing and * fractional metrics hints, use * <code>getStringBounds(String, Graphics)</code> * instead of this method. The advance of a <code>String</code> is * not necessarily the sum of the advances of its characters. * <p> * @param str the <code>String</code> to be measured * @return the advance width of the specified <code>String</code> * in the <code>Font</code> described by this * <code>FontMetrics</code>. * @see #bytesWidth(byte[], int, int) * @see #charsWidth(char[], int, int) * @see #getStringBounds(java.lang.String, java.awt.Graphics) */ public int stringWidth(String str) { return backend.stringWidth(str); } /** * Returns the total advance width for showing the specified array * of characters in this <code>Font</code>. The advance is the * distance from the leftmost point to the rightmost point on the * string's baseline. The advance of a <code>String</code>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -