use of com.xenoage.zong.core.text.FormattedTextStyle 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);
}
use of com.xenoage.zong.core.text.FormattedTextStyle in project Zong by Xenoage.
the class FormattedTextReader method readText.
@Override
public FormattedText readText(MxlFormattedText mxlText) {
String text = mxlText.getValue().trim();
FormattedTextStyle style = readStyle(mxlText);
Alignment alignment = readAlignment(mxlText);
return FormattedText.Companion.fText(text, style, alignment);
}
Aggregations