package com.remax.visualnovel.extension

import android.content.Context
import android.content.res.Resources

/**
 * Created by HJW on 2023/3/17
 */

/**
 * 字体大小不随着系统大小变动
 */
fun Resources.fixedFontSize(context: Context): Resources {
    var resources = this
    val newConfig = resources.configuration
    val displayMetrics = resources.displayMetrics
    if (newConfig.fontScale != 1f) {
        newConfig.fontScale = 1f
        val configurationContext = context.createConfigurationContext(newConfig)
        resources = configurationContext.resources
        displayMetrics.scaledDensity = displayMetrics.density * newConfig.fontScale
    }
    return resources
}