Home / Function/ buildFontOptions() — ui Function Reference

buildFontOptions() — ui Function Reference

Architecture documentation for the buildFontOptions() function in update-fonts.ts from the ui codebase.

Entity Profile

Dependency Diagram

graph TD
  dd2b376b_da61_b89f_188a_4979b45c5421["buildFontOptions()"]
  b169f1bf_76c5_e7c9_f493_15fe0f296591["update-fonts.ts"]
  dd2b376b_da61_b89f_188a_4979b45c5421 -->|defined in| b169f1bf_76c5_e7c9_f493_15fe0f296591
  fb488c27_d35b_ddbe_26c7_6bfb5c38105a["transformLayoutFonts()"]
  fb488c27_d35b_ddbe_26c7_6bfb5c38105a -->|calls| dd2b376b_da61_b89f_188a_4979b45c5421
  style dd2b376b_da61_b89f_188a_4979b45c5421 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/shadcn/src/utils/updaters/update-fonts.ts lines 263–279

function buildFontOptions(font: RegistryFontItem) {
  const options: Record<string, unknown> = {}

  if (font.font.subsets?.length) {
    options.subsets = font.font.subsets
  }

  if (font.font.weight?.length) {
    options.weight = font.font.weight
  }

  options.variable = font.font.variable

  return JSON.stringify(options)
    .replace(/"([^"]+)":/g, "$1:") // Remove quotes from keys.
    .replace(/"/g, "'") // Use single quotes for strings.
}

Subdomains

Frequently Asked Questions

What does buildFontOptions() do?
buildFontOptions() is a function in the ui codebase, defined in packages/shadcn/src/utils/updaters/update-fonts.ts.
Where is buildFontOptions() defined?
buildFontOptions() is defined in packages/shadcn/src/utils/updaters/update-fonts.ts at line 263.
What calls buildFontOptions()?
buildFontOptions() is called by 1 function(s): transformLayoutFonts.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free