@financial-times/o-fonts

中文文档
5.3.6发布于 2026/02/26MITES Module零依赖近 30 天下载 1.4万

Loads CSS declarations for FT web fonts. Does not include font assets.

原始使用文档
文档目录20 节
  1. Usage
  2. Recommended Fonts
  3. Core Brand Recommended Fonts
  4. Internal Brand Recommended Fonts
  5. Whitelabel Brand Recommended Fonts
  6. Fonts Included By Default
  7. All Available Fonts
  8. Sass
  9. Include Default Fonts
  10. Font Loading
  11. Use a custom font family
  12. Get a font family for a font name
  13. Get a font name from a font family
  14. Check a font of weight or style exists
  15. Check a font of weight or style has been included
  16. Contributing
  17. Add a new font or font variant
  18. Migration Guide
  19. Contact
  20. Licence

⚠️ NOTE: o-fonts has been replaced with o3-foundation. Please see Migration Guide for steps to upgrade.

o-fonts MIT licensed

Use o-fonts to include Origami provided fonts, or register supported custom fonts.

Usage

Check out how to include Origami components in your project to get started with o-fonts.

Origami components use a limited set of recommended font faces which vary per brand. We recommend Sass users include only these recommended fonts and carefully consider performance implications before including another font. However a wider selection of fonts are included by default so they are available to Build Service users. Sass users may choose to include only recommended fonts, or any of the available fonts.

WeightFinancierDisplayWebMetricWeb
thin
light
regular✓
medium✓
semibold✓
bold✓
black
  • ✓: normal style available
  • i: italic style available (if not, faux-italic will be displayed)
WeightMetricWeb
thin
light
regular✓
medium
semibold✓
bold
black
  • ✓: normal style available
  • i: italic style available (if not, faux-italic will be displayed)

(None). Origami components make no font assumptions for whitelabel brands and default to a system font.

Fonts Included By Default

A selection wider than recommended fonts are included by default so they are available to Build Service users. Font faces included by default, if using the Origami Build Service or including default fonts with SASS, depend on your products chosen brand:

BrandFonts included by default (all weights and styles available)
coreFinancierDisplayWeb, MetricWeb
internalMetricWeb
whitelabel(none)

All Available Fonts

Any of the below fonts may be included with o-fonts using SASS, this is useful for brands such as specialist titles who may use additional fonts. Build Service users are limited to fonts included by default.

WeightFinancierDisplayWebFinancierTextWebMetricWeb
thin✓
light✓ i✓ i
regular✓ i✓ i✓ i
medium✓ i✓✓
semibold✓ i✓
bold✓✓✓ i
black✓✓✓
  • ✓: normal style available
  • i: italic style available (if not, faux-italic will be displayed)

Sass

Include Default Fonts

To include all fonts for your brand, call oFonts.

@import '@financial-times/o-fonts/main';
@include oFonts();

To improve site performance, Origami components use a more limited set of font faces. To included only the recommended set of font faces, set recommended: true in the options $opts map.

@import '@financial-times/o-fonts/main';
@include oFonts($opts: ('recommended': true));

You may also include specific fonts granularly using an options $opts map. The map has a key for each font metric, financier-display, or financier-text, which accepts a list of weight and styles to include.

For example to include recommended fonts used by Origami components and an extra font, MetricWeb in a medium weight, and regular FinancierDisplayWeb:

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

Note: If your project has multiple Sass entry points call oFontsVariantsIncluded with the same options as oFonts, to tell o-fonts which font faces have been output.

Font Loading

By default font-display is set to swap. In supporting browsers a system font is shown until fonts are loaded. To update your font loading method set $o-fonts-display at the top of your Sass, before including any other component.

// Customise font loading.
$o-fonts-display: 'optional';
@import '@financial-times/o-fonts/main';


@include oFonts();

Use a custom font family

To register a custom font and supported variants, use the mixin oFontsDefineCustomFont.

