Search in sources :

Example 1 with FontLineMetrics

use of sun.font.FontLineMetrics in project jdk8u_jdk by JetBrains.

the class Font method getLineMetrics.

/**
     * Returns a <code>LineMetrics</code> object created with the
     * specified arguments.
     * @param chars an array of characters
     * @param beginIndex the initial offset of <code>chars</code>
     * @param limit the end offset of <code>chars</code>
     * @param frc the specified <code>FontRenderContext</code>
     * @return a <code>LineMetrics</code> object created with the
     * specified arguments.
     */
public LineMetrics getLineMetrics(char[] chars, int beginIndex, int limit, FontRenderContext frc) {
    FontLineMetrics flm = defaultLineMetrics(frc);
    int numChars = limit - beginIndex;
    flm.numchars = (numChars < 0) ? 0 : numChars;
    return flm;
}
Also used : FontLineMetrics(sun.font.FontLineMetrics)

Example 2 with FontLineMetrics

use of sun.font.FontLineMetrics in project jdk8u_jdk by JetBrains.

the class Font method getLineMetrics.

/**
     * Returns a {@link LineMetrics} object created with the specified
     * <code>String</code> and {@link FontRenderContext}.
     * @param str the specified <code>String</code>
     * @param frc the specified <code>FontRenderContext</code>
     * @return a <code>LineMetrics</code> object created with the
     * specified <code>String</code> and {@link FontRenderContext}.
     */
public LineMetrics getLineMetrics(String str, FontRenderContext frc) {
    FontLineMetrics flm = defaultLineMetrics(frc);
    flm.numchars = str.length();
    return flm;
}
Also used : FontLineMetrics(sun.font.FontLineMetrics)

Example 3 with FontLineMetrics

use of sun.font.FontLineMetrics in project jdk8u_jdk by JetBrains.

the class Font method getLineMetrics.

/**
     * Returns a <code>LineMetrics</code> object created with the
     * specified arguments.
     * @param ci the specified <code>CharacterIterator</code>
     * @param beginIndex the initial offset in <code>ci</code>
     * @param limit the end offset of <code>ci</code>
     * @param frc the specified <code>FontRenderContext</code>
     * @return a <code>LineMetrics</code> object created with the
     * specified arguments.
     */
public LineMetrics getLineMetrics(CharacterIterator ci, int beginIndex, int limit, FontRenderContext frc) {
    FontLineMetrics flm = defaultLineMetrics(frc);
    int numChars = limit - beginIndex;
    flm.numchars = (numChars < 0) ? 0 : numChars;
    return flm;
}
Also used : FontLineMetrics(sun.font.FontLineMetrics)

Example 4 with FontLineMetrics

use of sun.font.FontLineMetrics in project jdk8u_jdk by JetBrains.

the class Font method getLineMetrics.

/**
     * Returns a <code>LineMetrics</code> object created with the
     * specified arguments.
     * @param str the specified <code>String</code>
     * @param beginIndex the initial offset of <code>str</code>
     * @param limit the end offset of <code>str</code>
     * @param frc the specified <code>FontRenderContext</code>
     * @return a <code>LineMetrics</code> object created with the
     * specified arguments.
     */
public LineMetrics getLineMetrics(String str, int beginIndex, int limit, FontRenderContext frc) {
    FontLineMetrics flm = defaultLineMetrics(frc);
    int numChars = limit - beginIndex;
    flm.numchars = (numChars < 0) ? 0 : numChars;
    return flm;
}
Also used : FontLineMetrics(sun.font.FontLineMetrics)

Example 5 with FontLineMetrics

use of sun.font.FontLineMetrics in project jdk8u_jdk by JetBrains.

the class Font method defaultLineMetrics.

private FontLineMetrics defaultLineMetrics(FontRenderContext frc) {
    FontLineMetrics flm = null;
    if (flmref == null || (flm = flmref.get()) == null || !flm.frc.equals(frc)) {
        /* The device transform in the frc is not used in obtaining line
             * metrics, although it probably should be: REMIND find why not?
             * The font transform is used but its applied in getFontMetrics, so
             * just pass identity here
             */
        float[] metrics = new float[8];
        getFont2D().getFontMetrics(this, identityTx, frc.getAntiAliasingHint(), frc.getFractionalMetricsHint(), metrics);
        float ascent = metrics[0];
        float descent = metrics[1];
        float leading = metrics[2];
        float ssOffset = 0;
        if (values != null && values.getSuperscript() != 0) {
            ssOffset = (float) getTransform().getTranslateY();
            ascent -= ssOffset;
            descent += ssOffset;
        }
        float height = ascent + descent + leading;
        // need real index, assumes roman for everything
        int baselineIndex = 0;
        // need real baselines eventually
        float[] baselineOffsets = { 0, (descent / 2f - ascent) / 2f, -ascent };
        float strikethroughOffset = metrics[4];
        float strikethroughThickness = metrics[5];
        float underlineOffset = metrics[6];
        float underlineThickness = metrics[7];
        float italicAngle = getItalicAngle(frc);
        if (isTransformed()) {
            // extract rotation
            AffineTransform ctx = values.getCharTransform();
            if (ctx != null) {
                Point2D.Float pt = new Point2D.Float();
                pt.setLocation(0, strikethroughOffset);
                ctx.deltaTransform(pt, pt);
                strikethroughOffset = pt.y;
                pt.setLocation(0, strikethroughThickness);
                ctx.deltaTransform(pt, pt);
                strikethroughThickness = pt.y;
                pt.setLocation(0, underlineOffset);
                ctx.deltaTransform(pt, pt);
                underlineOffset = pt.y;
                pt.setLocation(0, underlineThickness);
                ctx.deltaTransform(pt, pt);
                underlineThickness = pt.y;
            }
        }
        strikethroughOffset += ssOffset;
        underlineOffset += ssOffset;
        CoreMetrics cm = new CoreMetrics(ascent, descent, leading, height, baselineIndex, baselineOffsets, strikethroughOffset, strikethroughThickness, underlineOffset, underlineThickness, ssOffset, italicAngle);
        flm = new FontLineMetrics(0, cm, frc);
        flmref = new SoftReference<FontLineMetrics>(flm);
    }
    return (FontLineMetrics) flm.clone();
}
Also used : CoreMetrics(sun.font.CoreMetrics) Point2D(java.awt.geom.Point2D) FontLineMetrics(sun.font.FontLineMetrics) AffineTransform(java.awt.geom.AffineTransform)

Aggregations

FontLineMetrics (sun.font.FontLineMetrics)5 AffineTransform (java.awt.geom.AffineTransform)1 Point2D (java.awt.geom.Point2D)1 CoreMetrics (sun.font.CoreMetrics)1