Closed notlee closed 4 years ago
Throw an error when a font face is used by o-typography which exists in o-fonts but has not been output by o-fonts
+1
for cases where the fonts faces are included in a different Sass entry point
Yes that's correct, we have two Sass entrypoints - global shared stuff (which includes fonts, normalise, grid, header, footer, layout) and an app specific one.
Add a deprecated parameter to the oFonts mixin
That's a good idea, although I doubt the efficacy or Sass warnings.
Yes that's correct, we have two Sass entrypoints - global shared stuff (which includes fonts, normalise, grid, header, footer, layout) and an app specific one.
Ah that's a bit annoying. We'd have to tell o-fonts in the second entry point what fonts have been included in the first, something like this:
@include oFontsAllowedFonts($allowed-fonts: (
'metric': (
('weight': 'regular', 'style': 'normal'),
('weight': 'semibold', 'style': 'normal')
('weight': 'medium', 'style': 'normal', 'deprecated': 'is being removed from ft.com, use semibold instead maybe')
),
'financier-display': (
('weight': 'regular', 'style': 'normal')
)
));
If the map is the same as for the oFonts
mixin at least a variable can be shared between the two entry points
Actually this isn't going to work out simply:
Let's:
oFontsVariantsIncluded
oFontsVariantIncluded
to check which fonts have been included (to go along with the existing oFontsVariantExists
function, which checks if the font is available in o-fonts at all)$o-typography-error-on-missing-font: false
that defaults to false, so this isn't breaking and doesn't break component builds. If a project sets $o-typography-error-on-missing-font: true
, it will use oFontsVariantIncluded
and error if the font being used has not been included
Problem
If a typography mixin such as
oTypographySans
is used to output a family/weight/style combination which does not have a font face in o-fonts an error is thrown.However there is no notice when a font face exists in o-fonts but hasn't been included in the project. Neither is there a way to "deprecate" the use of a font face within a project, which may have been included previously.
This is a problem because it would be expensive to load all our font families on ft.com, and when one has been included but rarely used it's difficult to remove. For example one font that has slipped into use on ft.com is MetricWeb medium (500). It is very rarely used and doesn't justify downloading another custom font.
Proposal
1. Throw an error when a font face is used by o-typography which exists in o-fonts but has not been output by o-fonts.
2. Add a
deprecated
parameter to the oFonts mixin, so projects may deprecate and eventually remove the use of a font face (which may continue to exist in o-fonts for other projects in the brand).