Post

Replies

Boosts

Views

Activity

Custom Fonts in Swift Package
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: .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: 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: 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?
7
0
9.7k
Jul ’20