
📌참고자료
📌참고자료
dependencies {
    ...
    implementation "androidx.compose.ui:ui-text-google-fonts:1.6.1"
}
//(1) configure Google Font Provider
val provider = GoogleFont.Provider(
    providerAuthority = "com.google.android.gms.fonts",
    providerPackage = "com.google.android.gms",
    certificates = R.array.com_google_android_gms_fonts_certs
)
//(2) pick your google font -> build your font family 
// can determine a chain of fallbacks for your font in case the font fails to download properly
val fontFamily = FontFamily(
	Font(googleFont = LobsterTwo, fontProvider = provider),
    Font(resId = R.font.my_font_regular), // define default
    Font(googleFont = googleFont, fontProvider = provider, weight = FontWeight.Bold),
    Font(resId = R.font.my_font_regular_bold, weight = FontWeight.Bold) // define default
)
//(3) set yout font famity to your Typography/individual Text composable 
Text(
    fontFamily = fontFamily, text = "Hello World!"
)
Google Font Provider 생성자 파라미터
test if google font provider is available & certificates are configured correctly
    val context = LocalContext.current
    LaunchedEffect(Unit) {
        if (provider.isAvailableOnDevice(context)) {
            Log.d(TAG, "Google Font Provider Configuration Success!")
        }
    }
    // pre-load downloadable fonts
    val fontFamilyResolver = LocalFontFamilyResolver.current
    val coroutineScope = rememberCoroutineScope()
    LaunchedEffect(Unit) {
        coroutineScope.launch(Dispatchers.IO) {
            fontFamilyResolver.preload(fontFamily)
        }
    }
FontFamily.Resolver:fun resolve(
    fontFamily: FontFamily? = null,
    fontWeight: FontWeight = FontWeight.Normal,
    fontStyle: FontStyle = FontStyle.Normal,
    fontSynthesis: FontSynthesis = FontSynthesis.All
): State<Any>
suspend fun preload(fontFamily: FontFamily): Unit
FontVariation API 사용// VariableFontDimension.kt
object DisplayLargeVFConfig {
    const val WEIGHT = 950
    const val WIDTH = 30f
    const val SLANT = -6f
    const val ASCENDER_HEIGHT = 800f
    const val COUNTER_WIDTH = 500
}
// In Typography.kt
val default = FontFamily(
    /*
    * This can be any font that makes sense
    */
    Font(
        R.font.robotoflex_static_regular
    )
)
@OptIn(ExperimentalTextApi::class)
val displayLargeFontFamily = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
    FontFamily(
        Font(
            R.font.robotoflex_variable, 
            variationSettings = FontVariation.Settings(
                FontVariation.weight(DisplayLargeVFConfig.WEIGHT),
                FontVariation.width(DisplayLargeVFConfig.WIDTH),
                FontVariation.slant(DisplayLargeVFConfig.SLANT),
            )
        )
    )
} else {
    default
}
FontVariation.Setting으로 정의 fun counterWidth(counterWidth: Int): FontVariation.Setting {
	// define guardrails for the value
    require(counterWidth in 323..603) { "'Counter width' must be in 323..603" }
    // return font setting
    return FontVariation.Setting("XTRA", counterWidth.toFloat())
}