Closed notlee closed 6 years ago
Why register a custom font with o-fonts
? Component implementations should be able to call oFontsVariantExists
and get a reliable result. Else breaking changes might creep in for whitelabel users without us noticing.
Thanks for the feedback! I'm going to make this real and not a proof of concept. Ignore the branch name 😬
@Financial-Times/origami-core This is ready for review. I'm going to merge this into a base branch which will include branding work, just in case branding gives me reason to change the interface of the new oTypographyFor
mixin.
Features:
Implementation:
oTypography
to output all features with silent mode on.oTypographyDefineFontScale
to register a custom font scale.oTypographyFor
, a more flexible mixin to output typography for any font.oTypographyProgressiveFontFallback
, so font fallbacks may be conditionally included based on typographic attributes (font, style, weight) rather than passing a hardcoded key 'sansBold'.$font
param to oTypographySize
, oTypographyGetScale
, oTypographyMaxLineWidth
, etc. so they may use a the correct scale for the given font.$opts
argument to oTypography
, so that select classes may be output.Based on feedback from @gvonkoss I added a helper mixin oTypographySetCustomFont
for setting a custom font. I've also made oTypographyFor
private, as access to that mixin isn't needed by consumers yet.
👇 This is where we started. See comments for final outcome.
Goals
Progress
Scale per font
$o-typography-font-scale-by-font
stores a map of font names to their scale. The existing variable$o-typography-font-scale
remains to avoid a major. It acts as a default scale.oTypographySize
,oTypographyGetScale
, andoTypographyMaxLineWidth
have a new$font
parameter, so their output can use the correct scale. The default scale is used if$font
is not given making this non-breaking.Fonts outside of sans/serif/display.
oTypography
accepts a$font
argument which could me any custom font registered with o-fonts (@todo add the ability to register new fonts). It also accepts anopts
argument to output one or more of family, scale, weight, style etc.To show how this works existing typography mixins wrap these e.g.
oTypographySerif
,oTypographyDisplay
,oTypographyDisplayBold
:In a future major these mixins may be trimmed down, e.g.
oTypographyDisplayBold
could be removed and replaced with justoTypographyDisplay
and anopts
param:Other
Potential Future Direction
Brain dump: