Skip to content

Commit 899059e

Browse files
author
stlc-bot
committed
refactor(fonts): share font link schemas and inferred types
Merge pull request #1838 from context-dot-dev/codex/font-faces-api Stainless-Generated-From: d70f93ced78af2b80a8f9a143adc0613086a1196
1 parent 6f8fb2f commit 899059e

1 file changed

Lines changed: 38 additions & 9 deletions

File tree

‎src/context/dev/types/web_extract_styleguide_response.py‎

Lines changed: 38 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
"StyleguideComponentsCard",
2222
"StyleguideElementSpacing",
2323
"StyleguideFontLinks",
24+
"StyleguideFontLinksFace",
2425
"StyleguideShadows",
2526
"StyleguideTypography",
2627
"StyleguideTypographyHeadings",
@@ -270,13 +271,31 @@ class StyleguideElementSpacing(BaseModel):
270271
xs: str
271272

272273

273-
class StyleguideFontLinks(BaseModel):
274-
files: Dict[str, str]
275-
"""Upright font files keyed by weight string (e.g.
274+
class StyleguideFontLinksFace(BaseModel):
275+
style: str
276+
"""
277+
CSS font-style descriptor: normal, italic, or oblique, including an optional
278+
oblique angle or angle range (e.g. oblique 10deg 20deg).
279+
"""
280+
281+
url: str
282+
"""Preferred font file URL or inline font data URL."""
276283

277-
"400" for regular, "500", "700"). Values are absolute URLs.
284+
weight: str
285+
"""CSS font-weight descriptor.
286+
287+
A variable font file can have a range such as "300 500", covering intermediate
288+
weights without separate files.
278289
"""
279290

291+
unicode_range: Optional[str] = FieldInfo(alias="unicodeRange", default=None)
292+
"""CSS unicode-range descriptor."""
293+
294+
width: Optional[str] = None
295+
"""CSS font-width or font-stretch descriptor."""
296+
297+
298+
class StyleguideFontLinks(BaseModel):
280299
type: Literal["google", "custom"]
281300

282301
category: Optional[str] = None
@@ -287,10 +306,20 @@ class StyleguideFontLinks(BaseModel):
287306
"""
288307

289308
display_name: Optional[str] = FieldInfo(alias="displayName", default=None)
309+
"""Human-readable family name.
310+
311+
For custom fonts, derived from the fontLinks key; for Google fonts, the
312+
canonical Google Fonts family name.
290313
"""
291-
Present when type is custom: human-readable name derived from the fontLinks key
292-
(strip build/hash suffixes, split camelCase / PascalCase, normalize separators).
293-
Google entries omit this.
314+
315+
faces: Optional[List[StyleguideFontLinksFace]] = None
316+
"""Discovered font faces, including style, weight, and distinct Unicode subsets."""
317+
318+
files: Optional[Dict[str, str]] = None
319+
"""Deprecated upright font lookup keyed by weight string.
320+
321+
A variable font can map several standard weight keys to the same URL; faces
322+
retains its actual weight range.
294323
"""
295324

296325

@@ -424,8 +453,8 @@ class Styleguide(BaseModel):
424453
font_links: Dict[str, StyleguideFontLinks] = FieldInfo(alias="fontLinks")
425454
"""
426455
Font assets keyed by family name as it appears in fontFamily/fontFallbacks
427-
(non-generic names only). Clients match typography.fontFamily / fontWeight or
428-
button styles to pick a file URL from files.
456+
(non-generic names only). Match font style and weight against faces to select a
457+
file URL.
429458
"""
430459

431460
mode: Literal["light", "dark"]

0 commit comments

Comments
 (0)