📄 defaultfontmetrics.java
字号:
* is not necessarily the sum of the advances of its characters. * This is equivalent to measuring a <code>String</code> of the * characters in the specified range. * @param data the array of characters to be measured * @param off the start offset of the characters in the array * @param len the number of characters to be measured from the array * @return the advance width of the subarray of the specified * <code>char</code> array in the font described by * this <code>FontMetrics</code> object. * @see #charWidth(int) * @see #charWidth(char) * @see #bytesWidth(byte[], int, int) * @see #stringWidth(java.lang.String) */ public int charsWidth(char data[], int off, int len) { return backend.charsWidth(data, off, len); } /** * Returns the total advance width for showing the specified array * of bytes 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. * This is equivalent to measuring a <code>String</code> of the * characters in the specified range. * @param data the array of bytes to be measured * @param off the start offset of the bytes in the array * @param len the number of bytes to be measured from the array * @return the advance width of the subarray of the specified * <code>byte</code> array in the <code>Font</code> * described by * this <code>FontMetrics</code> object. * @see #charsWidth(char[], int, int) * @see #stringWidth(java.lang.String) */ public int bytesWidth(byte data[], int off, int len) { return backend.bytesWidth(data, off, len); } /** * Gets the advance widths of the first 256 characters in the * <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 an array storing the advance widths of the * characters in the <code>Font</code> * described by this <code>FontMetrics</code> object. */ public int[] getWidths() { return backend.getWidths(); } /** * Checks to see if the <code>Font</code> has uniform line metrics. A * composite font may consist of several different fonts to cover * various character sets. In such cases, the * <code>FontLineMetrics</code> objects are not uniform. * Different fonts may have a different ascent, descent, metrics and * so on. This information is sometimes necessary for line * measuring and line breaking. * @return <code>true</code> if the font has uniform line metrics; * <code>false</code> otherwise. * @see java.awt.Font#hasUniformLineMetrics() */ public boolean hasUniformLineMetrics() { return backend.hasUniformLineMetrics(); } /** * Returns the {@link java.awt.font.LineMetrics} object for the specified * <code>String</code> in the specified {@link java.awt.Graphics} context. * @param str the specified <code>String</code> * @param context the specified <code>Graphics</code> context * @return a <code>LineMetrics</code> object created with the * specified <code>String</code> and <code>Graphics</code> context. * @see java.awt.Font#getLineMetrics(java.lang.String, java.awt.font.FontRenderContext) */ public LineMetrics getLineMetrics(String str, Graphics context) { return backend.getLineMetrics(str, context); } /** * Returns the {@link java.awt.font.LineMetrics} object for the specified * <code>String</code> in the specified {@link java.awt.Graphics} context. * @param str the specified <code>String</code> * @param beginIndex the initial offset of <code>str</code> * @param limit the length of <code>str</code> * @param context the specified <code>Graphics</code> context * @return a <code>LineMetrics</code> object created with the * specified <code>String</code> and <code>Graphics</code> context. * @see java.awt.Font#getLineMetrics(java.lang.String, int, int, java.awt.font.FontRenderContext) */ public LineMetrics getLineMetrics(String str, int beginIndex, int limit, Graphics context) { return backend.getLineMetrics(str, beginIndex, limit, context); } /** * Returns the {@link java.awt.font.LineMetrics} object for the specified * character array in the specified {@link java.awt.Graphics} context. * @param chars the specified character array * @param beginIndex the initial offset of <code>chars</code> * @param limit the length of <code>chars</code> * @param context the specified <code>Graphics</code> context * @return a <code>LineMetrics</code> object created with the * specified character array and <code>Graphics</code> context. * @see java.awt.Font#getLineMetrics(char[], int, int, java.awt.font.FontRenderContext) */ public LineMetrics getLineMetrics(char[] chars, int beginIndex, int limit, Graphics context) { return backend.getLineMetrics(chars, beginIndex, limit, context); } /** * Returns the {@link java.awt.font.LineMetrics} object for the specified * {@link java.text.CharacterIterator} in the specified {@link java.awt.Graphics} * context. * @param ci the specified <code>CharacterIterator</code> * @param beginIndex the initial offset in <code>ci</code> * @param limit the end index of <code>ci</code> * @param context the specified <code>Graphics</code> context * @return a <code>LineMetrics</code> object created with the * specified arguments. * @see java.awt.Font#getLineMetrics(java.text.CharacterIterator, int, int, java.awt.font.FontRenderContext) */ public LineMetrics getLineMetrics(CharacterIterator ci, int beginIndex, int limit, Graphics context) { return backend.getLineMetrics(ci, beginIndex, limit, context); } /** * Returns the bounds of the specified <code>String</code> in the * specified <code>Graphics</code> context. The bounds is used * to layout the <code>String</code>. * @param str the specified <code>String</code> * @param context the specified <code>Graphics</code> context * @return a {@link java.awt.geom.Rectangle2D} that is the bounding box of the * specified <code>String</code> in the specified * <code>Graphics</code> context. * @see java.awt.Font#getStringBounds(java.lang.String, java.awt.font.FontRenderContext) */ public Rectangle2D getStringBounds(String str, Graphics context) { return backend.getStringBounds(str, context); } /** * Returns the bounds of the specified <code>String</code> in the * specified <code>Graphics</code> context. The bounds is used * to layout the <code>String</code>. * @param str the specified <code>String</code> * @param beginIndex the offset of the beginning of <code>str</code> * @param limit the length of <code>str</code> * @param context the specified <code>Graphics</code> context * @return a <code>Rectangle2D</code> that is the bounding box of the * specified <code>String</code> in the specified * <code>Graphics</code> context. * @see java.awt.Font#getStringBounds(java.lang.String, int, int, java.awt.font.FontRenderContext) */ public Rectangle2D getStringBounds(String str, int beginIndex, int limit, Graphics context) { return backend.getStringBounds(str, beginIndex, limit, context); } /** * Returns the bounds of the specified array of characters * in the specified <code>Graphics</code> context. * The bounds is used to layout the <code>String</code> * created with the specified array of characters, * <code>beginIndex</code> and <code>limit</code>. * @param chars an array of characters * @param beginIndex the initial offset of the array of * characters * @param limit the length of the array of characters * @param context the specified <code>Graphics</code> context * @return a <code>Rectangle2D</code> that is the bounding box of the * specified character array in the specified * <code>Graphics</code> context. * @see java.awt.Font#getStringBounds(char[], int, int, java.awt.font.FontRenderContext) */ public Rectangle2D getStringBounds(char[] chars, int beginIndex, int limit, Graphics context) { return backend.getStringBounds(chars, beginIndex, limit, context); } /** * Returns the bounds of the characters indexed in the specified * <code>CharacterIterator</code> in the * specified <code>Graphics</code> context. * @param ci the specified <code>CharacterIterator</code> * @param beginIndex the initial offset in <code>ci</code> * @param limit the end index of <code>ci</code> * @param context the specified <code>Graphics</code> context * @return a <code>Rectangle2D</code> that is the bounding box of the * characters indexed in the specified <code>CharacterIterator</code> * in the specified <code>Graphics</code> context. * @see java.awt.Font#getStringBounds(java.text.CharacterIterator, int, int, java.awt.font.FontRenderContext) */ public Rectangle2D getStringBounds(CharacterIterator ci, int beginIndex, int limit, Graphics context) { return backend.getStringBounds(ci, beginIndex, limit, context); } /** * Returns the bounds for the character with the maximum bounds * in the specified <code>Graphics</code> context. * @param context the specified <code>Graphics</code> context * @return a <code>Rectangle2D</code> that is the * bounding box for the character with the maximum bounds. * @see java.awt.Font#getMaxCharBounds(java.awt.font.FontRenderContext) */ public Rectangle2D getMaxCharBounds(Graphics context) { return backend.getMaxCharBounds(context); } public static void main (String [] args) { FontMetrics fm = new DefaultFontMetrics(new Font ("Serif", Font.PLAIN, 10)); Log.debug ("MaxAdvance: " + fm.getMaxAdvance()); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -