mirror of
https://github.com/M66B/FairEmail.git
synced 2026-04-03 15:46:34 +02:00
Added OpenDyslexic
This commit is contained in:
@@ -54,7 +54,6 @@ import android.util.Patterns;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.core.content.FileProvider;
|
||||
import androidx.core.content.res.ResourcesCompat;
|
||||
import androidx.core.graphics.ColorUtils;
|
||||
import androidx.core.util.PatternsCompat;
|
||||
import androidx.preference.PreferenceManager;
|
||||
@@ -2256,11 +2255,7 @@ public class HtmlHelper {
|
||||
}
|
||||
break;
|
||||
case "font-family":
|
||||
String face = value.toLowerCase(Locale.ROOT);
|
||||
if ("fairemail".equals(face)) {
|
||||
Typeface typeface = ResourcesCompat.getFont(context, R.font.fantasy);
|
||||
setSpan(ssb, new CustomTypefaceSpan(face, typeface), start, ssb.length());
|
||||
} else if ("wingdings".equals(face)) {
|
||||
if ("wingdings".equalsIgnoreCase(value)) {
|
||||
for (int i = start; i < ssb.length(); i++) {
|
||||
int kar = ssb.charAt(i);
|
||||
if (kar >= 0x20 && kar < 0x20 + WINGDING_TO_UNICODE.length) {
|
||||
@@ -2271,7 +2266,7 @@ public class HtmlHelper {
|
||||
}
|
||||
}
|
||||
} else
|
||||
setSpan(ssb, new TypefaceSpan(face), start, ssb.length());
|
||||
setSpan(ssb, StyleHelper.getTypefaceSpan(value, context), start, ssb.length());
|
||||
break;
|
||||
case "text-decoration":
|
||||
if ("line-through".equals(value))
|
||||
|
||||
@@ -49,6 +49,7 @@ import android.view.View;
|
||||
import android.widget.EditText;
|
||||
|
||||
import androidx.appcompat.widget.PopupMenu;
|
||||
import androidx.core.content.res.ResourcesCompat;
|
||||
import androidx.lifecycle.LifecycleOwner;
|
||||
import androidx.preference.PreferenceManager;
|
||||
|
||||
@@ -155,7 +156,7 @@ public class StyleHelper {
|
||||
SubMenu smenu = popupMenu.getMenu().findItem(R.id.menu_style_font).getSubMenu();
|
||||
for (int i = 0; i < fontNameNames.length; i++) {
|
||||
SpannableStringBuilder ssb = new SpannableStringBuilder(fontNameNames[i]);
|
||||
ssb.setSpan(new TypefaceSpan(fontNameValues[i]), 0, ssb.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||
ssb.setSpan(getTypefaceSpan(fontNameValues[i], context), 0, ssb.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||
smenu.add(R.id.group_style_font, i, 0, ssb);
|
||||
}
|
||||
smenu.add(R.id.group_style_font, fontNameNames.length, 0, R.string.title_style_font_default);
|
||||
@@ -412,11 +413,12 @@ public class StyleHelper {
|
||||
int f = edit.getSpanFlags(span);
|
||||
edit.removeSpan(span);
|
||||
splitSpan(edit, start, end, s, e, f, false,
|
||||
new TypefaceSpan(span.getFamily()), new TypefaceSpan(span.getFamily()));
|
||||
getTypefaceSpan(span.getFamily(), context),
|
||||
getTypefaceSpan(span.getFamily(), context));
|
||||
}
|
||||
|
||||
if (face != null)
|
||||
edit.setSpan(new TypefaceSpan(face), start, end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||
edit.setSpan(getTypefaceSpan(face, context), start, end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||
|
||||
etBody.setText(edit);
|
||||
etBody.setSelection(start, end);
|
||||
@@ -761,5 +763,17 @@ public class StyleHelper {
|
||||
}
|
||||
}
|
||||
|
||||
static TypefaceSpan getTypefaceSpan(String family, Context context) {
|
||||
String face = family.toLowerCase(Locale.ROOT);
|
||||
if ("fairemail".equals(face)) {
|
||||
Typeface typeface = ResourcesCompat.getFont(context, R.font.fantasy);
|
||||
return new CustomTypefaceSpan(face, typeface);
|
||||
} else if (face.contains("comic sans")) {
|
||||
Typeface typeface = ResourcesCompat.getFont(context, R.font.opendyslexic);
|
||||
return new CustomTypefaceSpan(face, typeface);
|
||||
} else
|
||||
return new TypefaceSpan(face);
|
||||
}
|
||||
|
||||
//TextUtils.dumpSpans(text, new LogPrinter(android.util.Log.INFO, "FairEmail"), "afterTextChanged ");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user