Skip to content

Commit b5beab9

Browse files
committed
[css-fonts-4] Merge font-variant-numeric from CSS Fonts 3 #1653
1 parent a4d5216 commit b5beab9

File tree

6 files changed

+133
-0
lines changed

6 files changed

+133
-0
lines changed

css-fonts-4/Overview.bs

Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4005,6 +4005,139 @@ blockquote:first-line { font-variant: small-caps; }
40054005
<h3 id="font-variant-numeric-prop">
40064006
Numerical formatting: the 'font-variant-numeric' property</h3>
40074007

4008+
4009+
<pre class="propdef">
4010+
Name: font-variant-numeric
4011+
4012+
Value: normal | [ <<numeric-figure-values>> || <<numeric-spacing-values>> || <<numeric-fraction-values>> || ordinal || slashed-zero ] titling-caps
4013+
Initial: normal
4014+
Applies to: all elements
4015+
Inherited: yes
4016+
Percentages: n/a
4017+
Computed value: as specified
4018+
Animation type: discrete
4019+
</pre>
4020+
4021+
4022+
<p>Specifies control over numerical forms. The example below shows how
4023+
some of these values can be combined to influence the rendering of
4024+
tabular data with fonts that support these features. Within normal
4025+
paragraph text, proportional numbers are used while tabular numbers
4026+
are used so that columns of numbers line up properly:</p>
4027+
4028+
<div class="figure" style="padding: 0; margin: auto;"><img alt="combining number styles" src="images/numberstyles.png"><p class="caption">Using number styles</p></div>
4029+
4030+
<p>Possible combinations:</p>
4031+
4032+
<pre class="prod"><dfn id="numeric-figure-values"><var>&lt;numeric-figure-values&gt;</var></dfn> = [ <span>lining-nums</span> | <span>oldstyle-nums</span> ]</pre>
4033+
4034+
<pre class="prod"><dfn id="numeric-spacing-values"><var>&lt;numeric-spacing-values&gt;</var></dfn> = [ <span>proportional-nums</span> | <span>tabular-nums</span> ]</pre>
4035+
4036+
<pre class="prod"><dfn id="numeric-fraction-values"><var>&lt;numeric-fraction-values&gt;</var></dfn> = [ <span>diagonal-fractions</span> | <span>stacked-fractions</span> ]</pre>
4037+
4038+
<p>Individual values have the following meanings:</p>
4039+
4040+
<dl dfn-for="font-variant-numeric" dfn-type="value">
4041+
<dt><dfn id="font-variant-numeric-normal-value" title="normal!!font-variant-numeric">normal</dfn>
4042+
<dd>None of the features listed below are enabled.</dd>
4043+
4044+
<dt><dfn>lining-nums</dfn>
4045+
<dd>Enables display of lining numerals
4046+
(OpenType feature: <span class="tag">lnum</span>).</dd>
4047+
4048+
<dt><dfn>oldstyle-nums</dfn>
4049+
<dd>Enables display of old-style numerals
4050+
(OpenType feature: <span class="tag">onum</span>).</dd>
4051+
4052+
<dt><dfn>proportional-nums</dfn>
4053+
<dd>Enables display of proportional numerals
4054+
(OpenType feature: <span class="tag">pnum</span>).</dd>
4055+
4056+
<dt><dfn>tabular-nums</dfn>
4057+
<dd>Enables display of tabular numerals
4058+
(OpenType feature: <span class="tag">tnum</span>).</dd>
4059+
4060+
<dt><dfn>diagonal-fractions</dfn>
4061+
<dd>Enables display of lining diagonal fractions
4062+
(OpenType feature: <span class="tag">frac</span>).</dd>
4063+
4064+
<div class="featex"><img alt="diagonal fraction example" src="images/frac.png"></div>
4065+
4066+
<dt><dfn>stacked-fractions</dfn>
4067+
<dd>Enables display of lining stacked fractions
4068+
(OpenType feature: <span class="tag">afrc</span>).</dd>
4069+
4070+
<div class="featex"><img alt="stacked fraction example" src="images/afrc.png"></div>
4071+
4072+
<dt><dfn>ordinal</dfn>
4073+
<dd>Enables display of letter forms used with ordinal numbers
4074+
(OpenType feature: <span class="tag">ordn</span>).</dd>
4075+
4076+
<div class="featex"><img alt="ordinals example" src="images/ordinals.png"></div>
4077+
4078+
<dt><dfn>slashed-zero</dfn>
4079+
<dd>Enables display of slashed zeros
4080+
(OpenType feature: <span class="tag">zero</span>).</dd>
4081+
4082+
<div class="featex"><img alt="slashed zero example" src="images/zero.png"></div>
4083+
4084+
</dl>
4085+
4086+
<div id="ordinal-example" class="example">
4087+
<p>In the case of 'ordinal', although ordinal forms
4088+
are often the same as superscript forms, they are marked up
4089+
differently.</p>
4090+
<p>For superscripts, the variant property is only applied
4091+
to the sub-element containing the superscript:</p>
4092+
<pre>
4093+
sup { font-variant-position: super; }
4094+
x&lt;sup&gt;2&lt;/sup&gt;
4095+
</pre>
4096+
<p>For ordinals, the variant property is applied
4097+
to the entire ordinal number rather than
4098+
just to the suffix (or to the containing paragraph):</p>
4099+
<pre>
4100+
.ordinal { font-variant-numeric: ordinal; }
4101+
&lt;span class="ordinal"&gt;17th&lt;/span&gt;
4102+
</pre>
4103+
<p>In this case only the "th" will appear in ordinal form,
4104+
the digits will remain unchanged.
4105+
Depending upon the typographic traditions used in a given language,
4106+
ordinal forms may differ from superscript forms.
4107+
In Italian, for example,
4108+
ordinal forms sometimes include an underline in the ordinal design.</p>
4109+
</div>
4110+
4111+
<div class="example" id="steak-marinade">
4112+
<p>A simple flank steak marinade recipe,
4113+
rendered with automatic fractions and old-style numerals:</p>
4114+
4115+
<pre>.amount { font-variant-numeric: oldstyle-nums diagonal-fractions; }
4116+
4117+
&lt;h4>Steak marinade:&lt;/h4>
4118+
&lt;ul>
4119+
&lt;li>&lt;span class="amount">2&lt;/span> tbsp olive oil&lt;/li>
4120+
&lt;li>&lt;span class="amount">1&lt;/span> tbsp lemon juice&lt;/li>
4121+
&lt;li>&lt;span class="amount">1&lt;/span> tbsp soy sauce&lt;/li>
4122+
&lt;li>&lt;span class="amount">1 1/2&lt;/span> tbsp dry minced onion&lt;/li>
4123+
&lt;li>&lt;span class="amount">2 1/2&lt;/span> tsp italian seasoning&lt;/li>
4124+
&lt;li>Salt &amp;amp; pepper&lt;/li>
4125+
&lt;/ul>
4126+
4127+
&lt;p>Mix the meat with the marinade
4128+
and let it sit covered in the refrigerator
4129+
for a few hours or overnight.&lt;/p>
4130+
</pre>
4131+
4132+
<p>Note that the fraction feature
4133+
is only applied to values
4134+
not the entire paragraph.
4135+
Fonts often implement this feature using contextual rules
4136+
based on the use of the slash ('/') character.
4137+
As such, it's not suitable for use as a paragraph-level style.</p>
4138+
</div>
4139+
4140+
40084141
<h3 id="font-variant-alternates-prop">
40094142
Alternates and swashes: the 'font-variant-alternates' property</h3>
40104143

css-fonts-4/images/afrc.png

2.32 KB
Loading

css-fonts-4/images/frac.png

2.69 KB
Loading

css-fonts-4/images/numberstyles.png

18.2 KB
Loading

css-fonts-4/images/ordinals.png

3.47 KB
Loading

css-fonts-4/images/zero.png

2 KB
Loading

0 commit comments

Comments
 (0)