Search in sources :

Example 1 with Superscript

use of com.xenoage.zong.core.text.Superscript in project Zong by Xenoage.

the class FormattedTextConverter method getStyleFromAttributeSet.

private static FormattedTextStyle getStyleFromAttributeSet(AttributeSet attr) {
    if (attr == null) {
        return FormattedTextStyle.Companion.getDefaultStyle();
    }
    // font style
    FontStyle fontStyle = FontStyle.normal;
    if (StyleConstants.isBold(attr)) {
        fontStyle = fontStyle.with(FontStyle.Bold);
    }
    if (StyleConstants.isItalic(attr)) {
        fontStyle = fontStyle.with(FontStyle.Italic);
    }
    if (StyleConstants.isUnderline(attr)) {
        fontStyle = fontStyle.with(FontStyle.Underline);
    }
    if (StyleConstants.isStrikeThrough(attr)) {
        fontStyle = fontStyle.with(FontStyle.Strikethrough);
    }
    // superscript
    Superscript superscript = Superscript.Normal;
    if (StyleConstants.isSuperscript(attr)) {
        superscript = Superscript.Super;
    }
    if (StyleConstants.isSubscript(attr)) {
        superscript = Superscript.Sub;
    }
    // font
    FontInfo fontInfo = new FontInfo(StyleConstants.getFontFamily(attr), (float) StyleConstants.getFontSize(attr), fontStyle);
    return new FormattedTextStyle(fontInfo, fromAwtColor(StyleConstants.getForeground(attr)), superscript);
}
Also used : FontStyle(com.xenoage.utils.font.FontStyle) FormattedTextStyle(com.xenoage.zong.core.text.FormattedTextStyle) Superscript(com.xenoage.zong.core.text.Superscript) FontInfo(com.xenoage.utils.font.FontInfo)

Aggregations

FontInfo (com.xenoage.utils.font.FontInfo)1 FontStyle (com.xenoage.utils.font.FontStyle)1 FormattedTextStyle (com.xenoage.zong.core.text.FormattedTextStyle)1 Superscript (com.xenoage.zong.core.text.Superscript)1