Add factory variable to `Typography`
mpospese opened this issue · comments
Mark Pospesel commented
- Add a
static
var toTypography
of typeFontFamilyFactory
- name it
factory
- Its initial (default) value should be
DefaultFontFamilyFactory()
- Revise the second
init
override (the one that takesfamilyName: String, style: FontStyle
) to use thefactory
to create the font family to pass to the maininit
(instead of simply instantiating aDefaultFontFamily
object)
(FontInfo
will be renamed toDefaultFontFamily
in Issue #18) - add a test to
TypographyTests
to test switching out the factory. e.g. create a factory that always returns sayTypography.sfProText
, set the factory to that, then initialize a typography using same code as intestInit2()
but assert that the created typography hasfontFamily.familyName
equal to "SFProText" and not "AvenirNext" (proving that the factory indeed worked). You would then need to revertTypography.factory
back toDefaultFontFamily()
in order to not affect any other unit tests (you can do that viaaddTeardownBlock
if desired).