为什么我的自定义字体在 Xcode 中不起作用?

时间:2021-01-18 17:44:30

标签: fonts swiftui

所以这个问题遍布互联网,但我已经完成了几乎所有列出的成功解决方案的步骤,我想确保在我必须尝试重新安装我的 macOS 之前询问我的具体情况。我正在尝试在我的 iOS 应用程序 Montserrat 中使用自定义字体。字体文件名为“Montserrat-Regular.ttf”。我首先将文件添加到我的项目中,并将该项目选为目标:

enter image description here

我还在“应用程序提供的字体”中将它添加到我的 Info.plist 文件中:

enter image description here

它在我的复制包资源中:

enter image description here

尽管如此,当我尝试在我的 SwiftUI 应用程序中为 Text 对象使用字体时:

Text("Welcome Back!")
    .position(x: (geometry.size.width / 2), y: 160.0)
    .foregroundColor(.white)
    .font(Font.custom(Constants.FontStrings.montserratReg, size: 30.0))

我仍然使用默认字体。当我运行 for 循环来打印我拥有的所有字体系列时,有趣的是,蒙特塞拉特没有出现: enter image description here

即使它列在我的字体书中。实际上我的字体书中的一些字体没有出现在这里,我不确定这是否相关:

enter image description here

0 个答案:

没有答案
相关问题