You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit fee470e
Browse filesBrowse the repository at this point in the historyBrowse files
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: 4d6664b20d53e6f896d040ba1adb1d40adf0652e
Copy file name to clipboardExpand all lines: src/Web/WebExtractStyleguideResponse/Styleguide.php
+2-2Lines changed: 2 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -59,7 +59,7 @@ final class Styleguide implements BaseModel
59
59
publicElementSpacing$elementSpacing;
60
60
61
61
/**
62
-
* Font assets keyed by family name as it appears in fontFamily/fontFallbacks (non-generic names only). Clients match typography.fontFamily / fontWeight or button styles to pick a file URL from files.
62
+
* Font assets keyed by family name as it appears in fontFamily/fontFallbacks (non-generic names only). Match font style and weight against faces to select a file URL.
63
63
*
64
64
* @var array<string,FontLink> $fontLinks
65
65
*/
@@ -196,7 +196,7 @@ public function withElementSpacing(
196
196
}
197
197
198
198
/**
199
-
* Font assets keyed by family name as it appears in fontFamily/fontFallbacks (non-generic names only). Clients match typography.fontFamily / fontWeight or button styles to pick a file URL from files.
199
+
* Font assets keyed by family name as it appears in fontFamily/fontFallbacks (non-generic names only). Match font style and weight against faces to select a file URL.
* @phpstan-import-type FaceShape from \ContextDev\Web\WebExtractStyleguideResponse\Styleguide\FontLink\Face
16
+
*
14
17
* @phpstan-type FontLinkShape = array{
15
-
* files: array<string,string>,
16
18
* type: Type|value-of<Type>,
17
19
* category?: string|null,
18
20
* displayName?: string|null,
21
+
* faces?: list<Face|FaceShape>|null,
22
+
* files?: array<string,string>|null,
19
23
* }
20
24
*/
21
25
finalclass FontLink implements BaseModel
22
26
{
23
27
/** @use SdkModel<FontLinkShape> */
24
28
use SdkModel;
25
29
26
-
/**
27
-
* Upright font files keyed by weight string (e.g. "400" for regular, "500", "700"). Values are absolute URLs.
28
-
*
29
-
* @var array<string,string> $files
30
-
*/
31
-
#[Required(map: 'string')]
32
-
publicarray$files;
33
-
34
30
/** @var value-of<Type> $type */
35
31
#[Required(enum: Type::class)]
36
32
publicstring$type;
@@ -42,23 +38,41 @@ final class FontLink implements BaseModel
42
38
public ?string$category;
43
39
44
40
/**
45
-
* Present when type is custom: human-readable name derived from the fontLinks key (strip build/hash suffixes, split camelCase / PascalCase, normalize separators). Google entries omit this.
41
+
* Human-readable family name. For custom fonts, derived from the fontLinks key; for Google fonts, the canonical Google Fonts family name.
46
42
*/
47
43
#[Optional]
48
44
public ?string$displayName;
49
45
46
+
/**
47
+
* Discovered font faces, including style, weight, and distinct Unicode subsets.
48
+
*
49
+
* @var list<Face>|null $faces
50
+
*/
51
+
#[Optional(list: Face::class)]
52
+
public ?array$faces;
53
+
54
+
/**
55
+
* @deprecated
56
+
*
57
+
* Deprecated upright font lookup keyed by weight string. A variable font can map several standard weight keys to the same URL; faces retains its actual weight range.
58
+
*
59
+
* @var array<string,string>|null $files
60
+
*/
61
+
#[Optional(map: 'string')]
62
+
public ?array$files;
63
+
50
64
/**
51
65
* `new FontLink()` is missing required properties by the API.
52
66
*
53
67
* To enforce required parameters use
54
68
* ```
55
-
* FontLink::with(files: ..., type: ...)
69
+
* FontLink::with(type: ...)
56
70
* ```
57
71
*
58
72
* Otherwise ensure the following setters are called
59
73
*
60
74
* ```
61
-
* (new FontLink)->withFiles(...)->withType(...)
75
+
* (new FontLink)->withType(...)
62
76
* ```
63
77
*/
64
78
publicfunction__construct()
@@ -71,35 +85,25 @@ public function __construct()
71
85
*
72
86
* You must use named parameters to construct any parameters with a default value.
* Upright font files keyed by weight string (e.g. "400" for regular, "500", "700"). Values are absolute URLs.
96
-
*
97
-
* @param array<string,string> $files
98
-
*/
99
-
publicfunctionwithFiles(array$files): self
100
-
{
101
-
$self = clone$this;
102
-
$self['files'] = $files;
105
+
null !== $faces && $self['faces'] = $faces;
106
+
null !== $files && $self['files'] = $files;
103
107
104
108
return$self;
105
109
}
@@ -127,7 +131,7 @@ public function withCategory(string $category): self
127
131
}
128
132
129
133
/**
130
-
* Present when type is custom: human-readable name derived from the fontLinks key (strip build/hash suffixes, split camelCase / PascalCase, normalize separators). Google entries omit this.
134
+
* Human-readable family name. For custom fonts, derived from the fontLinks key; for Google fonts, the canonical Google Fonts family name.
@@ -136,4 +140,30 @@ public function withDisplayName(string $displayName): self
136
140
137
141
return$self;
138
142
}
143
+
144
+
/**
145
+
* Discovered font faces, including style, weight, and distinct Unicode subsets.
146
+
*
147
+
* @param list<Face|FaceShape> $faces
148
+
*/
149
+
publicfunctionwithFaces(array$faces): self
150
+
{
151
+
$self = clone$this;
152
+
$self['faces'] = $faces;
153
+
154
+
return$self;
155
+
}
156
+
157
+
/**
158
+
* Deprecated upright font lookup keyed by weight string. A variable font can map several standard weight keys to the same URL; faces retains its actual weight range.
0 commit comments