Origami Frontend Components & Services

SassDoc: o-fonts

oFonts(opts)

Output all default font-face declarations for the current brand.

parameter type default description
opts the font faces to include, see the README or examples for more details.

Examples

Example #1

all fonts for the current brand (core, internal, whitelabel).

@include oFonts();

Example #2

a limited set of recommended fonts for the current brand (core, internal, whitelabel).

@include oFonts($opts: ('recommended': true));

Example #3

a limited set of recommended fonts for the current brand, plus an extra FinancierDisplayWeb font.

@include oFonts($opts: (
	'recommended': true,
	'financier-display': (
		(weight: regular, style: normal)
	)
));

Example #4

only regular and semibold MetricWeb font faces.

@include oFonts($opts: ('metric': (
	(weight: regular, style: normal),
	(weight: semibold, style: normal),
)));

Example #5

only regular and bold FinancierDisplayWeb font faces.

@include oFonts($opts: ('financier-display': (
	(weight: regular, style: normal),
	(weight: semibold, style: normal),
)));

Example #6

only regular font faces for MetricWeb and FinancierDisplayWeb.

@include oFonts($opts: (
	'metric': ((weight: regular, style: normal)),
	'financier-display': ((weight: regular, style: normal))
));

Example #7

only black weighted font faces for MetricWeb, FinancierDisplayWeb, and FinancierTextWeb.

@include oFonts($opts: (
	'metric': ((weight: 'black', style: normal)),
	'financier-display': ((weight: 'black', style: normal)),
	'financier-text': ((weight: 'black', style: normal))
));

Links

oFontsVariantExists(...)

Check if a font variant exists for a family.

parameter type default description
family one of $_o-fonts-families
weight (optional) regular The font weight.
style (optional) normal The font style.

Returns

Bool

Links

oFontsVariantIncluded(...)

Check if a font variant has been included in your project with the oFonts mixin.

parameter type default description
family one of $_o-fonts-families
weight (optional) regular The font weight.
style (optional) normal The font style.

Returns

Bool

Links

oFontsGetFontFamilyWithFallbacks(family)

Get a font-family stack with the appropriate fallbacks

parameter type default description
family

Returns

String - font-stack

Example

font-family: oFontsGetFontFamilyWithFallbacks(FinancierDisplayWeb);

Links

oFontsGetFontFamilyWithoutFallbacks(family)

Removes a fonts fallbacks.

parameter type default description
family Font family potentially with fallbacks.

Returns

String - Font family without fallbacks.

Example

$family: oFontsGetFontFamilyWithoutFallbacks('FinancierDisplayWeb, sans'); //FinancierDisplayWeb

Links

oFontsWeight(keyword)

Machine-readable CSS font-weight.

parameter type default description
keyword Human-readable keyword e.g. 'semibold', 'regular', 'bold'.

Returns

Number - CSS font-weight

Example

font-weight: oFontsWeight(lighter);

Links

oFontsDefineCustomFont(font-family, variants)

Output custom Font-face declarations and register the family and variants with o-fonts.

parameter type default description
font-family The custom font family with fallback e.g. 'ComicSans, sans'
variants The variants (weight and style combinations) which are allowed in a nested map e.g. ((weight: bold, style: normal), (weight: regular, style: normal))

Content Block

If the font family is not a system font, output the font-face for the custom font in the mixin content.

Example

example shows registering a custom font "MyFont" with "sans" fallback. The font allows regular or bold variants.

@include oFontsDefineCustomFont('MyFont, sans', (
	(weight: regular, style: normal),
	(weight: bold, style: normal)
)) {
	@font-face {
		src: url('MyFont-Thin.woff2') format('woff2'), url('MyFont-Thin.woff') format('woff');
		font-family: MyFont;
		font-weight: 100;
		font-style: normal;
	}

	@font-face{
		src: url('MyFont-Bold.woff2') format('woff2'), url('MyFont-Bold.woff') format('woff');
		font-family: MyFont;
		font-weight: 700;
		font-style: normal;
	}
};

Links

oFontsVariantsIncluded(opts)

