Skip to main content

字体加载错误

加载 Google 字体时渲染超时

🌐 Render timeout when loading Google Fonts

使用 @remotion/google-fonts 时,你可能会遇到如下超时错误:

🌐 When using @remotion/google-fonts, you may encounter timeout errors like:

- A delayRender() "Fetching Inter font {"style":"normal","weight":"100","subset":"cyrillic-ext"}" was called but not cleared after 58000ms.

问题

🌐 Problem

默认情况下,loadFont() 会尝试加载所有可用的字体粗细和字符子集,这可能会导致超时。

🌐 By default, loadFont() attempts to load all available font weights and character subsets, which can cause timeouts.

解决方案

🌐 Solution

只加载你的项目所需的特定字体粗细和字符子集:

🌐 Only load the specific font weights and character subsets that your project needs:

import {loadFont} from '@remotion/google-fonts/Inter';

// ❌ Avoid: Loading all weights and subsets
loadFont();

// ✅ Recommended: Load only required weights and subsets
loadFont('normal', {
  subsets: ['latin'],
  weights: ['400', '700'], // Only load regular (400) and bold (700)
});