Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

skip CLI should have a skip font command #348

Open
dfabulich opened this issue Feb 19, 2025 · 0 comments
Open

skip CLI should have a skip font command #348

dfabulich opened this issue Feb 19, 2025 · 0 comments

Comments

@dfabulich
Copy link

dfabulich commented Feb 19, 2025

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/Resources with 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))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant