Giter Site home page Giter Site logo

rootstrap / rsfontsizes Goto Github PK

View Code? Open in Web Editor NEW
26.0 9.0 9.0 1.24 MB

RSFontSizes pod repository. Allows you to customize fonts and sizes in different screen sizes.

Home Page: https://rootstrap.com/

License: MIT License

Swift 92.86% Ruby 7.14%
swift fonts utility pod cocoapod font-size helper screen-size font library

rsfontsizes's Introduction

RSFontSizes

CI Status Carthage compatible Version License Platform

What is it?

RSFontSize allows you to manage different font sizes for every device screen size in a flexible manner.

  • No more family name and styles typing/guessing every time you use a font.
  • Flexible size configurations(Fixed, Proportional to screen size and user specific).
  • Smart size estimation for vague specifications.
  • Save your font configurations for different UIFontTextStyle(.body, .headline, etc).

Installation

Swift Package Manager

https://github.com/rootstrap/RSFontSizes
  • In XCode 11, go to File -> Swift Packages -> Add Package Dependency.
  • Enter the repo URL (https://github.com/rootstrap/RSFontSizes) and click Next.
  • Select the version rule desired (you can specify a version number, branch, or commit) and click Next.
  • Finally, select the target where you want to use the framework.

Note: It is always recommended to lock your external libraries to a specific version.

Cocoapods

RSFontSizes is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod "RSFontSizes"

Carthage

  1. Add the following sources to your Cartfile:
github "rootstrap/RSFontSizes" ~> 1.3.3
  1. Run the carthage update command in the terminal.

  2. Link the resulting RSFontSizes.framework and Device.framework to your project.

Quick peek

From poorly managed font sizes:

Normal Preview

Fonts are set directly from IB.

To readable texts:

Preview With RSFontSizes

Fonts using RSFontSizes.

Start using RSFontSizes

Just link your font assets to the project. Very detailed guide here.

If there are too many font files to add, FontBlaster pod is strongly recommended. It's a simple solution to load your assets automatically instead of manually adding every file to the Info.plist.

Optionally add shortcuts to your favourite fonts.

extension Font {
  //Your Custom font family names
  static let raleway = "Raleway".font()!
}

Perks

There are different types to get your fonts correctly sized:

-Fixed: The consumer sets the font point size or uses one of the provided classes(.small, .medium, etc).

let font = Font.raleway.small

No magic here :)

-Proportional: The consumer will specify a base font size asociated with a device screen size.

let font = Font.raleway.proportional(to: (.screen3_5Inch, 10))

The result will be a font resized accordingly for the current device screen size.

-Screen Specific: The consumer defines a set of font sizes linked to an specific screen size.

let font = Font.raleway.specific(values: [.screen4Inch: 12, 
                                          .screen4_7Inch: 13.5,
                                          .screen5_5Inch: 16,
                                          .screen9_7Inch: 20.2]))

If a screen size is not specified the library will try to estimate the correct value for the font size.

You can also...

Use a String as the Font family name

let font = "Raleway".font(withWeight: .bold,
                          size: .fixed(20))

Save your 'templates' to reuse

Font.save(font: someFont, forClass: .body)

And then use it elsewhere:

let label.font = Font.with(class: .body)

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

Credits

RSFontSizes is maintained by Rootstrap and German López with the help of our contributors.

License

RSFontSizes is available under the MIT license. See the LICENSE file for more info.

rsfontsizes's People

Contributors

camilamoscatelli avatar danialepaco avatar glm4 avatar kvacquier avatar toptierlabs avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

rsfontsizes's Issues

Update test suite

QUick and Nimble dependencies need to be updated
Test target is unlinked from the host app

Add support for iPhone 12

Fonts are looking way too big on these devices.

Also adding min and max for the proportional fonts maybe a good addition to the API.

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.