-
Notifications
You must be signed in to change notification settings - Fork 680
/
Overview.bs
9260 lines (7804 loc) · 383 KB
/
Overview.bs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<pre class='metadata'>
Title: CSS Fonts Module Level 4
Shortname: css-fonts
Level: 4
Status: ED
Prepare for TR: no
Work Status: Revising
Group: CSSWG
ED: https://drafts.csswg.org/css-fonts-4/
TR: https://www.w3.org/TR/css-fonts-4/
Previous Version: https://www.w3.org/TR/2024/WD-css-fonts-4-20240201/
Former Editor: John Daggett, Invited Expert, https://twitter.com/nattokirai, w3cid 41498
Former Editor: Myles C. Maxfield, Formerly of Apple Inc., mmaxfield@apple.com, w3cid 77180
Editor: Chris Lilley, W3C, http://svgees.us, w3cid 1438
Abstract: This specification defines modifications to the existing <a href="https://drafts.csswg.org/css-fonts-3/">CSS Fonts 3</a> specification along with additional features.
At Risk: Synthesis of the 'font-variant-position' property
At Risk: The 'font-language-override!!property' property
At Risk: The 'font-language-override!!descriptor' descriptor
Ignored Terms: <named-palette-color>
Complain About: missing-example-ids true
Default Highlight: css
WPT Path Prefix: css/css-fonts/
WPT Display: closed
</pre>
<pre class="link-defaults">
spec:css-color-4; type:property; text:color
spec: css-color-5; type: type; text: <color>
spec:css-values; type:value; text:ex
spec:css22; type:value; for:/; text:block
spec:html; type:element; text:font
spec:fetch; type:dfn; for:/; text:request
spec:fetch; type:dfn; for:/; text:fetch
</pre>
<pre class=biblio>
{
"GRAPHITE": {
"href": "https://scripts.sil.org/cms/scripts/page.php?site_id=projects&item_id=graphite_techAbout",
"title": "Graphite technical overview",
"publisher": "SIL",
"date": "2012"
},
"PFE-report": {
"href": "https://www.w3.org/TR/PFE-evaluation/",
"authors": [
"Chris Lilley"
],
"status": "Note",
"publisher": "W3C",
"title": "Progressive Font Enrichment: Evaluation Report",
"date": "15 October 2020"
}
}
</pre>
<style>
/* work-around for https://github.com/tabatkins/bikeshed/issues/1799 */
div.example {
overflow: visible;
}
div.example>a.self-link::before {
content: "¶";
}
</style>
<h2 id="introduction">
Introduction</h2>
This specification includes and expands on
the basic font features described in the CSS3 Fonts specification ([[CSS-FONTS-3]]).
<!--
██ ██ ███ ██ ██ ██ ████████ ██████
██ ██ ██ ██ ██ ██ ██ ██ ██ ██
██ ██ ██ ██ ██ ██ ██ ██ ██
██ ██ ██ ██ ██ ██ ██ ██████ ██████
██ ██ █████████ ██ ██ ██ ██ ██
██ ██ ██ ██ ██ ██ ██ ██ ██ ██
███ ██ ██ ████████ ███████ ████████ ██████
-->
<h3 id="values">
Value Definitions</h3>
This specification follows the <a href="https://www.w3.org/TR/CSS2/about.html#property-defs">CSS property definition conventions</a> from [[!CSS2]]
using the <a href="https://www.w3.org/TR/css-values-3/#value-defs">value definition syntax</a> from [[!CSS-VALUES-3]].
Value types not defined in this specification are defined in CSS Values & Units [[!CSS-VALUES-3]].
Combination with other CSS modules may expand the definitions of these value types.
In addition to the property-specific values listed in their definitions,
all properties defined in this specification
also accept the <a>CSS-wide keywords</a> as their property value.
For readability they have not been repeated explicitly.
<h2 id="basic-font-props">
Basic Font Properties</h2>
The particular font face used to render a character is determined by
the font family and other font properties that apply to a given element.
This structure allows settings to be varied independent of each
other.
<!--
████████ ███████ ██ ██ ████████ ████████ ███ ██ ██ ████ ██ ██ ██
██ ██ ██ ███ ██ ██ ██ ██ ██ ███ ███ ██ ██ ██ ██
██ ██ ██ ████ ██ ██ ██ ██ ██ ████ ████ ██ ██ ████
██████ ██ ██ ██ ██ ██ ██ ███████ ██████ ██ ██ ██ ███ ██ ██ ██ ██
██ ██ ██ ██ ████ ██ ██ █████████ ██ ██ ██ ██ ██
██ ██ ██ ██ ███ ██ ██ ██ ██ ██ ██ ██ ██ ██
██ ███████ ██ ██ ██ ██ ██ ██ ██ ██ ████ ████████ ██
-->
<h3 id="font-family-prop">
Font family: the 'font-family!!property' property</h3>
<pre class="propdef">
Name: font-family
Value: [ <<family-name>> | <<generic-family>> ]#
Initial: depends on user agent
Applies to: all elements and text
Inherited: yes
Percentages: n/a
Computed value: list, each item a string and/or <<generic-family>> keywords
Animation type: discrete
</pre>
<wpt>
font-family-name-000.xht
font-family-name-001.xht
font-family-name-002.xht
font-family-name-003.xht
font-family-name-004.xht
font-family-name-005.xht
font-family-name-006.xht
font-family-name-007.xht
font-family-name-008.xht
font-family-name-009.xht
font-family-name-010.xht
font-family-name-011.xht
font-family-name-012.xht
font-family-name-013.xht
font-family-name-014.xht
font-family-name-015.xht
font-family-name-016.xht
font-family-name-017.xht
font-family-name-018.xht
font-family-name-019.xht
font-family-name-020.xht
font-family-name-021.xht
font-family-name-022.xht
font-family-name-023.xht
font-family-name-024.xht
font-family-name-025.html
generic-family-keywords-003.html
standard-font-family-10.html
standard-font-family-11.html
standard-font-family-12.html
standard-font-family-13.html
standard-font-family-14.html
standard-font-family-15.html
standard-font-family-16.html
standard-font-family-17.html
standard-font-family-18.html
standard-font-family-19.html
standard-font-family-2.html
standard-font-family-20.html
standard-font-family-3.html
standard-font-family-4.html
standard-font-family-5.html
standard-font-family-6.html
standard-font-family-7.html
standard-font-family-8.html
standard-font-family-9.html
standard-font-family.html
test_font_family_parsing.html
animations/system-fonts.html
parsing/font-family-computed.html
parsing/font-family-invalid.html
parsing/font-family-valid.html
</wpt>
This property specifies a prioritized list of font family names or generic family names.
A font family defines a set of faces that vary in weight, width or slope.
CSS uses the combination of a family name with other font properties to select an individual face.
Using this selection mechanism,
rather than selecting a face via the style name as is often done in design applications,
allows some degree of regularity in textual display when fallback occurs.
Component values are a comma-separated list indicating alternatives.
A user agent iterates through the list of family names
until it matches an available font
that contains a glyph for the character to be rendered.
(See [[#cluster-matching]].)
This allows for differences in available fonts across platforms and
for differences in the range of characters supported by individual fonts.
<div class="example" id="ex-font-list">
<pre>
body {
font-family: Helvetica, Verdana, sans-serif;
}
</pre>
If Helvetica is available, it will be used when rendering.
If neither Helvetica nor Verdana is present,
then the generic font-family ''sans-serif'' font will be used.
</div>
There are three types of font family names, two of which may be used with this property:
<dl>
<dt><dfn id="family-name-value"><<family-name>></dfn>
<dd>
The name of a font family, such as Helvetica or Verdana in the previous example.
This might be a locally-instaled font, or might be a web font.
<dt><<generic-family>>
<dd>
Each <<generic-family>> keyword represents
a generic font choice,
and behaves as a potential alias for one or more locally-installed fonts
belonging to the specified generic font category.
A <<generic-family>> can thus be used as a fallback
for when an author's more specific font choices are not available.
There are three types of generic family:
1. Generics which apply to all Unicode characters
and will <em>always</em> match a locally installed font.
For example, ''monospaced''.
2. Generics which apply to all Unicode characters
but may not match to a locally installed font
on some systems.
For example, ''ui-rounded''.
3. Generics which are writing-system specific,
only apply to a subset of Unicode characters,
and may not match to a locally installed font
on some systems.
For example, ''generic(fangsong)''.
Authors are encouraged to append a generic font family as a last alternative
for improved robustness,
and to use a more specific generic font family, if applicable,
to prefer a specific style even if the individual named font family is not available.
Note that <<generic-family>> keywords cannot be quoted
(otherwise they are interpreted as a <<family-name>>).
The set of generic family keywords is defined in [[#generic-font-families]].
<dt><dfn id="system-family-name-value"><<system-family-name>></dfn>
<dd>
A locally installed system font, whose use is subject to certain constraints.
In particular, it may not be used with the ''font-family'' property,
but can be used with the ''font'' shorthand.
The following values refer to system fonts:
<dl dfn-type=value dfn-for=font>
<dt><dfn>caption</dfn>
<dd>The font used for captioned controls (e.g., buttons, drop-downs, etc.).
<dt><dfn>icon</dfn>
<dd>The font used to label icons.
<dt><dfn>menu</dfn>
<dd>The font used in menus (e.g., dropdown menus and menu lists).
<dt><dfn>message-box</dfn>
<dd>The font used in dialog boxes.
<dt><dfn>small-caption</dfn>
<dd>The font used for labeling small controls.
<dt><dfn>status-bar</dfn>
<dd>The font used in window status bars.
</dl>
<wpt>
system-fonts-serialization.tentative.html
</wpt>
</dd>
</dl>
<h4 id="family-name-syntax">
Syntax of <<family-name>>
</h4>
<pre class=prod><l><<family-name>></l> = <<string>> | <<custom-ident>>+</pre>
Font family names other than generic families or system font families
must either be given quoted as <<string>>s,
or unquoted as a sequence of one or more <<custom-ident>>.
Note: This means most punctuation characters and digits at the start of
each token must be escaped in unquoted font family names.
<div class="example invalid" id="ex-no-unquoted-punctuation">
To illustrate this, the following declarations are invalid:
<pre>
font-family: Red/Black, sans-serif;
font-family: "Lucida" Grande, sans-serif;
font-family: Ahem!, sans-serif;
font-family: test@foo, sans-serif;
font-family: #POUND, sans-serif;
font-family: Hawaii 5-0, sans-serif;
</pre>
</div>
Any identifier
which could be misinterpreted
as a pre-defined keyword in the font-family value definition,
or the [=CSS-wide keywords=],
is not allowed.
Note: this means that if you really have a font
whose name
is the same as one of the <<generic-family>> names,
or the system font names,
or the [=CSS-wide keywords=],
it <em>must</em> be quoted.
<div class="example" id="ex-valid-unusual-generic-like">
To illustrate this,
the following unusual font family names are valid
because they are quoted:
<pre>
font-family: "sans-serif", sans-serif;
font-family: "default", sans-serif;
font-family: "initial", sans-serif;
font-family: "inherit", sans-serif;
</pre>
</div>
If a sequence of identifiers is given as a <<family-name>>,
the computed value is the name
converted to a string
by joining all the identifiers in the sequence by single spaces.
To avoid mistakes in escaping,
it is recommended to quote font family names
that contain white space, digits,
or punctuation characters other than hyphens:
<div class="example" id="ex-best-quote">
Quoting font families prevents escaping mistakes.
<pre>
body { font-family: "New Century Schoolbook", serif }
<body style="font-family: '21st Century', fantasy">
</pre>
</div>
Font family <em>names</em> that happen to be the same as
a 'font-family!!property' keyword value
(e.g. <a>CSS-wide keywords</a> such as ''inherit'', or
<<generic-family>> keywords such as ''serif'')
must be quoted to prevent confusion
with the keywords of the same names.
UAs must not consider these keywords as matching the <<family-name>> type.
<h4 id="generic-family-name-syntax">
Syntax of <<generic-family>>
</h4>
<!-- <pre class=prod>
<dfn><<generic-family>></dfn> = generic(<<generic-script-specific>>) | <<generic-complete>> | <<generic-incomplete>>
<dfn><<generic-script-specific>></dfn> = <a href="">kai</a> | fangsong | nastaliq
<dfn><<generic-complete>></dfn> = serif | sans-serif | system-ui | cursive | fantasy | math | monospace
<dfn><<generic-incomplete>></dfn> = ui-serif | ui-sans-serif | ui-monospace | ui-rounded
</pre> -->
<pre class=prod>
<dfn><<generic-family>></dfn> = <<generic-script-specific>>| <<generic-complete>> | <<generic-incomplete>>
<dfn><<generic-script-specific>></dfn> = ''generic(kai)'' | ''generic(fangsong)'' | ''generic(nastaliq)''
<dfn><<generic-complete>></dfn> = ''serif'' | ''sans-serif'' | ''system-ui'' | ''cursive'' | ''fantasy'' | ''math'' | ''monospace''
<dfn><<generic-incomplete>></dfn> = ''ui-serif'' | ''ui-sans-serif'' | ''ui-monospace'' | ''ui-rounded''
</pre>
To make the syntax less succeptible to clashes, more recently defined generic font families are identified using a functional syntax.
<div class="example" id="ex-generic-functional">
<pre>
body { font-family: "Adobe Fangsong Std R", generic(fangsong), serif}
</pre>
The first choice in this example is a specific, named font, in Fang Song (仿宋) style.
The family name is enclosed in quotes as it contains space characters.
The second is a recently added script-specific generic font; it is unicode-range specific
and so may not match to an actual installed font on some systems;
but if it exists it will be an example of the requested style.
The third is a universal generic font, which is guaranteed to match on all systems.
</div>
<h4 id="system">
Syntax of <<system-family-name>>
</h4>
<pre class="prod">
<l><<system-family-name>></l> = ''caption'' | ''icon'' | ''menu'' | ''message-box'' | ''small-caption'' | ''status-bar''
</pre>
<h4 id="font-families">
Relationship Between Faces and Families
</h4>
A font family name only specifies a name given to a set of font faces;
it does not specify an individual face.
<div class="example" id="ex-futura-matches">
For example, given the availability of the fonts below,
Futura would match but Futura Medium would not:
<figure>
<img alt="family and face names" src="images/familyvsfacename.png">
<figcaption>Family and individual face names</figcaption>
</figure>
</div>
Note: The CSS definition of font attributes used for selection
are explicitly not intended to define a font taxonomy.
A type designer's idea of a family can often extend
to a set of faces that vary along axes other than just
the standard axes of
weight ('font-weight!!property'),
width ('font-width!!property'),
and slant ('font-style!!property').
A family can vary along axes that are unique to that family.
The CSS font selection mechanism merely
provides a way to determine the “closest” match
when substitution is necessary.
Note: The precise way a set of fonts are grouped into font families
varies depending upon the platform font management APIs.
For example, the Windows GDI API only allows four faces to be grouped into a family,
while the DirectWrite API,
Core Text API,
and other platforms support
font families with a variety of weights, widths, and slopes
(see [[#platform-props-to-css]] for more details).
See [[#localized-name-matching]] below for information on how
font-family names are matched.
<h4 id="generic-font-families">
Generic font families</h4>
A generic font family is a font family which has a standard name (as defined by CSS), but which is an alias for an existing installed font family present on the system.
However, a single generic font family may be a composite face
combining different typefaces based on such things as
the Unicode range of the character,
the <a>content language</a> of the containing element,
user preferences, system settings, etc.
Different generic font families may map to the same used font.
<wpt>
generic-family-keywords-001.html
generic-family-keywords-002.html
</wpt>
Note: Generic font families are intended to be widely implemented on many platforms, unlike arbitrary <<family-name>>s which are usually platform-specific names. They are expected to map to different fonts on different platforms. Authors may specify these generic family names if they desire their text to follow a particular design on many platforms, and are not particular about which specific font is chosen on those platforms.
User agents should provide reasonable default choices for the generic font families,
that express the characteristics of each family as well as possible,
within the limits allowed by the underlying technology.
User agents are encouraged to allow users to select alternative faces for the generic font families.
<dl dfn-for="font-family,<generic-family>" dfn-type=value>
<dt id="serif-def"><dfn>serif</dfn>
<dd>
Serif fonts represent
glyphs that have finishing strokes,
flared or tapering ends,
or have actual serifed endings (including slab serifs).
Serif fonts are typically proportionately-spaced.
They often display a greater variation between thick and thin strokes
than fonts from the ''sans-serif'' generic font family.
Note: ''serif'' and ''sans-serif''
only apply to a small handful of writing scripts.
Their use as generic font families in CSS is historical,
and reflects the Latin-centric nature
of early Web development.
Better and more widely applicable names would have been,
for example, "modulated" and "monoline".
However, for reasons of Web compatibility,
these names cannot be changed.
CSS uses the term "serif" to apply to a font for any script,
although other names might be more familiar for particular scripts,
such as Mincho (Japanese),
Sung or Song (Chinese),
Batang (Korean).
For Arabic, the Naskh style would correspond to ''serif''.
''serif'' must always map to at least one matched font face.
Note: No guarantee is placed on the character coverage of that font
face. Therefore, the font ''serif'' is mapped to may not end up being
used for all content.
<figure>
<img alt="sample serif fonts" src="images/serifexamples.png" >
<figcaption>Sample serif fonts</figcaption>
</figure>
<dt id="sans-serif-def"><dfn>sans-serif</dfn>
<dd>
Glyphs in sans-serif fonts,
as the term is used in CSS,
are generally low contrast
(vertical and horizontal stems have the close to the same thickness)
and have stroke endings that are plain
(without any flaring, cross stroke, or other ornamentation).
Sans-serif fonts are typically proportionately-spaced.
They often have little variation between thick and thin strokes,
compared to fonts from the ''serif'' family.
CSS uses the term "sans-serif" to apply to a font for any script,
although other names might be more familiar for particular scripts,
such as Gothic (Japanese),
Hei (Chinese),
or Gulim (Korean).
''sans-serif'' must always map to at least one matched font face.
Note: No guarantee is placed on the character coverage of that font
face. Therefore, the font ''sans-serif'' is mapped to may not end up being
used for all content.
<figure>
<img alt="sample sans-serif fonts" src="images/sansserifexamples.png" >
<figcaption>Sample sans-serif fonts</figcaption>
</figure>
<dt id="cursive-def"><dfn>cursive</dfn>
<dd>
Glyphs in cursive fonts generally use a script style,
and the result looks more like handwritten pen or brush writing than printed letterwork.
CSS uses the term "cursive" to apply to a font for any script,
although other names such as Chancery, Brush, Swing and Script are also used in font names.
<figure>
<img alt="sample cursive fonts" src="images/cursiveexamples.png" >
<figcaption>Sample cursive fonts</figcaption>
</figure>
<dt id="fantasy-def"><dfn>fantasy</dfn>
<dd>
Fantasy fonts are primarily decorative or expressive fonts
that contain decorative or expressive representations of characters.
These do not include Pi or Picture fonts which do not represent actual characters.
<figure>
<img alt="sample fantasy fonts" src="images/fantasyexamples.png" >
<figcaption>Sample fantasy fonts</figcaption>
</figure>
<dt id="monospace-def"><dfn>monospace</dfn>
<dd>
The sole criterion of a monospace font is that all glyphs have the same fixed width.
This is often used to render samples of computer code.
''monospace'' must always map to at least one matched font face.
Note: No guarantee is placed on the character coverage of that font
face. Therefore, the font ''monospace'' is mapped to may not end up being
used for all content.
<figure>
<img alt="sample monospace fonts" src="images/monospaceexamples.png" >
<figcaption>Sample monospace fonts</figcaption>
</figure>
<dt id="system-ui-def"><dfn>system-ui</dfn>
<dd>
This generic font family lets text render with the default user interface font
(which, as with all [[#generic-font-families]] may be a composite font)
on the platform on which the UA is running.
A cross-platform UA should use different fonts on its different supported platforms.
The purpose of ''system-ui'' is to allow web content
to integrate with the look and feel of the native OS.
<wpt>
system-ui-ar.html
system-ui-ja-vs-zh.html
system-ui-ja.html
system-ui-mixed.html
system-ui-ur-vs-ar.html
system-ui-ur.html
system-ui-zh.html
system-ui.html
</wpt>
The precise font used will depend on factors such as
Unicode coverage
and the content language.
<div class="example" id="ex-system-ui-opaque">
As with other generic font families,
the substitution of specific installed fonts for ''system-ui''
does not affect the computed style.
<pre>
<div id="system-text" style="font-family: system-ui"></div>
...
window.getComputedStyle(document.getElementById("system-text")).getPropertyValue("font-family");
</pre>
The script above should not have any knowledge of how ''system-ui''
is expanded to include a collection of system user interface fonts.
In particular, the above script should yield a result of "system-ui" on every platform.
</div>
<dt id="math-def"><dfn>math</dfn>
<dd>
This font family is intended for use with mathematical expressions.
<!-- largely from https://docs.microsoft.com/en-us/typography/opentype/spec/math -->
Such fonts may include additional data
(for example, the OpenType MATH table)
to help with the hierarchical process of equation layout.
In particular, they may contain
stylistic and stretching glyph variants
useful in setting mathematical equations.
<dt id="generic(fangsong)-def"><dfn>generic(fangsong)</dfn>
<dd>
This font family is used for Fang Song (仿宋) typefaces in Chinese.
Fang Song is a relaxed, intermediate form
between Song (''serif'') and Kai (''generic(kai)'').
Typically, the horizontal lines are tilted,
the endpoint flourishes are smaller,
and there is less variation in stroke width,
compared to a Song style.
Fang Song is often used for official Chinese Government documents.
Note: ''generic(fangsong)'' might not map to any locally installed font,
but if it does, that font will be in Fang Song style.
<figure>
<img style="width:75vw" alt="" src="images/fangsong.svg">
<figcaption>Chinese text displayed with sample fang song fonts</figcaption>
</figure>
<dt id="generic(kai)-def"><dfn>generic(kai)</dfn>
<dd>
This font family is used in
Simplified & Traditional Chinese.
A major typeface, which provides calligraphic styles for Chinese text.
It shows notable handwriting features.
Kai is commonly used in official documents and textbooks.
Most official documents in Taiwan use Kai in full text.
Kai can also be combined with other typefaces
to be used in text that needs to be differentiated
from the rest of the content,
for example, headlines, references, quotations, and dialogs.
Note: ''generic(kai)'' might not map to any locally installed font,
but if it does, that font will be in Kai style.
<figure>
<img style="width:75vw" alt="" src="images/kaiti.svg">
<figcaption>Chinese text displayed with sample kai fonts</figcaption>
</figure>
</dd>
<dt id="generic(nastaliq)-def"><dfn>generic(nastaliq)</dfn>
<dd>
This font family is the standard way of writing Urdu and Kashmiri,
and is also often a preferred style for Persian and other language text,
especially in literary genres such as poetry.
Key features include a sloping baseline for joined letters,
and overall complex shaping and positioning for base letters and diacritics alike.
There are also distinctive shapes for many glyphs and ligatures.
It is important not to fall back to a naskh style
for languages such as Urdu and Kashmiri.
Note: ''generic(nastaliq)'' might not map to any locally installed font,
but if it does, that font will be in Nastaliq style.
<figure>
<img style="width:25vw" alt="السلام علیکم" src="images/urdu-nastaliq.svg">
<figcaption>Urdu text displayed with a sample nastaliq font (Noto Nastaliq Urdu)</figcaption>
</figure>
<figure>
<img style="width:25vw" alt="السلام علیکم" src="images/urdu-naskh.svg">
<figcaption>Urdu text displayed with a fallback naskh font (Scheherazade New)</figcaption>
</figure>
<dt id="ui-serif-def"><dfn>ui-serif</dfn>
<dd>
This font family is used for the serif variant of the system's
user interface. The purpose of ''ui-serif'' is to allow web
content to integrate with the look and feel of the native OS.
Note: ''ui-serif'' is not expected to map to any font on platforms
without an appropriate system font.
<div class="example" id="ex-sample-ui-serif">
<figure>
<img alt="sample ui-serif font" src="images/ui-serif.png" >
<figcaption>Sample ui-serif font on macOS Catalina and iOS 13: New York</figcaption>
</figure>
</div>
<dt id="ui-sans-serif-def"><dfn>ui-sans-serif</dfn>
<dd>
This font family is used for the sans-serif variant of the system's
user interface. The purpose of ''ui-sans-serif'' is to allow web
content to integrate with the look and feel of the native OS.
Note: ''ui-sans-serif'' is not expected to map to any font on platforms
without an appropriate system font.
<div class="example" id="ex-sample-ui-sans">
<figure>
<img alt="sample ui-sans-serif font" src="images/ui-sans-serif.png" >
<figcaption>Sample ui-sans-serif font on macOS Catalina and iOS 13: San Francisco</figcaption>
</figure>
</div>
<dt id="ui-monospace-def"><dfn>ui-monospace</dfn>
<dd>
This font family is used for the monospaced variant of the
system's user interface. The purpose of ''ui-monospace'' is to
allow web content to integrate with the look and feel of the
native OS.
Note: ''ui-monospace'' is not expected to map to any font on platforms
without an appropriate system font.
<div class="example" id="ex-sample-ui-mono">
<figure>
<img alt="sample ui-monospace font" src="images/ui-monospace.png" >
<figcaption>Sample ui-monospace font on macOS Catalina and iOS 13: SF Mono</figcaption>
</figure>
</div>
<dt id="ui-rounded-def"><dfn>ui-rounded</dfn>
<dd>
This font family is used for the rounded variant of the system's
user interface. The purpose of ''ui-rounded'' is to allow web
content to integrate with the look and feel of the native OS.
Note: ''ui-rounded'' is not expected to map to any font on platforms
without an appropriate system font.
<div class="example" id="ex-sample-ui-rounded">
<figure>
<img alt="sample ui-rounded font" src="images/ui-rounded.png" >
<figcaption>Sample ui-rounded font on macOS Catalina and iOS 13: SF Rounded</figcaption>
</figure>
</div>
</dl>
<!--
████████ ███████ ██ ██ ████████ ██ ██ ████████ ████ ██████ ██ ██ ████████
██ ██ ██ ███ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██
██ ██ ██ ████ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██
██████ ██ ██ ██ ██ ██ ██ ███████ ██ ██ ██ ██████ ██ ██ ████ █████████ ██
██ ██ ██ ██ ████ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██
██ ██ ██ ██ ███ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██
██ ███████ ██ ██ ██ ███ ███ ████████ ████ ██████ ██ ██ ██
-->
<h3 id="font-weight-prop">Font weight: the 'font-weight!!property' property</h3>
<pre class="propdef">
Name: font-weight
Value: <<font-weight-absolute>> | bolder | lighter
Initial: normal
Applies to: all elements and text
Inherited: yes
Percentages: n/a
Computed value: a number, see below
Animation type: by computed value type
</pre>
<wpt>
font-weight-bolder-001.xht
font-weight-lighter-001.xht
font-weight-normal-001.xht
test-synthetic-bold.xht
parsing/font-weight-computed.html
parsing/font-weight-invalid.html
parsing/font-weight-valid.html
variations/font-parse-numeric-stretch-style-weight.html
variations/font-weight-interpolation.html
variations/font-weight-lighter-bolder.html
variations/font-weight-matching-installed-fonts.html
variations/font-weight-matching.html
variations/font-weight-metrics.html
variations/font-weight-parsing.html
</wpt>
The 'font-weight!!property' property specifies the weight of glyphs in the font,
their degree of blackness, or stroke thickness.
This property accepts values of the following:
<pre class="prod"><dfn id="font-weight-absolute-values"><font-weight-absolute></dfn> = [normal | bold | <<number [1,1000]>>]</pre>
Values have the following meanings:
<dl dfn-for=font-weight dfn-type=value>
<dt id="font-weight-numeric-values"><dfn><<number [1,1000]>></dfn>
<dd>
Each number indicates a weight that is at least as dark as its predecessor.
Only values greater than or equal to 1, and less than or equal to 1000, are valid,
and all other values are <a>invalid</a>.
Numeric values typically correspond to the commonly used weight names below.
<ul>
<li>100 - Thin
<li>200 - Extra Light (Ultra Light)
<li>300 - Light
<li>400 - Normal
<li>500 - Medium
<li>600 - Semi Bold (Demi Bold)
<li>700 - Bold
<li>800 - Extra Bold (Ultra Bold)
<li>900 - Black (Heavy)
</ul>
Note: A font might internally provide its own weight name mappings,
but those mappings within the font are disregarded in CSS.
<dt><dfn>normal</dfn>
<dd>
Same as ''400''.
<dt><dfn>bold</dfn>
<dd>
Same as ''700''.
<dt><dfn>bolder</dfn>
<dd>
Specifies a bolder weight than the inherited value.
See [[#relative-weights]].
<dt><dfn>lighter</dfn>
<dd>
Specifies a lighter weight than the inherited value.
See [[#relative-weights]].
</dl>
Font formats that use a scale other than a nine-step scale
should map their scale onto the CSS scale
so that 400 roughly corresponds with a face that would be labeled as Regular, Book, Roman
and 700 roughly matches a face that would be labeled as Bold.
Alternately, weights may be inferred from style names
that correspond roughly with the scale above.
The scale is relative,
so a face with a larger weight value must never appear lighter.
If style names are used to infer weights,
care should be taken to handle variations in style names across locales.
<h4 id="relative-weights">
Relative Weights</h4>
Specified values of ''bolder'' and ''lighter'' indicate weights
relative to the weight of the parent element.
The computed weight is calculated based on the inherited 'font-weight!!property' value
using the chart below.
<table id="bolderlighter" class="data">
<thead>
<tr>
<th>Inherited value (<var>w</var>)
<th>bolder
<th>lighter
<tbody>
<tr><th><var>w</var> < 100<td>400<td>No change
<tr><th>100 ≤ <var>w</var> < 350<td>400<td>100
<tr><th>350 ≤ <var>w</var> < 550<td>700<td>100
<tr><th>550 ≤ <var>w</var> < 750<td>900<td>400
<tr><th>750 ≤ <var>w</var> < 900<td>900<td>700
<tr><th>900 ≤ <var>w</var><td>No change<td>700
</table>
Note: The table above is equivalent to selecting the next relative bolder or lighter face,
given a font family containing normal and bold faces
along with a thin and a heavy face.
Authors who desire finer control over the exact weight values used for a given element
can use numerical values instead of relative weights.
<h4 id="missing-weights">
Missing weights</h4>
Quite often there are only a few weights available for a particular font family.
When a weight is specified for which no face exists, a face with a nearby weight is used.
In general, bold weights map to faces with heavier weights and light weights map to faces with lighter weights.
(See the [[#font-matching-algorithm]] for a precise definition.)
<div class="example" id="ex-nearby-weights">
The examples here illustrate which face is used for different weights.
Grey indicates that a face for the desired weight does not exist, so a face with a nearby weight is used.
<figure>
<img alt="weight mappings for a family with 400, 700 and 900 weights" src="images/optimaweights.png" >
<figcaption>Weight mappings for a font family with 400, 700 and 900 weight faces</figcaption>
</figure>
<figure>
<img alt="weight mappings for a family with 300, 600 weights" src="images/hiraginoweights.png" >
<figcaption>Weight mappings for a font family with 300 and 600 weight faces</figcaption>
</figure>
</div>
Most user agents model a font as having a particular weight
which often corresponds to one of the numbers in the nine-step scale
described <a href="#font-weight-numeric-values">above</a>.
While this is true of most fonts, some fonts might be configurable so as to support a range of weights.
In this situation, the user agent uses a face with a weight as close as possible to the weight requested
(see [[#font-matching-algorithm]] for the precise algorithm).
In particular, a user agent using a font which supports a range of weights
should behave the same as if a font is present at each individual weight in the range.
For TrueType / OpenType fonts that use variations,
the <code>wght</code> variation is used to implement varying weights.
Fractional weights are valid.
Although the practice is not well-loved by typographers,
bold faces are often synthesized by user agents for families that lack actual bold faces.
For the purposes of font matching,
these faces must be treated as if they exist within the family.
Authors can explicitly avoid this behavior by using the 'font-synthesis' property.
<!--
████████ ███████ ██ ██ ████████ ██ ██ ████ ████████ ████████ ██ ██
██ ██ ██ ███ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██
██ ██ ██ ████ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██
██████ ██ ██ ██ ██ ██ ██ ███████ ██ ██ ██ ██ ██ ██ ██ █████████
██ ██ ██ ██ ████ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██
██ ██ ██ ██ ███ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██
██ ███████ ██ ██ ██ ███ ███ ████ ████████ ██ ██ ██
-->
<h3 id="font-width-prop">
Font width: the 'font-width!!property' property</h3>
<pre class="propdef">
Name: font-width
Value: normal | <<percentage [0,∞]>> | ultra-condensed | extra-condensed | condensed | semi-condensed | semi-expanded | expanded | extra-expanded | ultra-expanded
Initial: normal
Applies to: all elements and text
Inherited: yes
Percentages: Not resolved
Computed value: a percentage, see below
Animation type: by computed value type
</pre>
<wpt>
font-stretch-01.html
font-stretch-02.html
font-stretch-03.html
font-stretch-04.html
font-stretch-05.html
font-stretch-06.html
font-stretch-07.html
font-stretch-08.html
font-stretch-09.html
font-stretch-10.html
font-stretch-11.html
font-stretch-12.html
font-stretch-13.html
font-stretch-14.html
font-stretch-15.html
font-stretch-16.html
font-stretch-17.html
font-stretch-18.html
animations/font-stretch-interpolation.html
parsing/font-stretch-computed.html
parsing/font-stretch-invalid.html
parsing/font-stretch-valid.html
variations/font-parse-numeric-stretch-style-weight.html
variations/font-stretch.html
</wpt>
The 'font-width!!property' property selects a normal,
condensed, or expanded face from a font family.
Values are specified either as percentages
or as keywords which map to a percentage
as defined in the following table:
<table id="widthmappings" class="data">
<thead>
<tr>
<th>Absolute keyword value
<th>Numeric value
<tbody dfn-for=font-width dfn-type=value>
<tr><th><dfn>ultra-condensed</dfn> <td>50%
<tr><th><dfn>extra-condensed</dfn> <td>62.5%
<tr><th><dfn>condensed</dfn> <td>75%
<tr><th><dfn>semi-condensed</dfn> <td>87.5%
<tr><th><dfn>normal</dfn> <td>100%