Please add <group> → <axis> → <family>
This is a part of: #200
Preamble
The optical size axis behaves slightly differently than the other standard OpenType axes.
While width / weight / slant can be selected by the user in traditional font selection menus, optical size is supposed to be applied by default, at specific sizes.
Therefore, it behaves more like a complete family replacement, at some sizes, than a style attribute.
Purpose
To accommodate optical size
, step
can accept lists of family
or match
elements, with the same syntax and rules as group
.
Proposed syntax
<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<!-- SPDX-License-Identifier: MIT -->
<fontconfig>
<group>
<family>@canonical_family_name@</family>
<axis>
<name>@axis_name@</name>
<step>
<name>@step_name@</name>
<value>@step_value@</name>
<family>@technical_family_name@</family>
</step>
</axis>
</group>
</fontconfig>
Behaviour
An optical sizing step
with a name
different from Regular
behaves like a group
with a target of @canonical_family_name@
SPACE @step_name@
. (Regular
corresponds to @canonical_family_name@
, and therefore can not be re-declared, except for its axis value).
Like agroup
, it can contain family
elements, match
elements, etc.
It reuses the weight
, width
, and slant
step values of the containing group. The reuse and aliasing implied by optical sizing
unification are the reason it is not desirable to push grouping of an optical axis
step in a separate group
element.
That would probably not scale well to multiple special axes, but optical size
is the only one specified so far and it’s hard to plan for things that have no formal existence in the OpenType spec.
The corresponding font files are used to satisfy a query for the @step_value@
of the axis, using the same distance calculation as in #198. Fontconfig should apply optical sizing automatically, unless explicitly requested otherwise by apps.
The Regular
step of optical size
is mapped by default to the fonts without any optical size
axis in group
. Its default value is 11
.
Exemple
<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<!-- SPDX-License-Identifier: MIT -->
<fontconfig>
<group>
<target>Bar</target>
<axis>
<name>optical size</name>
<step>
<name>Display</name>
<value>24</name>
<family>BigFoo</family>
</step>
</axis>
</group>
</fontconfig>
Real world Exemple
<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<!-- SPDX-License-Identifier: MIT -->
<fontconfig>
<group>
<target>PT Sans</target>
<match>
<family>PT Sans Narrow</family>
<style-prefix>Narrow</style-prefix>
</match>
<axis>
<name>optical size</name>
<step>
<name>Caption</name>
<value>8</name>
</step>
</axis>
</group>
</fontconfig>
In that real-world case the technical family mapped to the Caption
optical size step already has the target naming, so it does not need an explicit family
or match
declarations.
Any query for PT Sans
, Bold
at size lower or equal to 8, should return PT Sans Caption
, Bold
data.
Past alternatives
Something similar to:
<?xml version='1.0'?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<!-- SPDX-License-Identifier: MIT -->
<fontconfig>
<match target="scan">
<test name="family">
<string>PT Sans</string>
</test>
<edit name="fontversion">
<int>2</int>
</edit>
</match>
<match target="scan">
<test name="fullname">
<string>PT Sans Narrow</string>
</test>
<test name="family">
<string>PT Sans Narrow</string>
</test>
<test name="style">
<string>Regular</string>
</test>
<edit name="family" mode="prepend">
<string>PT Sans</string>
</edit>
<edit name="style" mode="prepend">
<string>Narrow</string>
</edit>
<edit name="fontversion">
<int>1</int>
</edit>
</match>
<match target="scan">
<test name="fullname">
<string>PT Sans Narrow Bold</string>
</test>
<test name="family">
<string>PT Sans Narrow</string>
</test>
<test name="style">
<string>Bold</string>
</test>
<edit name="family" mode="prepend">
<string>PT Sans</string>
</edit>
<edit name="style" mode="prepend">
<string>Narrow Bold</string>
</edit>
<edit name="fontversion">
<int>1</int>
</edit>
</match>
<alias binding="same">
<family>PT Sans</family>
<accept>
<family>sans-serif</family>
</accept>
</alias>
<alias>
<family>sans-serif</family>
<prefer>
<family>PT Sans</family>
</prefer>
</alias>
<match>
<test name="family">
<string>PT Sans</string>
</test>
<test name="size" compare="less_eq">
<double>8</double>
</test>
<edit name="family" mode="prepend" binding="same">
<string>PT Sans Caption</string>
</edit>
</match>
<alias binding="same">
<family>PT Sans Caption</family>
<accept>
<family>PT Sans</family>
</accept>
</alias>
<alias binding="same">
<family>PT Sans</family>
<accept>
<family>PT Sans Caption</family>
</accept>
</alias>
</fontconfig>