loadFontFromInfo()v4.0.279
Loads a Google Font based on some metadata that was obtained using getInfo()
.
getInfo()
returns just a pure JSON object, so the metadata of a font may be loaded from a server, which can avoid having a heavy client-side bundle.
On the servertsx
import {getInfo } from '@remotion/google-fonts/InterTight';// Return `info` to the client using an endpointconstinfo =getInfo ();
On the clienttsx
constinfo = awaitloadInfoFromServer ();const {fontFamily ,waitUntilDone } =loadFontFromInfo (info , 'italic');console .log (fontFamily );waitUntilDone ();
API
The API is the same as loadFont()
, except that another argument needs to be passed in first position, that being font metadata loaded using getInfo()
.
MyComp.tsxtsx
import {getInfo } from '@remotion/google-fonts/InterTight';import {loadFontFromInfo } from '@remotion/google-fonts/from-info';const {waitUntilDone } =loadFontFromInfo (getInfo (), 'normal', {weights : ['400'],subsets : ['latin'],});
Unlike loadFont()
, there is no autocomplete