Simplify font mapper

pull/199/head
M66B 4 years ago
parent 75467f3695
commit 6c00ea8ab4

@ -774,19 +774,20 @@ public class StyleHelper {
static Typeface getTypeface(String family, Context context) { static Typeface getTypeface(String family, Context context) {
String faces = family.toLowerCase(Locale.ROOT); String faces = family.toLowerCase(Locale.ROOT);
if (faces.equals("fairemail"))
return ResourcesCompat.getFont(context, R.font.fantasy);
if (faces.contains("comic sans"))
return ResourcesCompat.getFont(context, R.font.opendyslexic);
for (String face : faces.split(",")) { for (String face : faces.split(",")) {
face = face.trim().replace("\"", ""); face = face.trim().replace("\"", "");
if ("fairemail".equals(face)) Typeface tf = Typeface.create(face, Typeface.NORMAL);
return ResourcesCompat.getFont(context, R.font.fantasy); if (!tf.equals(Typeface.DEFAULT))
else if (face.contains("comic sans")) return tf;
return ResourcesCompat.getFont(context, R.font.opendyslexic);
else if (face.equals("times new roman") || face.equals("serif"))
return Typeface.SERIF;
else if (face.equals("arial") || face.equals("sans-serif"))
return Typeface.SANS_SERIF;
} }
return Typeface.DEFAULT;
return Typeface.create(family, Typeface.NORMAL);
} }
//TextUtils.dumpSpans(text, new LogPrinter(android.util.Log.INFO, "FairEmail"), "afterTextChanged "); //TextUtils.dumpSpans(text, new LogPrinter(android.util.Log.INFO, "FairEmail"), "afterTextChanged ");

Loading…
Cancel
Save