Coder Social home page Coder Social logo

uifontcomplete's Introduction

UIFontComplete

Build Status Swift 5.0 platforms CodeCov CocoaPods compatible Carthage compatible Swift Package Manager compatible License

Font management (System & Custom) for iOS and tvOS

Usage

No more wasted time searching for names of UIFont fonts and no more surprises at runtime if a font name was mistyped. This library is simply one extension to UIFont and one Font enum with a case for each system font on iOS and tvOS. Custom font support is also available, please keep reading for details!

Instead of using the String based constructor native to UIFont:

let font = UIFont(name: "Arial-BoldItalicMT", size: 12.0)

You can now simply start typing the name of the font enum and let code completion help you:

This library currently provides two different options for creating UIFont objects. The first is calling the font name off of the provided BuiltInFont enumeration and then calling of(size:) to provide the desired size.

let myFont: UIFont? = BuiltInFont.helvetica.of(size: 12.0)

The other UIFont creation method offered by this library is similar to the normal UIFont constructor except that instead of providing a String of the desired font, a case of the Font enum is provided instead.

let font = UIFont(font: .arialBoldItalicMT, size: 12.0)

What about Custom Fonts?

Custom Fonts can be added with the help of the FontRepresentable protocol. Simply create your own CustomFont String based enumeration that adapts the FontRepresentable and add a case per font that you want to add like so:

// In your project using custom fonts

enum CustomFont: String, FontRepresentable {
    case alexBrushRegular = "AlexBrush-Regular"
}

CustomFont.alexBrushRegular.of(size: 12.0) // => UIFont

SwiftUI support

SwiftUI Font is handled in a same way as UIKit UIFont.

You can do both:

let myFont: Font = BuiltInFont.helvetica.of(size: 12.0)
let font = Font(font: .arialBoldItalicMT, size: 12.0)

Installation

Carthage

If you use Carthage to manage your dependencies, simply add UIFontComplete to your Cartfile:

github "Nirma/UIFontComplete"

If you use Carthage to build your dependencies, make sure you have added UIFontComplete.framework to the "Linked Frameworks and Libraries" section of your target, and have included UIFontComplete.framework in your Carthage framework copying build phase.

CocoaPods

If you use CocoaPods to manage your dependencies, simply add UIFontComplete to your Podfile:

pod 'UIFontComplete'

Requirements

  • Xcode 9.0
  • Swift 4.0+

Contributing to UIFontComplete

Pull Requests are Welcome! If you feel that this library could be made better then please do so by sending over a pull request!

License

UIFontComplete is free software, and may be redistributed under the terms specified in the LICENSE file.

uifontcomplete's People

Contributors

jrtibbetts avatar matsune avatar nirma avatar nuudles avatar romanpodymov avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.