Search in sources :

Example 1 with AttributeValues

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

the class Font method deriveFont.

/**
     * Creates a new <code>Font</code> object by replicating the current
     * <code>Font</code> object and applying a new style to it.
     * @param style the style for the new <code>Font</code>
     * @return a new <code>Font</code> object.
     * @since 1.2
     */
public Font deriveFont(int style) {
    if (values == null) {
        return new Font(name, style, size, createdFont, font2DHandle);
    }
    AttributeValues newValues = getAttributeValues().clone();
    int oldStyle = (this.style != style) ? this.style : -1;
    applyStyle(style, newValues);
    return new Font(newValues, null, oldStyle, createdFont, font2DHandle);
}
Also used : AttributeValues(sun.font.AttributeValues) CompositeFont(sun.font.CompositeFont)

Example 2 with AttributeValues

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

the class TextLine method fastCreateTextLine.

/**
     * Create a TextLine from the text.  The Font must be able to
     * display all of the text.
     * attributes==null is equivalent to using an empty Map for
     * attributes
     */
public static TextLine fastCreateTextLine(FontRenderContext frc, char[] chars, Font font, CoreMetrics lm, Map<? extends Attribute, ?> attributes) {
    boolean isDirectionLTR = true;
    byte[] levels = null;
    int[] charsLtoV = null;
    Bidi bidi = null;
    int characterCount = chars.length;
    boolean requiresBidi = false;
    byte[] embs = null;
    AttributeValues values = null;
    if (attributes != null) {
        values = AttributeValues.fromMap(attributes);
        if (values.getRunDirection() >= 0) {
            isDirectionLTR = values.getRunDirection() == 0;
            requiresBidi = !isDirectionLTR;
        }
        if (values.getBidiEmbedding() != 0) {
            requiresBidi = true;
            byte level = (byte) values.getBidiEmbedding();
            embs = new byte[characterCount];
            for (int i = 0; i < embs.length; ++i) {
                embs[i] = level;
            }
        }
    }
    if (!requiresBidi) {
        requiresBidi = Bidi.requiresBidi(chars, 0, chars.length);
    }
    if (requiresBidi) {
        int bidiflags = values == null ? Bidi.DIRECTION_DEFAULT_LEFT_TO_RIGHT : values.getRunDirection();
        bidi = new Bidi(chars, 0, embs, 0, chars.length, bidiflags);
        if (!bidi.isLeftToRight()) {
            levels = BidiUtils.getLevels(bidi);
            int[] charsVtoL = BidiUtils.createVisualToLogicalMap(levels);
            charsLtoV = BidiUtils.createInverseMap(charsVtoL);
            isDirectionLTR = bidi.baseIsLeftToRight();
        }
    }
    Decoration decorator = Decoration.getDecoration(values);
    // no extra info yet, bidi determines run and line direction
    int layoutFlags = 0;
    TextLabelFactory factory = new TextLabelFactory(frc, chars, bidi, layoutFlags);
    TextLineComponent[] components = new TextLineComponent[1];
    components = createComponentsOnRun(0, chars.length, chars, charsLtoV, levels, factory, font, lm, frc, decorator, components, 0);
    int numComponents = components.length;
    while (components[numComponents - 1] == null) {
        numComponents -= 1;
    }
    if (numComponents != components.length) {
        TextLineComponent[] temp = new TextLineComponent[numComponents];
        System.arraycopy(components, 0, temp, 0, numComponents);
        components = temp;
    }
    return new TextLine(frc, components, lm.baselineOffsets, chars, 0, chars.length, charsLtoV, levels, isDirectionLTR);
}
Also used : Bidi(java.text.Bidi) TextLabelFactory(sun.font.TextLabelFactory) AttributeValues(sun.font.AttributeValues) TextLineComponent(sun.font.TextLineComponent) Decoration(sun.font.Decoration)

Example 3 with AttributeValues

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

the class Font method deriveFont.

/**
     * Creates a new <code>Font</code> object by replicating the current
     * <code>Font</code> object and applying a new size to it.
     * @param size the size for the new <code>Font</code>.
     * @return a new <code>Font</code> object.
     * @since 1.2
     */
public Font deriveFont(float size) {
    if (values == null) {
        return new Font(name, style, size, createdFont, font2DHandle);
    }
    AttributeValues newValues = getAttributeValues().clone();
    newValues.setSize(size);
    return new Font(newValues, null, -1, createdFont, font2DHandle);
}
Also used : AttributeValues(sun.font.AttributeValues) CompositeFont(sun.font.CompositeFont)

Example 4 with AttributeValues

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

the class Font method deriveFont.

/**
     * Creates a new <code>Font</code> object by replicating this
     * <code>Font</code> object and applying a new style and size.
     * @param style the style for the new <code>Font</code>
     * @param size the size for the new <code>Font</code>
     * @return a new <code>Font</code> object.
     * @since 1.2
     */
public Font deriveFont(int style, float size) {
    if (values == null) {
        return new Font(name, style, size, createdFont, font2DHandle);
    }
    AttributeValues newValues = getAttributeValues().clone();
    int oldStyle = (this.style != style) ? this.style : -1;
    applyStyle(style, newValues);
    newValues.setSize(size);
    return new Font(newValues, null, oldStyle, createdFont, font2DHandle);
}
Also used : AttributeValues(sun.font.AttributeValues) CompositeFont(sun.font.CompositeFont)

Example 5 with AttributeValues

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

the class Font method deriveFont.

/**
     * Creates a new <code>Font</code> object by replicating the current
     * <code>Font</code> object and applying a new transform to it.
     * @param trans the <code>AffineTransform</code> associated with the
     * new <code>Font</code>
     * @return a new <code>Font</code> object.
     * @throws IllegalArgumentException if <code>trans</code> is
     *         <code>null</code>
     * @since 1.2
     */
public Font deriveFont(AffineTransform trans) {
    AttributeValues newValues = getAttributeValues().clone();
    applyTransform(trans, newValues);
    return new Font(newValues, null, -1, createdFont, font2DHandle);
}
Also used : AttributeValues(sun.font.AttributeValues) CompositeFont(sun.font.CompositeFont)

Aggregations

AttributeValues (sun.font.AttributeValues)11 CompositeFont (sun.font.CompositeFont)7 AffineTransform (java.awt.geom.AffineTransform)1 Bidi (java.text.Bidi)1 AttributeMap (sun.font.AttributeMap)1 Decoration (sun.font.Decoration)1 TextLabelFactory (sun.font.TextLabelFactory)1 TextLineComponent (sun.font.TextLineComponent)1