Java Code Examples for sun.font.FontDesignMetrics#getMetrics()
The following examples show how to use
sun.font.FontDesignMetrics#getMetrics() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SunGraphics2D.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
public FontMetrics getFontMetrics(Font font) { if ((this.fontMetrics != null) && (font == this.font)) { return this.fontMetrics; } FontMetrics fm = FontDesignMetrics.getMetrics(font, getFontRenderContext()); if (this.font == font) { this.fontMetrics = fm; } return fm; }
Example 2
Source File: SunGraphics2D.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
public FontMetrics getFontMetrics(Font font) { if ((this.fontMetrics != null) && (font == this.font)) { return this.fontMetrics; } FontMetrics fm = FontDesignMetrics.getMetrics(font, getFontRenderContext()); if (this.font == font) { this.fontMetrics = fm; } return fm; }
Example 3
Source File: SwingUtilities2.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
public static FontMetrics getFontMetrics(JComponent c, Font font) { FontRenderContext frc = getFRCProperty(c); if (frc == null) { frc = DEFAULT_FRC; } return FontDesignMetrics.getMetrics(font, frc); }
Example 4
Source File: SwingUtilities2.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
public static FontMetrics getFontMetrics(JComponent c, Font font) { FontRenderContext frc = getFRCProperty(c); if (frc == null) { frc = DEFAULT_FRC; } return FontDesignMetrics.getMetrics(font, frc); }
Example 5
Source File: SunGraphics2D.java From jdk8u_jdk with GNU General Public License v2.0 | 5 votes |
public FontMetrics getFontMetrics() { if (this.fontMetrics != null) { return this.fontMetrics; } /* NB the constructor and the setter disallow "font" being null */ return this.fontMetrics = FontDesignMetrics.getMetrics(font, getFontRenderContext()); }
Example 6
Source File: SunGraphics2D.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
public FontMetrics getFontMetrics() { if (this.fontMetrics != null) { return this.fontMetrics; } /* NB the constructor and the setter disallow "font" being null */ return this.fontMetrics = FontDesignMetrics.getMetrics(font, getFontRenderContext()); }
Example 7
Source File: SunGraphics2D.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
public FontMetrics getFontMetrics(Font font) { if ((this.fontMetrics != null) && (font == this.font)) { return this.fontMetrics; } FontMetrics fm = FontDesignMetrics.getMetrics(font, getFontRenderContext()); if (this.font == font) { this.fontMetrics = fm; } return fm; }
Example 8
Source File: SunGraphics2D.java From hottub with GNU General Public License v2.0 | 5 votes |
public FontMetrics getFontMetrics(Font font) { if ((this.fontMetrics != null) && (font == this.font)) { return this.fontMetrics; } FontMetrics fm = FontDesignMetrics.getMetrics(font, getFontRenderContext()); if (this.font == font) { this.fontMetrics = fm; } return fm; }
Example 9
Source File: SunGraphics2D.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
public FontMetrics getFontMetrics(Font font) { if ((this.fontMetrics != null) && (font == this.font)) { return this.fontMetrics; } FontMetrics fm = FontDesignMetrics.getMetrics(font, getFontRenderContext()); if (this.font == font) { this.fontMetrics = fm; } return fm; }
Example 10
Source File: SunGraphics2D.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
public FontMetrics getFontMetrics() { if (this.fontMetrics != null) { return this.fontMetrics; } /* NB the constructor and the setter disallow "font" being null */ return this.fontMetrics = FontDesignMetrics.getMetrics(font, getFontRenderContext()); }
Example 11
Source File: SunGraphics2D.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
public FontMetrics getFontMetrics(Font font) { if ((this.fontMetrics != null) && (font == this.font)) { return this.fontMetrics; } FontMetrics fm = FontDesignMetrics.getMetrics(font, getFontRenderContext()); if (this.font == font) { this.fontMetrics = fm; } return fm; }
Example 12
Source File: SunGraphics2D.java From Bytecoder with Apache License 2.0 | 5 votes |
public FontMetrics getFontMetrics() { if (this.fontMetrics != null) { return this.fontMetrics; } /* NB the constructor and the setter disallow "font" being null */ return this.fontMetrics = FontDesignMetrics.getMetrics(font, getFontRenderContext()); }
Example 13
Source File: SunGraphics2D.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
public FontMetrics getFontMetrics() { if (this.fontMetrics != null) { return this.fontMetrics; } /* NB the constructor and the setter disallow "font" being null */ return this.fontMetrics = FontDesignMetrics.getMetrics(font, getFontRenderContext()); }
Example 14
Source File: Font.java From jdk8u_jdk with GNU General Public License v2.0 | 5 votes |
/** * Returns the logical bounds of the specified array of characters * in the specified <code>FontRenderContext</code>. The logical * bounds contains the origin, ascent, advance, and height, which * includes the leading. The logical bounds does not always enclose * all the text. For example, in some languages and in some fonts, * accent marks can be positioned above the ascent or below the * descent. To obtain a visual bounding box, which encloses all the * text, use the {@link TextLayout#getBounds() getBounds} method of * <code>TextLayout</code>. * <p>Note: The returned bounds is in baseline-relative coordinates * (see {@link java.awt.Font class notes}). * @param chars an array of characters * @param beginIndex the initial offset in the array of * characters * @param limit the end offset in the array of characters * @param frc the specified <code>FontRenderContext</code> * @return a <code>Rectangle2D</code> that is the bounding box of the * specified array of characters in the specified * <code>FontRenderContext</code>. * @throws IndexOutOfBoundsException if <code>beginIndex</code> is * less than zero, or <code>limit</code> is greater than the * length of <code>chars</code>, or <code>beginIndex</code> * is greater than <code>limit</code>. * @see FontRenderContext * @see Font#createGlyphVector * @since 1.2 */ public Rectangle2D getStringBounds(char [] chars, int beginIndex, int limit, FontRenderContext frc) { if (beginIndex < 0) { throw new IndexOutOfBoundsException("beginIndex: " + beginIndex); } if (limit > chars.length) { throw new IndexOutOfBoundsException("limit: " + limit); } if (beginIndex > limit) { throw new IndexOutOfBoundsException("range length: " + (limit - beginIndex)); } // this code should be in textlayout // quick check for simple text, assume GV ok to use if simple boolean simple = values == null || (values.getKerning() == 0 && values.getLigatures() == 0 && values.getBaselineTransform() == null); if (simple) { simple = ! FontUtilities.isComplexText(chars, beginIndex, limit); } if (simple) { FontDesignMetrics metrics = FontDesignMetrics.getMetrics(this, frc); return metrics.getSimpleBounds(chars, beginIndex, limit-beginIndex); } else { // need char array constructor on textlayout String str = new String(chars, beginIndex, limit - beginIndex); TextLayout tl = new TextLayout(str, this, frc); return new Rectangle2D.Float(0, -tl.getAscent(), tl.getAdvance(), tl.getAscent() + tl.getDescent() + tl.getLeading()); } }
Example 15
Source File: SwingUtilities2.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
public static FontMetrics getFontMetrics(JComponent c, Font font) { FontRenderContext frc = getFRCProperty(c); if (frc == null) { frc = DEFAULT_FRC; } return FontDesignMetrics.getMetrics(font, frc); }
Example 16
Source File: SunToolkit.java From jdk8u-jdk with GNU General Public License v2.0 | 4 votes |
@SuppressWarnings("deprecation") public FontMetrics getFontMetrics(Font font) { return FontDesignMetrics.getMetrics(font); }
Example 17
Source File: SunToolkit.java From hottub with GNU General Public License v2.0 | 4 votes |
@SuppressWarnings("deprecation") public FontMetrics getFontMetrics(Font font) { return FontDesignMetrics.getMetrics(font); }
Example 18
Source File: SunToolkit.java From TencentKona-8 with GNU General Public License v2.0 | 4 votes |
@SuppressWarnings("deprecation") public FontMetrics getFontMetrics(Font font) { return FontDesignMetrics.getMetrics(font); }
Example 19
Source File: SunToolkit.java From openjdk-jdk8u with GNU General Public License v2.0 | 4 votes |
@SuppressWarnings("deprecation") public FontMetrics getFontMetrics(Font font) { return FontDesignMetrics.getMetrics(font); }
Example 20
Source File: SunToolkit.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 4 votes |
@SuppressWarnings("deprecation") public FontMetrics getFontMetrics(Font font) { return FontDesignMetrics.getMetrics(font); }