use of com.google.android.exoplayer2.text.span.TextEmphasisSpan in project ExoPlayer by google.
the class SpannedToHtmlConverter method getOpeningTag.
@Nullable
private static String getOpeningTag(Object span, float displayDensity) {
if (span instanceof StrikethroughSpan) {
return "<span style='text-decoration:line-through;'>";
} else if (span instanceof ForegroundColorSpan) {
ForegroundColorSpan colorSpan = (ForegroundColorSpan) span;
return Util.formatInvariant("<span style='color:%s;'>", HtmlUtils.toCssRgba(colorSpan.getForegroundColor()));
} else if (span instanceof BackgroundColorSpan) {
BackgroundColorSpan colorSpan = (BackgroundColorSpan) span;
return Util.formatInvariant("<span class='bg_%s'>", colorSpan.getBackgroundColor());
} else if (span instanceof HorizontalTextInVerticalContextSpan) {
return "<span style='text-combine-upright:all;'>";
} else if (span instanceof AbsoluteSizeSpan) {
AbsoluteSizeSpan absoluteSizeSpan = (AbsoluteSizeSpan) span;
float sizeCssPx = absoluteSizeSpan.getDip() ? absoluteSizeSpan.getSize() : absoluteSizeSpan.getSize() / displayDensity;
return Util.formatInvariant("<span style='font-size:%.2fpx;'>", sizeCssPx);
} else if (span instanceof RelativeSizeSpan) {
return Util.formatInvariant("<span style='font-size:%.2f%%;'>", ((RelativeSizeSpan) span).getSizeChange() * 100);
} else if (span instanceof TypefaceSpan) {
@Nullable String fontFamily = ((TypefaceSpan) span).getFamily();
return fontFamily != null ? Util.formatInvariant("<span style='font-family:\"%s\";'>", fontFamily) : null;
} else if (span instanceof StyleSpan) {
switch(((StyleSpan) span).getStyle()) {
case Typeface.BOLD:
return "<b>";
case Typeface.ITALIC:
return "<i>";
case Typeface.BOLD_ITALIC:
return "<b><i>";
default:
return null;
}
} else if (span instanceof RubySpan) {
RubySpan rubySpan = (RubySpan) span;
switch(rubySpan.position) {
case TextAnnotation.POSITION_BEFORE:
return "<ruby style='ruby-position:over;'>";
case TextAnnotation.POSITION_AFTER:
return "<ruby style='ruby-position:under;'>";
case TextAnnotation.POSITION_UNKNOWN:
return "<ruby style='ruby-position:unset;'>";
default:
return null;
}
} else if (span instanceof UnderlineSpan) {
return "<u>";
} else if (span instanceof TextEmphasisSpan) {
TextEmphasisSpan textEmphasisSpan = (TextEmphasisSpan) span;
String style = getTextEmphasisStyle(textEmphasisSpan.markShape, textEmphasisSpan.markFill);
String position = getTextEmphasisPosition(textEmphasisSpan.position);
return Util.formatInvariant("<span style='-webkit-text-emphasis-style:%1$s;text-emphasis-style:%1$s;" + "-webkit-text-emphasis-position:%2$s;text-emphasis-position:%2$s;" + "display:inline-block;'>", style, position);
} else {
return null;
}
}
Aggregations