In this example we register a custom font "MyFont" with sans fallback MyFont, sans. We configure this font to allow two variants (a normal style of either bold or regular weight). In the mixin content we include the @font-face declaration to load these fonts from our own source.

@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;
    }
}

Get a font family for a font name

To get a font-family with web safe fallbacks for a font, use the oFontsGetFontFamilyWithFallbacks function.

$family: oFontsGetFontFamilyWithFallbacks(FinancierDisplayWeb); // FinancierDisplayWeb, sans-serif

Get a font name from a font family

To get a font without fallbacks, use oFontsGetFontFamilyWithoutFallbacks:

$font: oFontsGetFontFamilyWithoutFallbacks('FinancierDisplayWeb, sans-serif'); // FinancierDisplayWeb

Check a font of weight or style exists

To check if a font supports a weight/style use oFontsVariantExists.

$allowed: oFontsVariantExists('MetricWeb', 'bold', 'normal'); // true
$allowed: oFontsVariantExists('MetricWeb', 'black', 'italic'); // false

Check a font of weight or style has been included

To check if a font weight/style has been output in your project use oFontsVariantIncluded.

// including fonts in project
@include oFonts($opts: (
    'metric': (
        ('weight': 'medium', 'style': 'normal')
    ),
));


$included: oFontsVariantIncluded('MetricWeb', 'medium', 'normal'); // true
$included: oFontsVariantIncluded('MetricWeb', 'bold', 'normal'); // false

Note: If your project has multiple Sass entry points call oFontsVariantsIncluded with the same options as oFonts, to tell o-fonts which font faces have been output.

Contributing

Add a new font or font variant

Note: font files are contained in a separate, private repository (o-fonts-assets).

  1. Open src/scss/_variables.scss and update the $o-fonts-build-service-path variable to the release of o-fonts-assets which includes your new font.

  2. Add the font family name (if it's an entirely new family) and the variant styles to the private $_o-fonts-families map.

  3. If adding an entirely new font, add a new option to the oFonts mixin. To include the new font by default or with recommended fonts (see $_o-fonts-default and $_o-fonts-recommended).

  4. Finally, update the demos (see origami.json).

Migration Guide

StateMajor VersionLast Minor ReleaseMigration guide
✨ activeo3N/Amigrate to o3
⚠ maintained5N/Amigrate to v5
╳ deprecated44.5migrate to v4
╳ deprecated33.3migrate to v3
╳ deprecated22.3-
╳ deprecated11.5-

Contact

If you have any questions or comments about this component, or need help using it, please either raise an issue, visit #origami-support or email Origami Support.


Licence

This software is published by the Financial Times under the MIT licence.

版本与发布记录

@financial-times/o-fonts 共发布 39 个版本,首次发布于 2019/02/13;过去 12 个月发布了 1 个版本。

版本发布日期距今
5.3.6latest2026/02/268 个月前
5.3.52023/10/273 年前
5.3.42022/06/174 年前
5.3.32022/04/084 年前
5.3.22022/04/084 年前
5.3.12022/04/074 年前

其他发布通道:prerelease → 5.0.0-beta.1。

关于 @financial-times/o-fonts 的常见问题

@financial-times/o-fonts 是什么?

Loads CSS declarations for FT web fonts. Does not include font assets.

如何安装 @financial-times/o-fonts?

在项目目录运行 npm install @financial-times/o-fonts,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:@financial-times/o-brand(^4.1.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@financial-times/o-fonts 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/financial-times__o-fonts 是否存在。

@financial-times/o-fonts 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@financial-times/o-fonts 可以商用吗?

@financial-times/o-fonts 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@financial-times/o-fonts 的下载量有多少?

根据 npm 官方下载统计,@financial-times/o-fonts 在 2026/10/15 – 2026/11/13 这 30 天内被下载 14,073 次,日均约 469 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@financial-times/o-fonts 还在维护吗?

最新版本 5.3.6 发布于 2026/02/26(8 个月前);至今共发布 39 个版本,其中过去 12 个月发布了 1 个;首次发布于 2019/02/13。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。