Search in sources :

Example 1 with CodePointIterator

use of sun.text.CodePointIterator in project jdk8u_jdk by JetBrains.

the class StyledParagraph method addFonts.

/**
     * Resolve the given chars into Fonts using FontResolver, then add
     * font runs for each.
     */
private void addFonts(char[] chars, Map<? extends Attribute, ?> attributes, int start, int limit) {
    FontResolver resolver = FontResolver.getInstance();
    CodePointIterator iter = CodePointIterator.create(chars, start, limit);
    for (int runStart = iter.charIndex(); runStart < limit; runStart = iter.charIndex()) {
        int fontIndex = resolver.nextFontRunIndex(iter);
        addFont(resolver.getFont(fontIndex, attributes), runStart);
    }
}
Also used : CodePointIterator(sun.text.CodePointIterator) FontResolver(sun.font.FontResolver)

Example 2 with CodePointIterator

use of sun.text.CodePointIterator in project jdk8u_jdk by JetBrains.

the class TextLayout method singleFont.

/*
     * Determines a font for the attributes, and if a single font can render
     * all the text on one baseline, return it, otherwise null.  If the
     * attributes specify a font, assume it can display all the text without
     * checking.
     * If the AttributeSet contains an embedded graphic, return null.
     */
private static Font singleFont(char[] text, int start, int limit, Map<? extends Attribute, ?> attributes) {
    if (attributes.get(TextAttribute.CHAR_REPLACEMENT) != null) {
        return null;
    }
    Font font = null;
    try {
        font = (Font) attributes.get(TextAttribute.FONT);
    } catch (ClassCastException e) {
    }
    if (font == null) {
        if (attributes.get(TextAttribute.FAMILY) != null) {
            font = Font.getFont(attributes);
            if (font.canDisplayUpTo(text, start, limit) != -1) {
                return null;
            }
        } else {
            FontResolver resolver = FontResolver.getInstance();
            CodePointIterator iter = CodePointIterator.create(text, start, limit);
            int fontIndex = resolver.nextFontRunIndex(iter);
            if (iter.charIndex() == limit) {
                font = resolver.getFont(fontIndex, attributes);
            }
        }
    }
    if (sameBaselineUpTo(font, text, start, limit) != limit) {
        return null;
    }
    return font;
}
Also used : CodePointIterator(sun.text.CodePointIterator) FontResolver(sun.font.FontResolver) Font(java.awt.Font)

Aggregations

FontResolver (sun.font.FontResolver)2 CodePointIterator (sun.text.CodePointIterator)2 Font (java.awt.Font)1