Search in sources :

Example 1 with TextLabelFactory

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

the class TextMeasurer method generateComponents.

/**
     * Generate components for the paragraph.  fChars, fBidi should have been
     * initialized already.
     */
private void generateComponents(int startingAt, int endingAt) {
    if (collectStats) {
        formattedChars += (endingAt - startingAt);
    }
    // no extra info yet, bidi determines run and line direction
    int layoutFlags = 0;
    TextLabelFactory factory = new TextLabelFactory(fFrc, fChars, fBidi, layoutFlags);
    int[] charsLtoV = null;
    if (fBidi != null) {
        fLevels = BidiUtils.getLevels(fBidi);
        int[] charsVtoL = BidiUtils.createVisualToLogicalMap(fLevels);
        charsLtoV = BidiUtils.createInverseMap(charsVtoL);
        fIsDirectionLTR = fBidi.baseIsLeftToRight();
    } else {
        fLevels = null;
        fIsDirectionLTR = true;
    }
    try {
        fComponents = TextLine.getComponents(fParagraph, fChars, startingAt, endingAt, charsLtoV, fLevels, factory);
    } catch (IllegalArgumentException e) {
        System.out.println("startingAt=" + startingAt + "; endingAt=" + endingAt);
        System.out.println("fComponentLimit=" + fComponentLimit);
        throw e;
    }
    fComponentStart = startingAt;
    fComponentLimit = endingAt;
//debugFormatCount += (endingAt-startingAt);
}
Also used : TextLabelFactory(sun.font.TextLabelFactory)

Example 2 with TextLabelFactory

use of sun.font.TextLabelFactory 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 TextLabelFactory

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

the class TextLine method standardCreateTextLine.

/**
     * Create a TextLine from the text.  chars is just the text in the iterator.
     */
public static TextLine standardCreateTextLine(FontRenderContext frc, AttributedCharacterIterator text, char[] chars, float[] baselineOffsets) {
    StyledParagraph styledParagraph = new StyledParagraph(text, chars);
    Bidi bidi = new Bidi(text);
    if (bidi.isLeftToRight()) {
        bidi = null;
    }
    // no extra info yet, bidi determines run and line direction
    int layoutFlags = 0;
    TextLabelFactory factory = new TextLabelFactory(frc, chars, bidi, layoutFlags);
    boolean isDirectionLTR = true;
    if (bidi != null) {
        isDirectionLTR = bidi.baseIsLeftToRight();
    }
    return createLineFromText(chars, styledParagraph, factory, isDirectionLTR, baselineOffsets);
}
Also used : Bidi(java.text.Bidi) TextLabelFactory(sun.font.TextLabelFactory)

Aggregations

TextLabelFactory (sun.font.TextLabelFactory)3 Bidi (java.text.Bidi)2 AttributeValues (sun.font.AttributeValues)1 Decoration (sun.font.Decoration)1 TextLineComponent (sun.font.TextLineComponent)1