@NonNull
    public static Spanned style(@NonNull Context ctx,
                                @Nullable HashMap<String, ITypeface> fonts,
                                @NonNull Spanned textSpanned,
                                @Nullable List<CharacterStyle> styles,
                                @Nullable HashMap<String, List<CharacterStyle>> stylesFor) {
        fonts = init(ctx, fonts);

        //find all icons which should be replaced with the iconFont
        TextStyleContainer textStyleContainer = IconicsUtils.findIcons(textSpanned, fonts);

        //create spannableString to set the spans on
        SpannableString sb = SpannableString.valueOf(textStyleContainer.spannableStringBuilder);

        //set all the icons and styles
        IconicsUtils.applyStyles(ctx, sb, textStyleContainer.styleContainers, styles, stylesFor);

        return sb;
    }
@ NonNull public static Spanned style ( @ NonNull Context ctx , @ Nullable HashMap < String , ITypeface > fonts , @ NonNull Spanned textSpanned , @ Nullable List < CharacterStyle > styles , @ Nullable HashMap < String , List < CharacterStyle > > stylesFor ) { fonts = init ( ctx , fonts ) ; TextStyleContainer textStyleContainer = IconicsUtils . findIcons ( textSpanned , fonts ) ; SpannableString sb = SpannableString . valueOf ( textStyleContainer . spannableStringBuilder ) ; IconicsUtils . applyStyles ( ctx , sb , textStyleContainer . styleContainers , styles , stylesFor ) ; return sb ; }
Creates a new SpannableStringBuilder and will iterate over the textSpanned once and copy over
all characters, it will also directly replace icon font placeholders with the correct mapping.
Afterwards it will apply the styles