无法使用自定义字体

问题描述 投票:0回答:1
import androidx.compose.material3.Typography
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.font.Font
import androidx.compose.ui.text.font.FontFamily
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.sp
import com.example.meditationui.R


val gothicA1 = FontFamily(
    listOf(
        Font(R.font.gothica1_regular, FontWeight.Normal),
        Font(R.font.gothica1_medium, FontWeight.Medium),
        Font(R.font.gothica1_semibold, FontWeight.SemiBold),
        Font(R.font.gothica1_bold, FontWeight.Bold),
        Font(R.font.gothica1_black, FontWeight.Black),
    )
)

// Set of Material typography styles to start with
val Typography = Typography(
    bodyLarge = TextStyle(
        fontFamily = FontFamily.Default,
        fontWeight = FontWeight.Normal,
        fontSize = 16.sp,
        lineHeight = 24.sp,
        letterSpacing = 0.5.sp
    ),
    h1 = TextStyle(
        color = TextWhite,
        fontFamily = gothicA1,
        fontWeight = FontWeight.Bold,
        fontSize = 22.sp
    )
)

Android Studio 未检测到 h1“无法找到具有此名称的参数:h1”

我尝试将自定义字体系列添加到我的项目中,但我不断面临这个问题“找不到具有此名称的参数:h1”

android fonts android-jetpack-compose font-awesome
1个回答
0
投票
Material 的 Typography 类不支持

h1
。 您可以使用
headlineLarge
headlineMedium
headlineSmall
来代替。

© www.soinside.com 2019 - 2024. All rights reserved.