Search in sources :

Example 1 with TopSpanIterator

use of com.mta.tehreer.internal.text.TopSpanIterator in project Tehreer-Android by mta452.

the class Typesetter method resolveFonts.

private void resolveFonts(int charStart, int charEnd, byte bidiLevel, ShapingEngine shapingEngine, Typeface typeface) {
    Spanned spanned = mSpanned;
    TopSpanIterator<TypeSizeSpan> iterator = new TopSpanIterator<>(spanned, charStart, charEnd, TypeSizeSpan.class);
    while (iterator.hasNext()) {
        TypeSizeSpan spanObject = iterator.next();
        int spanStart = iterator.getSpanStart();
        int spanEnd = iterator.getSpanEnd();
        float typeSize;
        if (spanObject == null) {
            typeSize = DEFAULT_FONT_SIZE;
        } else {
            typeSize = spanObject.getSize();
            if (typeSize < 0.0f) {
                typeSize = 0.0f;
            }
        }
        IntrinsicRun intrinsicRun = resolveGlyphs(spanStart, spanEnd, bidiLevel, shapingEngine, typeface, typeSize);
        mIntrinsicRuns.add(intrinsicRun);
    }
}
Also used : TopSpanIterator(com.mta.tehreer.internal.text.TopSpanIterator) TypeSizeSpan(com.mta.tehreer.layout.style.TypeSizeSpan) Spanned(android.text.Spanned)

Example 2 with TopSpanIterator

use of com.mta.tehreer.internal.text.TopSpanIterator in project Tehreer-Android by mta452.

the class Typesetter method resolveTypefaces.

private void resolveTypefaces(int charStart, int charEnd, byte bidiLevel, ShapingEngine shapingEngine) {
    Spanned spanned = mSpanned;
    TopSpanIterator<TypefaceSpan> iterator = new TopSpanIterator<>(spanned, charStart, charEnd, TypefaceSpan.class);
    while (iterator.hasNext()) {
        TypefaceSpan spanObject = iterator.next();
        int spanStart = iterator.getSpanStart();
        int spanEnd = iterator.getSpanEnd();
        if (spanObject == null || spanObject.getTypeface() == null) {
            throw new IllegalArgumentException("No typeface is specified for range [" + spanStart + ".." + spanEnd + ")");
        }
        resolveFonts(spanStart, spanEnd, bidiLevel, shapingEngine, spanObject.getTypeface());
    }
}
Also used : TopSpanIterator(com.mta.tehreer.internal.text.TopSpanIterator) Spanned(android.text.Spanned) TypefaceSpan(com.mta.tehreer.layout.style.TypefaceSpan)

Aggregations

Spanned (android.text.Spanned)2 TopSpanIterator (com.mta.tehreer.internal.text.TopSpanIterator)2 TypeSizeSpan (com.mta.tehreer.layout.style.TypeSizeSpan)1 TypefaceSpan (com.mta.tehreer.layout.style.TypefaceSpan)1