I have been able to ship some image and asset catalogs in a Swift package with success using Xcode 12b1 and Swift 5.3. I am not having so much luck with using a custom .ttf file in a Swift Package.
I am loading a .ttf file in the manifest like so:
And I noticed that there's no initializer on the Font type in SwiftUI to include an asset from a module. For example, this works:
However, there's no way to specify where a font is coming from. I was hoping that loading it into the module would emit it into the target for use, but no such luck:
This does not load the font as expected. I'm investigating using a CoreText api to try and trick it into loading, but I feel like there should be an easier way. Any advice?
I am loading a .ttf file in the manifest like so:
Code Block .target( name: "BestPackage", dependencies: [], resources: [ .copy("Resources/Fonts/CustomFont.ttf"), .process("Resources/Colors.xcassets") ] ),
And I noticed that there's no initializer on the Font type in SwiftUI to include an asset from a module. For example, this works:
Code Block static var PrimaryButtonBackgroundColor: SwiftUI.Color { Color("Components/Button/Background", bundle: .module) }
However, there's no way to specify where a font is coming from. I was hoping that loading it into the module would emit it into the target for use, but no such luck:
Code Block static var PrimaryButtonFont: Font { Font.custom("CustomFont", size: 34) }
This does not load the font as expected. I'm investigating using a CoreText api to try and trick it into loading, but I feel like there should be an easier way. Any advice?