skip
skip copied to clipboard
skip CLI should have a `skip font` command
Apropos #345 and #346, it's very complicated to set up fonts correctly in a Skip app, and worst part is that when you mess it up, the build succeeds, and the app just silently shows the system-default font, with no warning or message in the build/runtime logs about missing fonts.
The skip CLI has a skip icon command that takes care of icons for you; I think it would be really helpful to have a skip font command that can take care of fonts, too.
You'd pass it the name of a file, like skip font ProtestGuerrilla-Regular.ttf, and it would:
- Read the Postscript metadata and compute a font file name to match Android standards (
protest_guerilla.ttf) - Copy the file into
Sources/MyApp/Resourceswith the right name - Add any project references / symlinks necessary to make the font work in Android
- Add the file to
UIAppFonts - Print out example code of how to use the font, ensuring that the developer uses the font's PostScript name and not the file's name.
Text("Hello, world").font(.custom("Protest Guerilla", size: 30.0))
Maybe even generate an extension to Font that would let you use the font in a typesafe way.
public enum BundledFont: String {
case ProtestGuerrilla = "Protest Guerrilla"
}
extension Font {
public static func bundled(_ font: BundledFont, size: CGFloat) -> Font {
return .custom(font.rawValue, size: size)
}
}
Then, skip font could suggest:
Text("Hello, world").font(.bundled(.ProtestGuerilla, size: 30.0))