From ed802c800f0522d695102c922ee5fb9eb3431b04 Mon Sep 17 00:00:00 2001 From: M66B Date: Tue, 20 Apr 2021 20:17:00 +0200 Subject: [PATCH] Improved font size eval --- .../java/eu/faircode/email/HtmlHelper.java | 29 +++++++++---------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/HtmlHelper.java b/app/src/main/java/eu/faircode/email/HtmlHelper.java index 4c19a0870c..68f7359a3a 100644 --- a/app/src/main/java/eu/faircode/email/HtmlHelper.java +++ b/app/src/main/java/eu/faircode/email/HtmlHelper.java @@ -475,26 +475,25 @@ public class HtmlHelper { if (!TextUtils.isEmpty(color)) sb.append("color:").append(color).append(";"); - if (!TextUtils.isEmpty(size)) { + if (!TextUtils.isEmpty(size)) try { - if (size.startsWith("-")) - size = "smaller"; - else if (size.startsWith("+")) - size = "larger"; - else { - int s = Integer.parseInt(size); - if (s < 3) - size = "small"; - else if (s > 3) - size = "large"; - else - size = "medium"; - } + int s = Integer.parseInt(size); + if (size.startsWith("-")) { + if (s < 0) + size = "smaller"; + } else if (size.startsWith("+")) { + if (s > 0) + size = "larger"; + } else if (s >= 1 && s < 3) + size = "small"; + else if (s > 3 && s <= 7) + size = "large"; + else + size = "medium"; sb.append("font-size:").append(size).append(";"); } catch (NumberFormatException ex) { Log.i(ex); } - } if (!TextUtils.isEmpty(face)) { sb.append("font-family:");