Financial-Times / o-typography

Typography and vertical rhythm styles for FT branding
http://registry.origami.ft.com/components/o-typography
10 stars 2 forks source link

Proposal: Discorage use of currently unused font faces / familes #247

Closed notlee closed 4 years ago

notlee commented 4 years ago

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).

// Pagekit?
@include oFonts($opts: (
    'metric': (
            ('weight': 'regular', 'style': 'normal'),
            ('weight': 'semibold', 'style': 'normal')
-           ('weight': 'medium', 'style': 'normal')
+           ('weight': 'medium', 'style': 'normal', 'deprecated': 'is being removed from ft.com, use semibold instead maybe')
    ),
    'financier-display': (
            ('weight': 'regular', 'style': 'normal')
    )
));
i-like-robots commented 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.

notlee commented 4 years ago

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

notlee commented 4 years ago

Actually this isn't going to work out simply:

Let's:

notlee commented 4 years ago

Closing in favour of: https://github.com/Financial-Times/o-fonts/issues/109 https://github.com/Financial-Times/o-typography/issues/249