Fonts
Register a font from Google Fonts, a file in public/, a stylesheet or CSS @font-face, and use it in text.
Text uses only the fonts you register. Kinetograph reads no system fonts, so a render looks the same on every machine.
import { Text } from '@kinetographdev/core';
import { loadFont } from '@remotion/google-fonts/Inter';
const { fontFamily } = loadFont('normal', { weights: ['400', '700'] });
export const Title = () => (
<Text font={fontFamily} weight={700} size={96} color="#ffffff">
Hello
</Text>
);
Call loadFont at the top of the file, outside any component.
Google Fonts
Import the family you want from @remotion/google-fonts/<Family>. The first render downloads each file and keeps it in ~/.cache/kinetograph/fonts, so later renders need no network.
A font file in your project
Put the file in public/fonts/ and register it under a family name:
import { loadFont } from '@remotion/fonts';
import { staticFile } from '@kinetographdev/core';
loadFont({ family: 'Brand', url: staticFile('fonts/Brand-Bold.ttf'), weight: '700' });
loadFont({ family: 'Brand', url: staticFile('fonts/Brand-Italic.ttf'), style: 'italic' });Then write <Text font="Brand" weight={700}>. The file can be TrueType, OpenType, WOFF or WOFF2.
A stylesheet or CSS
For fonts hosted elsewhere, makeWebFont from @kinetographdev/core/fonts takes the URL of a stylesheet of @font-face rules. In HTML or an imported stylesheet, @font-face works as in a browser, with the url() looked for beside the entry file, then in public/.
HTML pages and JSON scenes
- An HTML page names a family in CSS. The families HyperFrames embeds are built in, and any other font comes from
@font-facewith a file. - In a
.jsonscene, thefontsobject maps a family name to a file. See the scene format.
Rules
- Register before measuring. Text is never measured before its fonts are registered.
- No system fonts. With no font loaded, text is drawn in the bundled DM Sans, and
lintreports aTextwhose font is not registered. - Missing characters. CJK, Arabic, Devanagari and similar scripts have no bundled font, so load one that has them. Emoji are monochrome.
What works
- Drawn natively: Google Fonts, font files,
@font-face,FontFace, variable fonts and-webkit-text-stroke,text-shadowandbackground-clip: text. - Approximated:
monospaceandexcan differ from Chrome, and a variable font set per element withfont-variation-settingscan measure wider. Emoji are monochrome. - Not supported: system fonts, and
getAvailableFonts()from@remotion/google-fonts. doctorlists a character no font has, and a font that did not download (understylesheets). Runnpx kinetograph doctor <entry>before a long render, and see What works.