Skip to content

Commit

Permalink
Update fontconfig configs for macOS bundling (openscad#5191)
Browse files Browse the repository at this point in the history
  • Loading branch information
kintel authored Jun 25, 2024
1 parent 1105773 commit d4c36aa
Show file tree
Hide file tree
Showing 23 changed files with 753 additions and 201 deletions.
15 changes: 15 additions & 0 deletions fonts-osx/conf.d/10-hinting-slight.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "urn:fontconfig:fonts.dtd">
<fontconfig>
<description>Set hintslight to hintstyle</description>

<match target="pattern">
<!--
This sort of configuration is available on the major desktop environments
and we don't have to break it with "assign" unconditionally. however, we
want to set something for others. So we use "append" here to get this working
in both cases so that most clients would takes a look at the first place only.
-->
<edit name="hintstyle" mode="append"><const>hintslight</const></edit>
</match>
</fontconfig>
36 changes: 19 additions & 17 deletions fonts-osx/conf.d/10-scale-bitmap-fonts.conf
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<!DOCTYPE fontconfig SYSTEM "urn:fontconfig:fonts.dtd">
<fontconfig>

<description>Bitmap scaling</description>
<!--
If font is bitmap, calculate scale factor.
Note that color bitmap fonts have scalable=true, while
non-color ones have scalable=false. Both groups have outline=false.
-->
<match target="font">
<test name="scalable" compare="eq">
<test name="outline" compare="eq">
<bool>false</bool>
</test>
<edit name="pixelsizefixupfactor" mode="assign">
Expand All @@ -13,10 +18,20 @@
</divide>
</edit>
</match>
<!--
For non-scalable bitmap fonts (ie. non-color), skip
minor scaling if hinting is enabled.
-->
<match target="font">
<test name="outline" compare="eq">
<bool>false</bool>
</test>
<test name="scalable" compare="eq">
<bool>false</bool>
</test>
<test name="hinting" compare="eq">
<bool>true</bool>
</test>
<edit name="scalingnotneeded" mode="assign">
<and>
<less>
Expand All @@ -30,20 +45,7 @@
</and>
</edit>
</match>
<!--
So far we determined the scale factor. Now, check and if
scaling is NOT desirable, just reset the scale factor to 1.0.
-->
<match target="font">
<test name="scalable" compare="eq">
<bool>false</bool>
</test>
<test name="pixelsize" target="pattern" compare="less">
<double>64</double>
</test>
<test name="hinting" compare="eq">
<bool>true</bool>
</test>
<test name="scalingnotneeded" compare="eq">
<bool>true</bool>
</test>
Expand All @@ -55,7 +57,7 @@
If we *are* going to scale, go ahead and do it.
-->
<match target="font">
<test name="scalable" compare="eq">
<test name="outline" compare="eq">
<bool>false</bool>
</test>
<test name="pixelsizefixupfactor" compare="not_eq">
Expand Down
15 changes: 15 additions & 0 deletions fonts-osx/conf.d/10-sub-pixel-rgb.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "urn:fontconfig:fonts.dtd">
<fontconfig>
<description>Enable sub-pixel rendering with the RGB stripes layout</description>
<!-- Enable sub-pixel rendering -->
<match target="pattern">
<!--
This sort of configuration is available on the major desktop environments
and we don't have to break it with "assign" unconditionally. however, we
want to set something for others. So we use "append" here to get this working
in both cases so that most clients would takes a look at the first place only.
-->
<edit name="rgba" mode="append"><const>rgb</const></edit>
</match>
</fontconfig>
8 changes: 8 additions & 0 deletions fonts-osx/conf.d/10-yes-antialias.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "urn:fontconfig:fonts.dtd">
<fontconfig>
<description>Enable antialiasing</description>
<match target="pattern">
<edit name="antialias" mode="append"><bool>true</bool></edit>
</match>
</fontconfig>
17 changes: 17 additions & 0 deletions fonts-osx/conf.d/11-lcdfilter-default.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "urn:fontconfig:fonts.dtd">
<fontconfig>
<description>Use lcddefault as default for LCD filter</description>
<!-- Use lcddefault as default for LCD filter -->
<match target="pattern">
<!--
This sort of configuration is available on the major desktop environments
and we don't have to break it with "assign" unconditionally. however, we
want to set something for others. So we use "append" here to get this working
in both cases so that most clients would takes a look at the first place only.
-->
<edit mode="append" name="lcdfilter">
<const>lcddefault</const>
</edit>
</match>
</fontconfig>
3 changes: 2 additions & 1 deletion fonts-osx/conf.d/20-unhint-small-vera.conf
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<!DOCTYPE fontconfig SYSTEM "urn:fontconfig:fonts.dtd">
<fontconfig>
<description>Disable hinting for Bitstream Vera fonts when the size is less than 8ppem</description>
<!--
The Bitstream Vera fonts have GASP entries suggesting that hinting be
disabled below 8 ppem, but FreeType ignores those, preferring to use
Expand Down
Loading

0 comments on commit d4c36aa

Please sign in to comment.