Skip to main content

loadFontFromInfo()v4.0.279

根据使用 getInfo() 获取的一些元数据加载 Google 字体。

🌐 Loads a Google Font based on some metadata that was obtained using getInfo().

getInfo() 只返回纯 JSON 对象,因此字体的元数据可以从服务器加载,这可以避免客户端打包包过大。

On the server
import {getInfo} from '@remotion/google-fonts/InterTight'; // Return `info` to the client using an endpoint const info = getInfo();
On the client
const info = await loadInfoFromServer(); const {fontFamily, waitUntilDone} = loadFontFromInfo(info, 'italic'); console.log(fontFamily); waitUntilDone();

应用编程接口

🌐 API

该 API 与 loadFont() 相同,只是需要在第一个位置传入另一个参数,即使用 getInfo() 加载的字体元数据。

🌐 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.tsx
import {getInfo} from '@remotion/google-fonts/InterTight'; import {loadFontFromInfo} from '@remotion/google-fonts/from-info'; const {waitUntilDone} = loadFontFromInfo(getInfo(), 'normal', { weights: ['400'], subsets: ['latin'], });

loadFont() 不同,没有自动补齐

🌐 Unlike loadFont(), there is no autocomplete

另请参阅

🌐 See also