MCPcopy Create free account
hub / github.com/M66B/FairEmail / setFont

Method setFont

app/src/main/java/eu/faircode/email/StyleHelper.java:814–838  ·  view source on GitHub ↗
(EditText etBody, int start, int end, String face, boolean select)

Source from the content-addressed store, hash-verified

812 }
813
814 static boolean setFont(EditText etBody, int start, int end, String face, boolean select) {
815 Log.breadcrumb("style", "action", "font");
816
817 Context context = etBody.getContext();
818
819 Editable edit = etBody.getText();
820 TypefaceSpan[] spans = edit.getSpans(start, end, TypefaceSpan.class);
821 for (TypefaceSpan span : spans) {
822 int s = edit.getSpanStart(span);
823 int e = edit.getSpanEnd(span);
824 int f = edit.getSpanFlags(span);
825 edit.removeSpan(span);
826 splitSpan(edit, start, end, s, e, f, false,
827 getTypefaceSpan(span.getFamily(), context),
828 getTypefaceSpan(span.getFamily(), context));
829 }
830
831 if (face != null)
832 edit.setSpan(getTypefaceSpan(face, context), start, end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
833
834 etBody.setText(edit);
835 etBody.setSelection(select ? start : end, end);
836
837 return true;
838 }
839
840 static boolean selectAlignment(LifecycleOwner owner, View anchor, EditText etBody, int start, int end) {
841 Log.breadcrumb("style", "action", "selectAlignment");

Callers 2

applyMethod · 0.95
onMenuItemClickMethod · 0.95

Calls 13

breadcrumbMethod · 0.95
splitSpanMethod · 0.95
getTypefaceSpanMethod · 0.95
getFamilyMethod · 0.80
setTextMethod · 0.65
getTextMethod · 0.45
getSpansMethod · 0.45
getSpanStartMethod · 0.45
getSpanEndMethod · 0.45
getSpanFlagsMethod · 0.45
removeSpanMethod · 0.45
setSpanMethod · 0.45

Tested by

no test coverage detected