Swiftpack.co - BenShutt/FontManager as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by BenShutt.
BenShutt/FontManager 1.0.0
Simplify font management in iOS apps
⭐️ 0
🕓 3 weeks ago
iOS macOS watchOS tvOS
.package(url: "https://github.com/BenShutt/FontManager.git", from: "1.0.0")

FontManager

Archived

Though the executable may still be useful for generating Info.plist key-value pairs, there are better ways now to handle fonts in SwiftUI. This framework is very light-weight so can be easily replaced.

Framework

Easily manage a consistent global font in an iOS app, mapping UIFont.TextStyles to custom UIFonts.

Example

// Define a global (custom) font
Font.fontManager = FontManager(fontName: "OpenSans")

// Get the font for a given text style  
label.font = Font.font(for: .body)

// Get the font for a given size and weight  
label.font = Font.font(ofSize: 21, weight: .bold)

Installation

For preferred font for text styles to work a {fontName}.plist file is required to be added to the main Bundle. This maps UIFont.TextStyles to PreferredFonts and thus a UIFont. To automatically generate this plist file see App

App

A companion command line program for the FontManager framework. Generates propertyList (plist) files for FontManager to reference.

The plist files which are generated include:

  • font-info.plist which maps a single UIAppFonts key to an array of fonts. Allowing you to quickly add fonts to an app Info.plist
  • {fontName}.plist mapping UIFont.TextStyles to their PreferredFonts, to drive the FontManager

How to run

From the command line: navigate to the font directory you would like to create plist files for, and simply execute:

bash -l -c "$(curl -sfL https://raw.githubusercontent.com/BenCShutt/FontManager/master/FontManagerApp/fontManagerApp.sh)"

The plist files will be written to the directory where the script is executed.

Acknowledgements

Use Your Loaf tutorial

GitHub

link
Stars: 0
Last commit: 3 weeks ago
jonrohan Something's broken? Yell at me @ptrpavlik. Praise and feedback (and money) is also welcome.

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics