package com.ydl.ydlcommon.utils

import android.content.Context
import android.graphics.Typeface
import android.text.SpannableString
import android.text.Spanned
import android.text.style.StyleSpan

class FontUtils {
    companion object {

        fun getMultiFontText(
            text: String,
            wordsToBold: Array<String>
        ): SpannableString? {
            val spannableString = SpannableString(text)
            for (word in wordsToBold) {
                var startIndex = text.indexOf(word)
                while (startIndex >= 0) {
                    val endIndex = startIndex + word.length
                    spannableString.setSpan(
                        StyleSpan(Typeface.BOLD),
                        startIndex,
                        endIndex,
                        Spanned.SPAN_EXCLUSIVE_EXCLUSIVE
                    )
                    startIndex = text.indexOf(word, endIndex + 1)
                }
            }
            return spannableString
        }
    }
}