⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 font.java

📁 gcc的组建
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
  }  /**   * Returns the italic angle of this font, a measurement of its slant when   * style is {@link #ITALIC}. The precise meaning is the inverse slope of a   * caret line which "best measures" the font's italic posture.   *   * @return The italic angle.   *   * @see java.awt.font.TextAttribute#POSTURE   */  public float getItalicAngle()  {    return peer.getItalicAngle(this);  }  /**   * Returns a {@link LineMetrics} object constructed with the specified   * text and {@link FontRenderContext}.    *   * @param text The string to calculate metrics from.   * @param begin Index of first character in <code>text</code> to measure.   * @param limit Index of last character in <code>text</code> to measure.   * @param rc Context for calculating precise glyph placement and hints.   *   * @return A new {@link LineMetrics} object.   *   * @throws IndexOutOfBoundsException if the range [begin, limit] is   * invalid in <code>text</code>.   */  public LineMetrics getLineMetrics(String text, int begin,                                     int limit, FontRenderContext rc)  {    return peer.getLineMetrics(this, new StringCharacterIterator(text),                                begin, limit, rc);  }  /**   * Returns a {@link LineMetrics} object constructed with the specified   * text and {@link FontRenderContext}.    *   * @param chars The string to calculate metrics from.   * @param begin Index of first character in <code>text</code> to measure.   * @param limit Index of last character in <code>text</code> to measure.   * @param rc Context for calculating precise glyph placement and hints.   *   * @return A new {@link LineMetrics} object.   *   * @throws IndexOutOfBoundsException if the range [begin, limit] is   * invalid in <code>chars</code>.   */  public LineMetrics getLineMetrics(char[] chars, int begin,                                     int limit, FontRenderContext rc)  {    return peer.getLineMetrics(this,                               new StringCharacterIterator(new String(chars)),                                begin, limit, rc);  }  /**   * Returns a {@link LineMetrics} object constructed with the specified   * text and {@link FontRenderContext}.    *   * @param ci The string to calculate metrics from.   * @param begin Index of first character in <code>text</code> to measure.   * @param limit Index of last character in <code>text</code> to measure.   * @param rc Context for calculating precise glyph placement and hints.   *   * @return A new {@link LineMetrics} object.   *   * @throws IndexOutOfBoundsException if the range [begin, limit] is   * invalid in <code>ci</code>.   */  public LineMetrics getLineMetrics(CharacterIterator ci, int begin,                                     int limit, FontRenderContext rc)  {    return peer.getLineMetrics(this, ci, begin, limit, rc);  }  /**   * Returns the maximal bounding box of all the bounding boxes in this   * font, when the font's bounding boxes are evaluated in a given {@link   * FontRenderContext}   *   * @param rc Context in which to evaluate bounding boxes.   *   * @return The maximal bounding box.   */  public Rectangle2D getMaxCharBounds(FontRenderContext rc)  {    return peer.getMaxCharBounds(this, rc);  }  /**   * Returns the glyph code this font uses to represent missing glyphs. This   * code will be present in glyph vectors when the font was unable to   * locate a glyph to represent a particular character code.   *   * @return The missing glyph code.   *   * @since 1.2   */  public int getMissingGlyphCode()  {    return peer.getMissingGlyphCode(this);  }  /**   * Returns the overall number of glyphs in this font. This number is one   * more than the greatest glyph code used in any glyph vectors this font   * produces. In other words, glyph codes are taken from the range   * <code>[ 0, getNumGlyphs() - 1 ]</code>.   *   * @return The number of glyphs in this font.   *    * @since 1.2   */  public int getNumGlyphs()  {    return peer.getMissingGlyphCode(this);  }  /**   * Returns the PostScript Name of this font.      *   * @return The PostScript Name of this font.   *   * @since 1.2   *   * @see #getName()   * @see #getFamily()   * @see #getFontName()   */  public String getPSName()  {    return peer.getPostScriptName(this);  }  /**   * Returns the logical bounds of the specified string when rendered with this   * font in the specified {@link FontRenderContext}. This box will include the   * glyph origin, ascent, advance, height, and leading, but may not include all   * diacritics or accents. To get the complete visual bounding box of all the   * glyphs in a run of text, use the {@link TextLayout#getBounds} method of    * {@link TextLayout}.   *   * @param str The string to measure.   * @param frc The context in which to make the precise glyph measurements.   *    * @return A bounding box covering the logical bounds of the specified text.   *   * @see #createGlyphVector(FontRenderContext, String)   */  public Rectangle2D getStringBounds(String str, FontRenderContext frc)  {    return getStringBounds(str, 0, str.length() - 1, frc);  }  /**   * Returns the logical bounds of the specified string when rendered with this   * font in the specified {@link FontRenderContext}. This box will include the   * glyph origin, ascent, advance, height, and leading, but may not include all   * diacritics or accents. To get the complete visual bounding box of all the   * glyphs in a run of text, use the {@link TextLayout#getBounds} method of   * {@link TextLayout}.   *   * @param str The string to measure.   * @param begin Index of the first character in <code>str</code> to measure.   * @param limit Index of the last character in <code>str</code> to measure.   * @param frc The context in which to make the precise glyph measurements.   *    * @return A bounding box covering the logical bounds of the specified text.   *   * @throws IndexOutOfBoundsException if the range [begin, limit] is   * invalid in <code>str</code>.   *   * @since 1.2   *   * @see #createGlyphVector(FontRenderContext, String)   */  public Rectangle2D getStringBounds(String str, int begin,                                      int limit, FontRenderContext frc)  {    return peer.getStringBounds(this, new StringCharacterIterator(str), begin,                                limit, frc);  }  /**   * Returns the logical bounds of the specified string when rendered with this   * font in the specified {@link FontRenderContext}. This box will include the   * glyph origin, ascent, advance, height, and leading, but may not include all   * diacritics or accents. To get the complete visual bounding box of all the   * glyphs in a run of text, use the {@link TextLayout#getBounds} method of   * {@link TextLayout}.   *   * @param ci The text to measure.   * @param begin Index of the first character in <code>ci</code> to measure.   * @param limit Index of the last character in <code>ci</code> to measure.   * @param frc The context in which to make the precise glyph measurements.   *    * @return A bounding box covering the logical bounds of the specified text.   *   * @throws IndexOutOfBoundsException if the range [begin, limit] is   * invalid in <code>ci</code>.   *   * @since 1.2   *   * @see #createGlyphVector(FontRenderContext, CharacterIterator)   */  public Rectangle2D getStringBounds(CharacterIterator ci, int begin,                                      int limit, FontRenderContext frc)  {    return peer.getStringBounds(this, ci, begin, limit, frc);  }  /**   * Returns the logical bounds of the specified string when rendered with this   * font in the specified {@link FontRenderContext}. This box will include the   * glyph origin, ascent, advance, height, and leading, but may not include all   * diacritics or accents. To get the complete visual bounding box of all the   * glyphs in a run of text, use the {@link TextLayout#getBounds} method of   * {@link TextLayout}.   *   * @param chars The text to measure.   * @param begin Index of the first character in <code>ci</code> to measure.   * @param limit Index of the last character in <code>ci</code> to measure.   * @param frc The context in which to make the precise glyph measurements.   *    * @return A bounding box covering the logical bounds of the specified text.   *   * @throws IndexOutOfBoundsException if the range [begin, limit] is   * invalid in <code>chars</code>.   *   * @since 1.2   *   * @see #createGlyphVector(FontRenderContext, char[])   */  public Rectangle2D getStringBounds(char[] chars, int begin,                                      int limit, FontRenderContext frc)  {    return peer.getStringBounds(this,                                new StringCharacterIterator(new String(chars)),                                 begin, limit, frc);  }  /**   * Returns a copy of the affine transformation this font is currently   * subject to, if any.   *   * @return The current transformation.   */  public AffineTransform getTransform()  {    return peer.getTransform(this);  }  /**   * Indicates whether this font's line metrics are uniform. A font may be   * composed of several "subfonts", each covering a different code range,   * and each with their own line metrics. A font with no subfonts, or   * subfonts with identical line metrics, is said to have "uniform" line   * metrics.   *   * @return Whether this font has uniform line metrics.   *   * @see LineMetrics   * @see #getLineMetrics(String, FontRenderContext)   */  public boolean hasUniformLineMetrics()  {    return peer.hasUniformLineMetrics(this);  }  /**   * Indicates whether this font is subject to a non-identity affine   * transformation.   *   * @return <code>true</code> iff the font has a non-identity affine   * transformation applied to it.   */  public boolean isTransformed()  {    return peer.isTransformed(this);  }  /**   * Produces a glyph vector representing a full layout fo the specified   * text in this font. Full layouts may include complex shaping and   * reordering operations, for scripts such as Arabic or Hindi.   *   * Bidirectional (bidi) layout is not performed in this method; text   * should have its bidi direction specified with one of the flags {@link   * #LAYOUT_LEFT_TO_RIGHT} or {@link #LAYOUT_RIGHT_TO_LEFT}.   *   * Some types of layout (notably Arabic glyph shaping) may examine context   * characters beyond the bounds of the indicated range, in order to select   * an appropriate shape. The flags {@link #LAYOUT_NO_START_CONTEXT} and   * {@link #LAYOUT_NO_LIMIT_CONTEXT} can be provided to prevent these extra   * context areas from being examined, for instance if they contain invalid   * characters.   *   * @param frc Context in which to perform the layout.   * @param chars Text to perform layout on.   * @param start Index of first character to perform layout on.   * @param limit Index of last character to perform layout on.   * @param flags Combination of flags controlling layout.   *   * @return A new {@link GlyphVector} representing the specified text.   *   * @throws IndexOutOfBoundsException if the range [begin, limit] is   * invalid in <code>chars</code>.    */  public GlyphVector layoutGlyphVector(FontRenderContext frc,                                        char[] chars, int start,                                        int limit, int flags)  {    return peer.layoutGlyphVector(this, frc, chars, start, limit, flags);  }  /**   * Returns a native peer object for this font.   *   * @return A native peer object for this font.   *   * @deprecated   */  public FontPeer getPeer()  {    return peer;  }  /**   * Returns a hash value for this font.   *    * @return A hash for this font.   */  public int hashCode()  {    return this.toString().hashCode();  }  /**   * Tests whether or not the specified object is equal to this font.  This   * will be true if and only if:   * <P>   * <ul>   * <li>The object is not <code>null</code>.   * <li>The object is an instance of <code>Font</code>.   * <li>The object has the same names, style, size, and transform as this object.   * </ul>   *   * @return <code>true</code> if the specified object is equal to this   * object, <code>false</code> otherwise.   */  public boolean equals(Object obj)  {    if (obj == null)      return false;    if (! (obj instanceof Font))      return false;    Font f = (Font) obj;    return (f.getName().equals(this.getName())            && f.getFamily().equals(this.getFamily())            && f.getFontName().equals(this.getFontName())            && f.getTransform().equals(this.getTransform ())            && f.getSize() == this.getSize()            && f.getStyle() == this.getStyle());  }  /**   * Returns a string representation of this font.   *   * @return A string representation of this font.   */  public String toString()  {    String styleString = "";    switch (getStyle())      {      case 0:        styleString = "plain";        break;      case 1:        styleString = "bold";        break;      case 2:        styleString = "italic";        break;      default:        styleString = "unknown";     }        return getClass().getName()              + "[family=" + getFamily ()             + ",name=" + getFontName ()             + ",style=" + styleString             + ",size=" + getSize () + "]";  }  /**   * Determines the line metrics for a run of text.   *   * @param str the text run to be measured.   *   * @param frc the font rendering parameters that are used for the   *        measurement. The exact placement and size of text slightly   *        depends on device-specific characteristics, for instance   *        the device resolution or anti-aliasing.  For this reason,   *        the returned measurement will only be accurate if the   *        passed <code>FontRenderContext</code> correctly reflects   *        the relevant parameters. Hence, <code>frc</code> should be   *        obtained from the same <code>Graphics2D</code> that will   *        be used for drawing, and any rendering hints should be set   *        to the desired values before obtaining <code>frc</code>.   *   * @see java.awt.Graphics2D#getFontRenderContext()   */  public LineMetrics getLineMetrics(String str, FontRenderContext frc)  {    return getLineMetrics(str, 0, str.length() - 1, frc);  }  /**   * Reads the normal fields from the stream and then constructs the   * peer from the style and size through getPeerFromToolkit().   */  private void readObject(ObjectInputStream ois)    throws IOException, ClassNotFoundException  {    ois.defaultReadObject();    HashMap attrs = new HashMap();    ClasspathFontPeer.copyStyleToAttrs(style, attrs);    ClasspathFontPeer.copySizeToAttrs(size, attrs);    peer = getPeerFromToolkit(name, attrs);  }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -