类sun.font.FontDesignMetrics源码实例Demo

下面列出了怎么用sun.font.FontDesignMetrics的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: dragonwell8_jdk   文件: SunGraphics2D.java
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());
}
 
源代码2 项目: dragonwell8_jdk   文件: SunGraphics2D.java
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;
}
 
源代码3 项目: dragonwell8_jdk   文件: SwingUtilities2.java
public static FontMetrics getFontMetrics(JComponent c, Font font) {
    FontRenderContext  frc = getFRCProperty(c);
    if (frc == null) {
        frc = DEFAULT_FRC;
    }
    return FontDesignMetrics.getMetrics(font, frc);
}
 
源代码4 项目: TencentKona-8   文件: SunGraphics2D.java
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());
}
 
源代码5 项目: TencentKona-8   文件: SunGraphics2D.java
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;
}
 
源代码6 项目: TencentKona-8   文件: SwingUtilities2.java
public static FontMetrics getFontMetrics(JComponent c, Font font) {
    FontRenderContext  frc = getFRCProperty(c);
    if (frc == null) {
        frc = DEFAULT_FRC;
    }
    return FontDesignMetrics.getMetrics(font, frc);
}
 
源代码7 项目: jdk8u60   文件: SunGraphics2D.java
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());
}
 
源代码8 项目: jdk8u60   文件: SunGraphics2D.java
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;
}
 
源代码9 项目: jdk8u60   文件: SwingUtilities2.java
public static FontMetrics getFontMetrics(JComponent c, Font font) {
    FontRenderContext  frc = getFRCProperty(c);
    if (frc == null) {
        frc = DEFAULT_FRC;
    }
    return FontDesignMetrics.getMetrics(font, frc);
}
 
源代码10 项目: poster-generater   文件: Text.java
/**
 * 获取文本所占宽度
 *
 * @param font    字体
 * @param content 文本内容
 * @return int 返回宽度
 */
private static int getWordWidth(Font font, String content) {
    FontDesignMetrics metrics = FontDesignMetrics.getMetrics(font);
    int width = 0;
    for (int i = 0; i < content.length(); i++) {
        width += metrics.charWidth(content.charAt(i));
    }
    return width;
}
 
源代码11 项目: openjdk-jdk8u   文件: SunGraphics2D.java
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());
}
 
源代码12 项目: openjdk-jdk8u   文件: SunGraphics2D.java
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;
}
 
源代码13 项目: openjdk-jdk8u   文件: SwingUtilities2.java
public static FontMetrics getFontMetrics(JComponent c, Font font) {
    FontRenderContext  frc = getFRCProperty(c);
    if (frc == null) {
        frc = DEFAULT_FRC;
    }
    return FontDesignMetrics.getMetrics(font, frc);
}
 
源代码14 项目: openjdk-jdk8u-backup   文件: SunGraphics2D.java
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());
}
 
源代码15 项目: openjdk-jdk8u-backup   文件: SunGraphics2D.java
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;
}
 
源代码16 项目: openjdk-jdk8u-backup   文件: SwingUtilities2.java
public static FontMetrics getFontMetrics(JComponent c, Font font) {
    FontRenderContext  frc = getFRCProperty(c);
    if (frc == null) {
        frc = DEFAULT_FRC;
    }
    return FontDesignMetrics.getMetrics(font, frc);
}
 
源代码17 项目: Bytecoder   文件: Font.java
/**
 * Returns the logical bounds of the specified array of characters
 * in the specified {@code FontRenderContext}.  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}.
 * <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}
 * @return a {@code Rectangle2D} that is the bounding box of the
 * specified array of characters in the specified
 * {@code FontRenderContext}.
 * @throws IndexOutOfBoundsException if {@code beginIndex} is
 *         less than zero, or {@code limit} is greater than the
 *         length of {@code chars}, or {@code beginIndex}
 *         is greater than {@code limit}.
 * @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());
    }
}
 
源代码18 项目: Bytecoder   文件: SunGraphics2D.java
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());
}
 
源代码19 项目: Bytecoder   文件: SunGraphics2D.java
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;
}
 
源代码20 项目: Bytecoder   文件: SwingUtilities2.java
public static FontMetrics getFontMetrics(JComponent c, Font font) {
    FontRenderContext  frc = getFRCProperty(c);
    if (frc == null) {
        frc = DEFAULT_FRC;
    }
    return FontDesignMetrics.getMetrics(font, frc);
}
 
源代码21 项目: openjdk-jdk9   文件: SunGraphics2D.java
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());
}
 
源代码22 项目: openjdk-jdk9   文件: SunGraphics2D.java
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;
}
 
源代码23 项目: openjdk-jdk9   文件: SwingUtilities2.java
public static FontMetrics getFontMetrics(JComponent c, Font font) {
    FontRenderContext  frc = getFRCProperty(c);
    if (frc == null) {
        frc = DEFAULT_FRC;
    }
    return FontDesignMetrics.getMetrics(font, frc);
}
 
源代码24 项目: jdk8u-jdk   文件: SunGraphics2D.java
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());
}
 
源代码25 项目: jdk8u-jdk   文件: SunGraphics2D.java
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;
}
 
源代码26 项目: jdk8u-jdk   文件: SwingUtilities2.java
public static FontMetrics getFontMetrics(JComponent c, Font font) {
    FontRenderContext  frc = getFRCProperty(c);
    if (frc == null) {
        frc = DEFAULT_FRC;
    }
    return FontDesignMetrics.getMetrics(font, frc);
}
 
源代码27 项目: hottub   文件: SunGraphics2D.java
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());
}
 
源代码28 项目: hottub   文件: SunGraphics2D.java
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;
}
 
源代码29 项目: hottub   文件: SwingUtilities2.java
public static FontMetrics getFontMetrics(JComponent c, Font font) {
    FontRenderContext  frc = getFRCProperty(c);
    if (frc == null) {
        frc = DEFAULT_FRC;
    }
    return FontDesignMetrics.getMetrics(font, frc);
}
 
源代码30 项目: openjdk-8-source   文件: SunGraphics2D.java
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());
}