Improved font element handling

This commit is contained in:
M66B 2020-04-26 18:43:20 +02:00
parent c9f3bf7f99
commit 5ab3a79355
1 changed files with 8 additions and 1 deletions

View File

@ -458,14 +458,18 @@ public class HtmlHelper {
// Font
for (Element font : document.select("font")) {
// https://developer.mozilla.org/en-US/docs/Web/HTML/Element/font
String style = font.attr("style");
String color = font.attr("color");
String size = font.attr("size");
style = style.trim();
if (!TextUtils.isEmpty(style) && !style.endsWith(";"))
style += ";";
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
font.removeAttr("color");
font.removeAttr("size");
StringBuilder sb = new StringBuilder();
StringBuilder sb = new StringBuilder(style);
if (!TextUtils.isEmpty(color))
sb.append("color:").append(color).append(";");
@ -1924,6 +1928,9 @@ public class HtmlHelper {
case "em":
ssb.setSpan(new StyleSpan(Typeface.ITALIC), start, ssb.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
break;
case "font":
// Do nothing
break;
case "h1":
case "h2":
case "h3":