codeandtheory / YMatterType

An opinionated take on Design System Typography for iOS and tvOS.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add factory variable to `Typography`

mpospese opened this issue · comments

  • Add a static var to Typography of type FontFamilyFactory
  • name it factory
  • Its initial (default) value should be DefaultFontFamilyFactory()
  • Revise the second init override (the one that takes familyName: String, style: FontStyle) to use the factory to create the font family to pass to the main init (instead of simply instantiating a DefaultFontFamily object)
    (FontInfo will be renamed to DefaultFontFamily in Issue #18)
  • add a test to TypographyTests to test switching out the factory. e.g. create a factory that always returns say Typography.sfProText, set the factory to that, then initialize a typography using same code as in testInit2() but assert that the created typography has fontFamily.familyName equal to "SFProText" and not "AvenirNext" (proving that the factory indeed worked). You would then need to revert Typography.factory back to DefaultFontFamily() in order to not affect any other unit tests (you can do that via addTeardownBlock if desired).