Improved font size eval

This commit is contained in:
M66B 2021-04-20 20:17:00 +02:00
parent 2eb90bc2c3
commit ed802c800f
1 changed files with 14 additions and 15 deletions

View File

@ -475,26 +475,25 @@ public class HtmlHelper {
if (!TextUtils.isEmpty(color)) if (!TextUtils.isEmpty(color))
sb.append("color:").append(color).append(";"); sb.append("color:").append(color).append(";");
if (!TextUtils.isEmpty(size)) { if (!TextUtils.isEmpty(size))
try { try {
if (size.startsWith("-")) int s = Integer.parseInt(size);
size = "smaller"; if (size.startsWith("-")) {
else if (size.startsWith("+")) if (s < 0)
size = "larger"; size = "smaller";
else { } else if (size.startsWith("+")) {
int s = Integer.parseInt(size); if (s > 0)
if (s < 3) size = "larger";
size = "small"; } else if (s >= 1 && s < 3)
else if (s > 3) size = "small";
size = "large"; else if (s > 3 && s <= 7)
else size = "large";
size = "medium"; else
} size = "medium";
sb.append("font-size:").append(size).append(";"); sb.append("font-size:").append(size).append(";");
} catch (NumberFormatException ex) { } catch (NumberFormatException ex) {
Log.i(ex); Log.i(ex);
} }
}
if (!TextUtils.isEmpty(face)) { if (!TextUtils.isEmpty(face)) {
sb.append("font-family:"); sb.append("font-family:");