From dad15fe4f653b2e5a9d94778dfbef5f593481367 Mon Sep 17 00:00:00 2001 From: M66B Date: Thu, 20 Feb 2020 11:30:43 +0100 Subject: [PATCH] Fixed very small/large fonts --- .../main/java/eu/faircode/email/HtmlHelper.java | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/eu/faircode/email/HtmlHelper.java b/app/src/main/java/eu/faircode/email/HtmlHelper.java index 1ecb7ad220..b6786965a3 100644 --- a/app/src/main/java/eu/faircode/email/HtmlHelper.java +++ b/app/src/main/java/eu/faircode/email/HtmlHelper.java @@ -405,8 +405,22 @@ public class HtmlHelper { // https://developer.mozilla.org/en-US/docs/Web/CSS/font-size Element parent = element.parent(); if (parent != null) { + boolean set = false; + boolean small = false; + boolean big = false; Integer current = null; while (parent != null) { + if (!set) { + if ("small".equals(parent.tagName())) { + set = true; + small = true; + } + if ("big".equals(parent.tagName())) { + set = true; + big = true; + } + } + String xFontSize = parent.attr("x-font-size"); if (!TextUtils.isEmpty(xFontSize)) { current = Integer.parseInt(xFontSize); @@ -417,7 +431,7 @@ public class HtmlHelper { Float fsize = getFontSize(value, current); if (fsize != null && fsize != 0 && - (fsize <= 0.8f || fsize >= 1.25)) { + ((!small && fsize <= 0.8f) || (!big && fsize >= 1.25))) { Element e = new Element(fsize < 1 ? "small" : "big"); e.attr("x-font-size", Integer.toString(Math.round(16 * fsize))); element.replaceWith(e);