mirror of
https://github.com/M66B/FairEmail.git
synced 2026-03-25 18:35:06 +01:00
Added OpenDyslexic
This commit is contained in:
@@ -31,3 +31,4 @@ FairEmail uses:
|
||||
* [Compact Language Detector v3](https://github.com/google/cld3). Copyright 2016 Google Inc. All rights reserved. [Apache License 2.0](https://github.com/google/cld3/blob/master/LICENSE).
|
||||
* [POI-HMEF](https://poi.apache.org/components/hmef/index.html). Copyright © 2001-2020 The Apache Software Foundation. [Apache Software License v2](https://poi.apache.org/devel/guidelines.html#The+Licensing).
|
||||
* [GoSquared's Flag Icon Set](https://github.com/gosquared/flags). Copyright (c) 2017 Go Squared Ltd. [MIT License](https://github.com/gosquared/flags/blob/master/LICENSE.txt).
|
||||
* [OpenDyslexic](https://github.com/antijingoist/opendyslexic). Copyright (c) 12/2012 - 2019. Copyright (c) 2019-07-29, Abbie Gonzalez. [SIL Open Font License 1.1](https://github.com/antijingoist/opendyslexic/blob/master/OFL.txt).
|
||||
|
||||
@@ -31,3 +31,4 @@ FairEmail uses:
|
||||
* [Compact Language Detector v3](https://github.com/google/cld3). Copyright 2016 Google Inc. All rights reserved. [Apache License 2.0](https://github.com/google/cld3/blob/master/LICENSE).
|
||||
* [POI-HMEF](https://poi.apache.org/components/hmef/index.html). Copyright © 2001-2020 The Apache Software Foundation. [Apache Software License v2](https://poi.apache.org/devel/guidelines.html#The+Licensing).
|
||||
* [GoSquared's Flag Icon Set](https://github.com/gosquared/flags). Copyright (c) 2017 Go Squared Ltd. [MIT License](https://github.com/gosquared/flags/blob/master/LICENSE.txt).
|
||||
* [OpenDyslexic](https://github.com/antijingoist/opendyslexic). Copyright (c) 12/2012 - 2019. Copyright (c) 2019-07-29, Abbie Gonzalez. [SIL Open Font License 1.1](https://github.com/antijingoist/opendyslexic/blob/master/OFL.txt).
|
||||
|
||||
@@ -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 ");
|
||||
}
|
||||
|
||||
9
app/src/main/res/font/opendyslexic.xml
Normal file
9
app/src/main/res/font/opendyslexic.xml
Normal file
@@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<font-family xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
<!-- https://developer.android.com/guide/topics/ui/look-and-feel/fonts-in-xml -->
|
||||
<font
|
||||
app:font="@font/opendyslexic_normal"
|
||||
app:fontStyle="normal"
|
||||
app:fontWeight="400" />
|
||||
<!-- https://opendyslexic.org/ -->
|
||||
</font-family>
|
||||
BIN
app/src/main/res/font/opendyslexic_normal.ttf
Normal file
BIN
app/src/main/res/font/opendyslexic_normal.ttf
Normal file
Binary file not shown.
@@ -1891,6 +1891,8 @@
|
||||
<item>Sans-serif</item>
|
||||
<item>Monospace</item>
|
||||
<item>Fantasy</item>
|
||||
<item>Fantasy</item>
|
||||
<item>Dyslexia</item>
|
||||
</string-array>
|
||||
|
||||
<!-- https://www.w3.org/TR/css-fonts-4/#generic-font-families -->
|
||||
@@ -1900,6 +1902,7 @@
|
||||
<item>sans-serif</item>
|
||||
<item>monospace</item>
|
||||
<item>fantasy</item>
|
||||
<item>comic sans</item>
|
||||
</string-array>
|
||||
|
||||
<string name="fingerprint" translatable="false">17BA15C1AF55D925F98B99CEA4375D4CDF4C174B</string>
|
||||
|
||||
Reference in New Issue
Block a user