Register which fonts have been output by already for your project. This mixin is useful if a project calls the oFonts mixin is in a different entry point.

parameter type default description
opts the font faces to included, see the README or examples for more details.

Examples

Example #1

all fonts for the current brand (core, internal, whitelabel).

@include oFontsVariantsIncluded();

Example #2

a limited set of recommended fonts for the current brand (core, internal, whitelabel).

@include oFontsVariantsIncluded($opts: ('recommended': true));

Example #3

a limited set of recommended fonts for the current brand, plus an extra FinancierDisplayWeb font.

@include oFontsVariantsIncluded($opts: (
	'recommended': true,
	'financier-display': (
		(weight: regular, style: normal)
	)
));

Example #4

only regular and semibold MetricWeb font faces.

@include oFontsVariantsIncluded($opts: ('metric': (
	(weight: regular, style: normal),
	(weight: semibold, style: normal),
)));

Example #5

only regular and bold FinancierDisplayWeb font faces.

@include oFontsVariantsIncluded($opts: ('financier-display': (
	(weight: regular, style: normal),
	(weight: semibold, style: normal),
)));

Example #6

only regular font faces for MetricWeb and FinancierDisplayWeb.

@include oFontsVariantsIncluded($opts: (
	'metric': ((weight: regular, style: normal)),
	'financier-display': ((weight: regular, style: normal))
));

Links

o-fonts-is-silent

Silent mode

Links

The variable "o-fonts-path" is deprecated. - Use "$o-fonts-build-service-path" or "$o-fonts-self-host-path" instead.

o-fonts-path

Origami Build Service path to font files.

Links

o-fonts-build-service-path

Origami Build Service path to font files.

Links

o-fonts-self-host-path

Alternative path to self hosted font files, hosted on a service which does not conform to the Origami Build Service api. For example this is used by Financial-Times/ft-app to support offline fonts.

Links

o-fonts-display

The default font-display property of included font faces. https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/font-display

Links

oFonts(opts)

Output all default font-face declarations for the current brand.

parameter type default description
opts the font faces to include, see the README or examples for more details.

Examples

Example #1

all fonts for the current brand (core, internal, whitelabel).

@include oFonts();

Example #2

a limited set of recommended fonts for the current brand (core, internal, whitelabel).

@include oFonts($opts: ('recommended': true));

Example #3

a limited set of recommended fonts for the current brand, plus an extra FinancierDisplayWeb font.

@include oFonts($opts: (
	'recommended': true,
	'financier-display': (
		(weight: regular, style: normal)
	)
));

Example #4

only regular and semibold MetricWeb font faces.

@include oFonts($opts: ('metric': (
	(weight: regular, style: normal),
	(weight: semibold, style: normal),
)));

Example #5

only regular and bold FinancierDisplayWeb font faces.

@include oFonts($opts: ('financier-display': (
	(weight: regular, style: normal),
	(weight: semibold, style: normal),
)));

Example #6

only regular font faces for MetricWeb and FinancierDisplayWeb.

@include oFonts($opts: (
	'metric': ((weight: regular, style: normal)),
	'financier-display': ((weight: regular, style: normal))
));

Example #7

only black weighted font faces for MetricWeb, FinancierDisplayWeb, and FinancierTextWeb.

@include oFonts($opts: (
	'metric': ((weight: 'black', style: normal)),
	'financier-display': ((weight: 'black', style: normal)),
	'financier-text': ((weight: 'black', style: normal))
));

Links

Status
active
Switch component view

GitHub: o-fonts@5.3.4

Install o-fonts

If using the Build Service, add o-fonts@^5.3.4 to your link tag.

If using the npm package manager for a Manual Build, run npm install --save-peer "@financial-times/o-fonts@^5.3.4".

Help & Support

o-fonts is maintained directly by the Origami team. If you have any questions about o-fonts or Origami in general, we are happy to help. 😊

Slack: #origami-support
Email: origami.support@ft.com

Feedback / Issues

To report a bug or request features please create an issue on Github. For support or general feedback please get in touch 😊

Slack: #origami-support
Email: origami.support@ft.com