-
Notifications
You must be signed in to change notification settings - Fork 708
/
Copy pathOverview-wip.bs
3874 lines (3124 loc) · 161 KB
/
Overview-wip.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
<!--
This is *not* the CSS Fonts spec source, it's an attempt to switch the
Fonts spec to Bikeshed format. See README for more details.
-->
<pre class='metadata'>
Group: CSSWG
Shortname: css-fonts
Title: CSS Fonts Module
Level: 3
Status: ED
Work Status: Testing
TR: https://www.w3.org/TR/css-fonts-3/
ED: https://drafts.csswg.org/css-fonts/
Editor: John Daggett, Invited Expert, @nattokirai, w3cid 41498
Editor: Myles C. Maxfield, Apple Inc., mmaxfield@apple.com, w3cid 77180
Abstract: This CSS3 module describes how font properties are specified and how font resources are loaded dynamically. The contents of this specification are a consolidation of content previously divided into <a href="https://www.w3.org/TR/2002/WD-css3-fonts-20020802/">CSS3 Fonts</a> and <a href="https://www.w3.org/TR/2002/WD-css3-webfonts-20020802/">CSS3 Web Fonts</a> modules. The description of font load events was moved into the <a href="https://drafts.csswg.org/css-font-load-events/">CSS3 Font Load Events</a> module.
Previous Version: https://www.w3.org/TR/2013/CR-css-fonts-3-20131003/
Previous Version: https://www.w3.org/TR/2013/WD-css-fonts-3-20130711/
!Issues List: <a href="http://www.w3.org/Style/CSS/Tracker/products/18">Tracker</a>
!Issues List: <a href="https://www.w3.org/Bugs/Public/buglist.cgi?query_format=advanced&product=CSS&component=Fonts&bug_status=NEW&bug_status=ASSIGNED&bug_status=REOPENED">Bugzilla</a>
Test Suite: http://test.csswg.org/suites/css3-fonts/nightly-unstable/
At Risk: fallback handling for text decoration in superscript/subscript variant glyphs ('font-variant-position'), 'font-language-override' property
Ignored Terms: font-relative lengths, document language, sub, sup, ident, atkeyword, number, <unicode-range>, domstring, invalidaccesserror
</pre>
<!-- I'm just experimenting here, don't get your bee in a bonnet -->
<script type="text/javascript" src="http://use.typekit.com/xon2bky.js"></script>
<script type="text/javascript">try{Typekit.load();}catch(e){}</script>
<script type="text/javascript">
window.onload = function () {
if (!("devicePixelRatio" in window && window.devicePixelRatio > 1)) return;
var i, hiresElements = document.getElementsByClassName("hires");
for (i = 0; i < hiresElements.length; i++) {
var h = hiresElements[i];
if (h.tagName != "IMG") continue;
var src = h.getAttribute("src");
var src2x = src.replace(/\.\w+$/, function(m) { return "@2x" + m; });
h.src = src2x;
}
}
</script>
<style type="text/css">
body, th, td, h1, h2, h3, h4, h5, h6 {
font-family: "myriad-pro", sans-serif !important;
}
body {
padding: 2em 70px 2em 70px;
}
p + p, p.mtb {
margin-top: 0.8em;
text-indent: 0px;
}
#bolderlighter {
width: 40%;
}
#bolderlighter th {
text-align: center;
}
#fontformats td, #eventhandlers td, #fontformats th, #eventhandlers th {
padding-right: 2em;
text-align: left;
}
dd {
margin-bottom: 1em;
}
#authors dd {
margin-bottom: 0;
}
#fontstylematchingalg {
list-style-type: lower-alpha;
}
#fontmatchingalg ul, #fontmatchingalg ol {
margin-top: 0.8em;
}
#fontmatchingalg li + li {
margin-top: 0.8em;
}
div.example {
padding: 1em;
margin-top: 1em;
}
div.example + div.example {
margin-top: 2em;
}
div.figure {
page-break-inside: avoid;
}
pre.prod { white-space: pre-wrap; margin: 1em 0 1em 2em }
div.featex {
width: 700px;
}
div.featex img {
margin: auto;
display: block;
}
span.tag {
font-family: monospace;
font-size: 120%;
}
ol ol {
list-style-type: lower-alpha;
}
.idl-code {
font-weight: bold;
color: #c50;
}
</style>
<h2 id="introduction">Introduction</h2>
A font provides a resource containing the visual representation of
characters. At the simplest level it contains information that maps character
codes to shapes (called glyphs) that represent these characters. Fonts
sharing a common design style are commonly grouped into font families
classified by a set of standard font properties. Within a family, the
shape displayed for a given character can vary by stroke weight, slant
or relative width, among others. An individual font face is described by a
unique combination of these properties. For a given range of text, CSS
font properties are used to select a font family and a specific font
face within that family to be used when rendering that text. As a
simple example, to use the bold form of Helvetica one could use:
<pre>
body {
font-family: Helvetica;
font-weight: bold;
}
</pre>
Font resources may be installed locally on the system on which a user
agent is running or downloadable. For local font resources descriptive
information can be obtained directly from the font resource. For
downloadable font resources (sometimes referred to as web fonts), the
descriptive information is included with the reference to the font
resource.
Families of fonts typically don't contain a single face for each
possible variation of font properties. The CSS font selection mechanism
describes how to match a given set of CSS font properties to a single
font face.
<h2 id="typography-background">Typography Background</h2>
<em>This section is non-normative.</em>
Typographic traditions vary across the globe, so there is no unique way
to classify all fonts across languages and cultures. For even common
Latin letters, wide variations are possible:
<div class="figure"><img alt="variations in glyphs for a single character" src="aaaaaa.png"><p class="caption">One character, many glyph variations</div>
Differences in the anatomy of letterforms is one way to distinguish
fonts. For Latin fonts, flourishes at the ends of a character's main
strokes, or serifs, can distinguish a font from those without. Similar
comparisons exist in non-Latin fonts between fonts with tapered strokes
and those using primarily uniform strokes:
<div class="figure"><img alt="serif vs. non-serifs" src="serifvssansserif.png" /><p class="caption">Letterforms with and without serifs</div>
<div class="figure"><img alt="serif vs. non-serifs for japanese" src="minchovsgothic.png" /><p class="caption">Similar groupings for Japanese typefaces</div>
Fonts contain letterforms and the data needed to map characters to
these letterforms. Often this may be a simple one-to-one mapping, but
more complex mappings are also possible. The use of combining diacritic
marks creates many variations for an underlying letterform:
<div class="figure"><img alt="diacritic marks" src="aaaaaa-diacritics.png" /><p class="caption">Variations with diacritic marks</div>
A sequence of characters can be represented by a single glyph known as a ligature:
<div class="figure"><img alt="example of a fi ligature" src="final-ligature.png" /><p class="caption">Ligature example</div>
Visual transformations based on textual context are often
stylistic option in European languages. They are required to correctly
render languages like Arabic, the lam and alef characters below
<em>must</em> be combined when they exist in sequence:
<div class="figure"><img alt="lam alef ligature" src="lamaleflig.png" /><p class="caption">Required Arabic ligature</div>
The relative complexity of these shaping transformations requires
additional data within the font.
Sets of font faces with various stylistic variations are often
grouped together into font families. In the simplest case a regular
face is supplemented with bold and italic faces, but much more extensive
groupings are possible. Variations in the thickness of letterform
strokes, the <dfn>weight</dfn>, and the overall proportions of the letterform,
the <dfn>width</dfn>, are most common. In the example below, each letter uses a
different font face within the Univers font family. The width used
increases from top to bottom and the weight increases from left to
right:
<div class="figure"><img alt="various width and weight variations within a single family" src="weightwidthvariations.png" /><p class="caption">Weight and width variations within a single font family</div>
Creating fonts that support multiple scripts is a difficult task;
designers need to understand the cultural traditions surrounding the
use of type in different scripts and come up with letterforms that
somehow share a common theme. Many languages often share a common
script and each of these languages may have noticeable stylistic
differences. For example, the Arabic script, when used for Persian and
Urdu, exhibits significant and systematic differences in letterforms,
as does Cyrillic when used with languages such as Serbian and
Russian.
The <em>character map</em> of a font defines the mapping of characters
to glyphs for that font. If a document contains characters not
supported by the <a>character maps</a> of the fonts contained in a font
family list, a
user agent may use a <em>system font fallback</em> procedure to locate an
appropriate font that does. If no appropriate font can be found,
some form of "missing glyph" character will be rendered by the
user agent. System fallback can occur when the specified list of font families
does not include a font that supports a given character.
Although the <em>character map</em> of a font maps a given character to a
glyph for that character, modern font technologies such as OpenType
and AAT (Apple Advanced Typography) provide ways of mapping a
character to different glyphs based upon feature settings. Fonts in
these formats allow these features to be embedded in the font itself
and controlled by applications. Common typographic features which can
be specified this way include ligatures, swashes, contextual
alternates, proportional and tabular figures, and automatic fractions,
to list just a few. For a visual overview of OpenType features, see
the [[OPENTYPE-FONT-GUIDE]].
<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.
<!-- prop: font-family -->
<h3 id="font-family-prop">Font family: the 'font-family' property</h3>
<pre class="propdef">
Name: font-family
Value: [ <<family-name>> | <<generic-family>> ]#
Initial: depends on user agent
Applies to: all elements
Inherited: yes
Percentages: n/a
Computed value: as specified
Animatable: no
</pre>
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 style attributes 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.
Note: Designers should note that 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 may often extend to
a set of faces that vary along axes other than just the standard axes
of weight, width and slope. A family may extend to include both a set
of serif faces and a set of sans-serif faces or vary along axes that
are unique to that family. The CSS font selection mechanism merely
provides a way to determine the “closest” substitute when
substitution is necessary.
Unlike other CSS properties, 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. This allows for differences
in available fonts across platforms and for differences in the range
of characters supported by individual fonts.
A font family name only specifies a name given to a set of font
faces, it does not specify an individual face. For example, given the availability
of the fonts below, Futura would match but Futura Medium would not:
<div class="figure"><img alt="family and face names" src="familyvsfacename.png" /><p class="caption">Family and individual face names</div>
Consider the example below:
<div class="example">
<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 user-agent-defined
sans serif font will be used.
</div>
There are two types of font family names:
<dl dfn-for="font-family" dfn-type="value">
<dt><dfn id="family-name-value"><<family-name>></dfn>
<dd>The name of a font family of choice such as Helvetica or Verdana in the previous example.
<dt><dfn id="generic-family-value"><<generic-family>></dfn>
<dd>
The following generic family keywords are defined: ''serif'', ''sans-serif'', ''cursive'',
''fantasy'', and ''monospace''. These keywords can be used as a general fallback mechanism
when an author's desired font choices are not available. As keywords, they must not
be quoted. Authors are encouraged to append a generic font family as a last alternative for
improved robustness.
</dl>
Font family names other than generic families must either be given quoted as <a
href="https://www.w3.org/TR/CSS21/syndata.html#strings">strings,</a>
or unquoted as a sequence of one or more
<a href="https://www.w3.org/TR/CSS21/syndata.html#value-def-identifier">identifiers.</a>
This means most punctuation characters and digits at the start of
each token must be escaped in unquoted font family names.
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>
If a sequence of identifiers is given as a font 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:
<pre>
body { font-family: "New Century Schoolbook", serif }
<BODY STYLE="font-family: '21st Century', fantasy">
</pre>
Font family <em>names</em> that happen to be the same as a keyword
value (''inherit'', ''serif'', ''sans-serif'', ''monospace'', ''fantasy'', and
''cursive'') must be quoted to prevent confusion with the keywords with
the same names. The keywords ''initial'' and ''default'' are reserved for
future use and must also be quoted when used as font names. UAs must
not consider these keywords as matching the <var><family-name></var>
type.
The precise way a set of fonts are grouped into font families
varies depending upon the platform font management API's. The
Windows GDI API only allows four faces to be grouped into a family
while the DirectWrite API and API's on OSX and other platforms support
font families with a variety of weights, widths and slopes (see <a
href="#platform-props-to-css">Appendix A</a> for more details).
Some font formats allow fonts to carry multiple localizations
of the family name. User agents must recognize and correctly
match all of these names independent of the underlying platform
localization, system API used or document encoding:
<div class="figure"><img alt="examples of localized family names" src="localizedfamilynames.png" /><p class="caption">Localized family names</div>
The details of localized font family name matching and the
corresponding issues of case sensitivity are described below in the
<a href="#font-family-casing">font matching</a> section.
<h4 id="generic-font-families">Generic font families</h4>
All five generic font families are defined to exist in all CSS
implementations (they need not necessarily map to five distinct actual
fonts). User agents should provide reasonable default choices for the
generic font families, which 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 choices for the generic fonts.
The syntax of <dfn><generic-family></dfn> is:
<pre class=prod><generic-family> = serif | sans-serif | cursive | fantasy | monospace</pre>
<h5 class="no-num no-toc" id='serif-family'><dfn value for="<generic-family>">serif</dfn></h5>
Serif fonts represent the formal text style for a script.
This often means but is not limited to 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. CSS uses the term ''serif'' to apply to a font for any script,
although other names may be more familiar for particular scripts, such
as Mincho (Japanese), Sung, Song or Kai (Chinese), Batang (Korean).
For Arabic, the Naskh style would correspond to ''serif'' more due to
its typographic role rather than its actual design style.
Any font that is so described may be used to represent the
generic ''serif'' family.
<div class="figure"><img alt="sample serif fonts" src="serifexamples.png" /><p class="caption">Sample serif fonts</div>
<h5 class="no-num no-toc" id='sans-serif-family'><dfn value for="<generic-family>">sans-serif</dfn></h5>
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 may be more familiar for particular scripts, such as
Gothic (Japanese), Hei (Chinese), or Gulim (Korean). Any font that
is so described may be used to represent the generic ''sans-serif''
family.
<div class="figure"><img alt="sample sans-serif fonts" src="sansserifexamples.png" /><p class="caption">Sample sans-serif fonts</div>
<h5 class="no-num no-toc" id='cursive-family'><dfn value for="<generic-family>">cursive</dfn></h5>
Glyphs in cursive fonts generally use a more informal 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.
<div class="figure"><img alt="sample cursive fonts" src="cursiveexamples.png" /><p class="caption">Sample cursive fonts</div>
<h5 class="no-num no-toc" id='fantasy-family'><dfn value for="<generic-family>">fantasy</dfn></h5>
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.
<div class="figure"><img alt="sample fantasy fonts" src="fantasyexamples.png" /><p class="caption">Sample fantasy fonts</div>
<h5 class="no-num no-toc" id='monospace-family'><dfn value for="<generic-family>">monospace</dfn></h5>
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.
<div class="figure"><img alt="sample monospace fonts" src="monospaceexamples.png" /><p class="caption">Sample monospace fonts</div>
<!-- prop: font-weight -->
<h3 id="font-weight-prop">Font weight: the 'font-weight' property</h3>
<pre class="propdef">
Name: font-weight
Value: normal | bold | bolder | lighter | 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900
Initial: normal
Applies to: all elements
Inherited: yes
Percentages: n/a
Computed value: numeric weight value (see description)
Animatable: as font weight
</pre>
The 'font-weight' property specifies the weight of glyphs in the font,
their degree of blackness or stroke thickness.
Values have the following meanings:
<dl dfn-type=value dfn-for=font-weight>
<dt><dfn>100</dfn>, <dfn>200</dfn>, <dfn>300</dfn>, <dfn>400</dfn>, <dfn>500</dfn>, <dfn>600</dfn>, <dfn>700</dfn>, <dfn>800</dfn>, <dfn>900</dfn>
<dd>
These values form an ordered sequence,
where each number indicates a weight that is at least as dark as its predecessor.
These roughly correspond to the commonly used weight names below:
* 100 - Thin
* 200 - Extra Light (Ultra Light)
* 300 - Light
* 400 - Normal
* 500 - Medium
* 600 - Semi Bold (Demi Bold)
* 700 - Bold
* 800 - Extra Bold (Ultra Bold)
* 900 - Black (Heavy)
<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.
<dt><dfn>lighter</dfn>
<dd>Specifies a lighter weight than the inherited value.
</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. Or weights may be
inferred from the style names, ones 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.
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 [[#font-matching-algorithm]] for a precise definition). The examples here illustrate which
face is used for different weights, grey indicates a face for that
weight does not exist so a face with a nearby weight is used:
<div class="figure"><img alt="weight mappings for a family with 400, 700 and 900 weights" src="optimaweights.png" /><p class="caption">Weight mappings for a font family with 400, 700 and 900 weight faces</div>
<div class="figure"><img alt="weight mappings for a family with 300, 600 weights" src="hiraginoweights.png" /><p class="caption">Weight mappings for a font family with 300 and 600 weight faces</div>
Although the practice is not well-loved by typographers, bold faces are often
synthesized by user agents for faces that lack actual bold faces. For
the purposes of style 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.
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' value using the chart
below.
<table id="bolderlighter" class="data" summary="Bolder/lighter mappings">
<thead>
<tr>
<th>Inherited value
<th>bolder
<th>lighter
<tbody>
<tr><th>100<td>400<td>100
<tr><th>200<td>400<td>100
<tr><th>300<td>400<td>100
<tr><th>400<td>700<td>100
<tr><th>500<td>700<td>100
<tr><th>600<td>900<td>400
<tr><th>700<td>900<td>400
<tr><th>800<td>900<td>700
<tr><th>900<td>900<td>700
</table>
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
may use numerical values instead of relative weights.
<h3 id="font-stretch-prop">Font width: the 'font-stretch' property</h3>
<pre class="propdef">
Name: font-stretch
Value: normal | ultra-condensed | extra-condensed | condensed | semi-condensed | semi-expanded | expanded | extra-expanded | ultra-expanded
Initial: normal
Applies to: all elements
Inherited: yes
Percentages: n/a
Computed value: as specified
Animatable: as font stretch
</pre>
The 'font-stretch' property selects a normal,
condensed, or expanded face from a font family. Absolute keyword values
have the following ordering, from narrowest to widest:
<ul dfn-type=value dfn-for=font-stretch>
<li><dfn>ultra-condensed</dfn>
<li><dfn>extra-condensed</dfn>
<li><dfn>condensed</dfn>
<li><dfn>semi-condensed </dfn>
<li><dfn>normal</dfn>
<li><dfn>semi-expanded</dfn>
<li><dfn>expanded</dfn>
<li><dfn>extra-expanded</dfn>
<li><dfn>ultra-expanded</dfn>
</ul>
When a face does not exist
for a given width, normal or condensed values map to a narrower face,
otherwise a wider face. Conversely, expanded values map to a wider
face, otherwise a narrower face. The figure below shows how the nine
font-stretch property settings affect font selection for font family
containing a variety of widths, grey indicates a width for which no
face exists and a different width is substituted:
<div class="figure"><img alt="width mappings for a family with condensed, normal and expanded faces" src="universwidths.png" /><p class="caption">Width mappings for a font family with condensed, normal and expanded width faces</div>
<p id="font-stretch-animation">Animation of font stretch: Font stretch is
interpolated in discrete steps. The interpolation happens as though the
ordered values are equally spaced real numbers. The interpolation result
is rounded to the nearest value, with values exactly halfway between two
values rounded towards the later value in the list above.
<h3 id="font-style-prop">Font style: the 'font-style' property</h3>
<pre class="propdef">
Name: font-style
Value: normal | italic | oblique
Initial: normal
Applies to: all elements
Inherited: yes
Percentages: n/a
Computed value: as specifed
Animatable: no
</pre>
The 'font-style' property allows
italic or oblique faces to be selected. Italic forms are generally cursive in nature while oblique faces are
typically sloped versions of the regular face. Oblique faces can be simulated by artificially sloping the
glyphs of the regular face. Compare the artificially sloped renderings of Palatino "a" and Baskerville "N"
in grey with the actual italic versions:
<div class="figure"><img alt="artificial sloping vs. real italics" src="realvsfakeitalics.png" /><p class="caption">Artificial sloping versus real italics</div>
Values have the following meanings:
<dl dfn-type=value dfn-for=font-style>
<dt><dfn>normal</dfn>
<dd>selects a face that is classified as a normal face, one that is neither italic or obliqued
<dt><dfn>italic</dfn>
<dd>selects a font that is labeled as an italic face, or an oblique face if one is not
<dt><dfn>oblique</dfn>
<dd>selects a font that is labeled as an oblique face, or an italic face if one is not
</dl>
If no italic or oblique face is available, oblique faces can be
synthesized by rendering non-obliqued faces with an artificial
obliquing operation. The use of these artificially obliqued faces
can be disabled using the 'font-synthesis' property. The details
of the obliquing operation are not explicitly defined.
Note: Authors should also be aware that synthesized
approaches may not be suitable for scripts like Cyrillic, where italic
forms are very different in shape. It is always better to use an actual
italic font rather than rely on a synthetic version.
<!-- resolution on the "undefined" nature of synthetics: http://www.w3.org/2013/06/06-css-minutes.html#item03 -->
Many scripts lack the tradition of mixing a cursive form within
text rendered with a normal face. Chinese, Japanese and Korean fonts
almost always lack italic or oblique faces. Fonts that support a
mixture of scripts will sometimes omit specific scripts such as Arabic
from the set of glyphs supported in the italic face. User agents
should be careful about making <em>character map</em> assumptions across
faces when implementing support for <em>system font fallback</em>.
<h3 id="font-size-prop">Font size: the 'font-size' property</h3>
<pre class="propdef">
Name: font-size
Value: <<absolute-size>> | <<relative-size>> | <<length-percentage>>
Initial: medium
Applies to: all elements
Inherited: yes
Percentages: refer to parent element's font size
Computed value: absolute length
Animatable: as length
</pre>
This property indicates the desired height of glyphs from the
font. For scalable fonts, the font-size is a scale factor applied to the EM unit
of the font. (Note that certain glyphs may bleed outside their EM box.) For
non-scalable fonts, the font-size is converted into absolute units and matched
against the declared font-size of the font, using the same absolute coordinate
space for both of the matched values.
Values have the following meanings:
<dl dfn-type=value dfn-for=font-size>
<dt><dfn type><absolute-size></dfn>
<dd> An <<absolute-size>> keyword refers to an entry
in a table of font sizes computed and kept by the user agent. Possible values
are:
<pre class=prod link-type=value link-for="<absolute-size>">
<a>xx-small</a> | <a>x-small</a> | <a>small</a> | <a>medium</a> | <a>large</a> | <a>x-large</a> | <a>xx-large</a>
</pre>
<dt><dfn type><relative-size></dfn>
<dd> A <<relative-size>> keyword is interpreted
relative to the table of font sizes and the computed 'font-size' of the
parent element. Possible values are:
<pre class=prod dfn-type=value dfn-for="<relative-size> font-size">
<dfn>larger</dfn> | <dfn>smaller</dfn>
</pre>
For example, if the parent element has a font size of
''medium'', a value of ''larger'' will make the font size of the
current element be ''large''. If the parent element's size is not
close to a table entry, the user agent is free to interpolate
between table entries or round off to the closest one. The user
agent may have to extrapolate table values if the numerical value
goes beyond the keywords.
<dt><dfn><<length-percentage>></dfn>
<dd>A length value specifies an absolute font size
(independent of the user agent's font table).
Negative lengths are illegal.
A percentage value specifies an absolute font size relative
to the parent element's font size. Use of percentage values, or
values in ''em''s, leads to more robust and cascadable style sheets.
</dl>
The following table provides user agent guidelines for the
absolute-size scaling factor and their mapping to HTML heading and
absolute font-sizes. The ''medium'' value is used as the reference
middle value. The user agent may fine-tune these values for different
fonts or different types of display devices.
<table class="data">
<thead dfn-type=value dfn-for="font-size <absolute-size>">
<th scope=row><<absolute-size>>
<th scope=col><dfn>xx-small</dfn>
<th scope=col><dfn>x-small</dfn>
<th scope=col><dfn>small</dfn>
<th scope=col><dfn>medium</dfn>
<th scope=col><dfn>large</dfn>
<th scope=col><dfn>x-large</dfn>
<th scope=col><dfn>xx-large</dfn>
<th scope=col>
<tbody>
<tr>
<th scope=row>scaling factor
<td>3/5
<td>3/4
<td>8/9
<td>1
<td>6/5
<td>3/2
<td>2/1
<td>3/1
<tr>
<th scope=row>HTML headings
<td>h6
<td>
<td>h5
<td>h4
<td>h3
<td>h2
<td>h1
<td>
<tr>
<th scope=row>HTML font sizes
<td>1
<td>
<td>2
<td>3
<td>4
<td>5
<td>6
<td>7
</table>
Note: To preserve readability, an UA applying
these guidelines should nevertheless avoid creating font-size resulting
in less than 9 device pixels per EM unit on a computer display.</em>
Note: In CSS1, the suggested
scaling factor between adjacent indexes was 1.5 which user experience
proved to be too large. In CSS2, the suggested scaling factor for computer
screen between adjacent indexes was 1.2 which still created issues for the small
sizes. The new scaling factor varies between each index to provide a better
readability.</em>
The actual value of this property may differ from the computed
value due a numerical value on 'font-size-adjust' and the
unavailability of certain font sizes.
Child elements inherit the computed 'font-size' value (otherwise, the
effect of 'font-size-adjust' would compound).
<div class="example">
Examples:
<pre>p { font-size: 12pt; }
blockquote { font-size: larger }
em { font-size: 150% }
em { font-size: 1.5em }
</pre>
</div>
<h3 id="font-size-adjust-prop">Relative sizing: the 'font-size-adjust' property</h3>
<pre class="propdef">
Name: font-size-adjust
Value: none | <<number>>
Initial: none
Applies to: all elements
Inherited: yes
Percentages: n/a
Computed value: as specified
Animatable: as number
</pre>
For any given font size, the apparent size and legibility of text
varies across fonts. For scripts such as Latin or Cyrillic that
distinguish between upper and lowercase letters, the relative height
of lowercase letters compared to their uppercase counterparts is a
determining factor of legibility. This is commonly referred to as the
<dfn lt="font aspect value" local-lt="aspect value">aspect value</dfn>.
Precisely defined, it is equal to the x-height of a font divided by
the font size.
In situations where font fallback occurs, fallback fonts may not
share the same aspect value as the desired font family and will thus
appear less readable. The 'font-size-adjust' property is a way to
preserve the readability of text when font fallback occurs. It does
this by adjusting the font-size so that the x-height is the same
regardless of the font used.
<div class="example">
The style defined below defines Verdana as the desired font family, but if Verdana is not available Futura or Times
will be used.
<pre>
p {
font-family: Verdana, Futura, Times;
}
<p>Lorem ipsum dolor sit amet, ...</p>
</pre>
Verdana has a relatively high aspect value, lowercase letters are relatively tall compared to uppercase
letters, so at small sizes text appears legible. Times has a lower aspect value and so if fallback occurs,
the text will be less legible at small sizes than Verdana.
</div>
How text rendered in each of these fonts compares is shown below, the columns show text rendered in Verdana, Futura and Times.
The same font-size value is used across cells
within each row and red lines are included to show the differences in x-height. In the upper half each row is rendered in the same font-size value. The same is true
for the lower half but in this half the 'font-size-adjust' property is also set so that the actual font size is adjusted
to preserve the x-height across each row. Note how small text remains relatively legible across each row in the lower half.
<div class="figure"><img alt="text with and without 'font-size-adjust'" src="fontsizeadjust.png" /><p class="caption">Text with and without the use of 'font-size-adjust'</div>
This property allows authors to specify an <a>aspect value</a> for an element that
will effectively preserve the x-height of the first choice font, whether it is substituted
or not. Values have the following meanings:
<dl dfn-type=value dfn-for=font-size-adjust>
<dt><dfn>none</dfn>
<dd>Do not preserve the font's x-height.
<dt><dfn><<number>></dfn>
<dd>
Specifies the <a>aspect value</a> used in the calculation below to calculate the adjusted font size:
<pre>c = ( a / a' ) s </pre>
where:
<pre>
s = font-size value
a = <a>aspect value</a> as specified by the 'font-size-adjust' property
a' = <a>aspect value</a> of actual font
c = adjusted font-size to use
</pre>
This value applies to any font that is selected but in typical usage it should be based
on the <a>aspect value</a> of the first font in the font-family list. If this is specified accurately,
the <tt>(a/a')</tt> term in the formula above is effectively 1 for the first font and no adjustment occurs.
If the value is specified inaccurately, text rendered using the first font in the family
list will display differently in older user agents that don't support 'font-size-adjust'.
</dl>
The value of 'font-size-adjust' affects the used value of 'font-size' but
does not affect the computed value. It affects the size of relative units
that are based on font metrics of the <a>first available font</a> such
as <code>ex</code> and <code>ch</code> but does not affect the size of
<code>em</code> units. Since numeric values of 'line-height'
refer to the computed size of 'font-size',
'font-size-adjust' does not affect the used value of 'line-height'.
Note: In CSS, authors often specify 'line-height'
as a multiple of the 'font-size'. Since the 'font-size-adjust'
property affects the used value of 'font-size', authors should take
care setting the line height when 'font-size-adjust' is used. Setting
the line height too tightly can result in overlapping lines of text
in this situation.
Authors can calculate the
<a>aspect value</a> for a given font by comparing spans with the same content but
different 'font-size-adjust' properties. If the same font-size is used, the spans will match when the 'font-size-adjust'
value is accurate for the given font.
<div class="example">
Two spans with borders are used to determine the <a>aspect value</a> of a font. The 'font-size' is the same for both spans but the
'font-size-adjust' property is specified only for the right span. Starting with a value of 0.5, the aspect
value can be adjusted until the borders around the two letters line up.
<pre>
p {
font-family: Futura;
font-size: 500px;
}
span {
border: solid 1px red;
}
.adjust {
font-size-adjust: 0.5;
}
<p><span>b</span><span class="adjust">b</span></p>
</pre>
<div class="figure"><img alt="Futura with an aspect value of 0.5" src="beforefontsizeadjust.png" /><p class="caption">Futura with an <a>aspect value</a> of 0.5</div>
The box on the right is a bit bigger than the one on the left, so the <a>aspect value</a> of this font is something less than 0.5.
Adjust the value until the boxes align.
</div>
<h3 id="font-prop">Shorthand font property: the 'font' property</h3>
<pre class="propdef shorthand">
Name: font
Value: [ [ <<'font-style'>> || <<font-variant-css21>> || <<'font-weight'>> || <<'font-stretch'>> ]?
Value: <<'font-size'>> [ / <<'line-height'>> ]? <<'font-family'>> ]
Value: | caption | icon | menu | message-box | small-caption | status-bar
</pre>
The 'font' property is, except as
described below, a shorthand property for setting
'font-style',
'font-variant',
'font-weight',
'font-stretch',
'font-size',
'line-height',
and 'font-family' at the same place in the stylesheet.
Values for the 'font-variant'
property may also be included, but only those supported in CSS 2.1; none
of the 'font-variant' values added in this specification can be used in
the 'font' shorthand:
<pre class="prod"><dfn><font-variant-css21></dfn> = [ <dfn value for="<font-variant-css21> font">normal</dfn> | <dfn value for="<font-variant-css21> font">small-caps</dfn> ]</pre>
Additionally, it is a shorthand for
'font-size-adjust',
'font-kerning',
and 'font-language-override',
but as these cannot be specified in the syntax,
it merely resets these to their initial values.
The syntax of this property is based on a traditional typographical
shorthand notation to set multiple properties related to fonts.
<div class="example">
Examples:
<pre>
p { font: 12pt/14pt sans-serif }
p { font: 80% sans-serif }
p { font: x-large/110% "new century schoolbook", serif }
p { font: bold italic large Palatino, serif }