Ham*_*med 2 android android-jetpack-compose
我正在尝试将字体添加到我的应用程序中,但是当我在文件中声明字体时,Type.kt我收到此错误消息
变量“iranSansFontFamily”必须初始化
为什么我会收到此错误?
这是代码:
val CustomTypography = Typography(
bodyLarge = TextStyle(
fontFamily = iranSansFontFamily,
fontWeight = FontWeight.Normal,
fontSize = 16.sp,
lineHeight = 24.sp,
letterSpacing = 0.5.sp
)
)
val iranSansFontFamily = FontFamily(
Font(R.font.iransans_farsi_medium, FontWeight.Medium),
Font(R.font.iransans_farsi_bold, FontWeight.Bold)
)
Run Code Online (Sandbox Code Playgroud)
字体系列的声明必须位于版式的顶部,如下所示:
val iranSansFontFamily = FontFamily(
Font(R.font.iransans_farsi_medium, FontWeight.Medium),
Font(R.font.iransans_farsi_bold, FontWeight.Bold)
)
val CustomTypography = Typography(
bodyLarge = TextStyle(
fontFamily = iranSansFontFamily,
fontWeight = FontWeight.Normal,
fontSize = 16.sp,
lineHeight = 24.sp,
letterSpacing = 0.5.sp
)
)
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
334 次 |
| 最近记录: |