Created
August 7, 2017 21:25
-
-
Save gnprice/5b37dab520e44c38067b59c9235095db to your computer and use it in GitHub Desktop.
Noto CJK font fix
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0"?> | |
<!DOCTYPE fontconfig SYSTEM "fonts.dtd"> | |
<!-- | |
Problem: After installing the Noto fonts (on my Debian `stretch` | |
system, with `apt install fonts-noto`), Japanese text in my | |
browser ends up displayed in the "Medium" style of the font | |
rather than the "Regular" style. The "Medium" style is too | |
heavy for normal text. | |
Solution: Configure fontconfig to look specifically for Regular. | |
This can't be done with just the `style` property in the | |
pattern, because Medium has `style=Medium,Regular` and | |
Regular just has `style=Regular`, and there doesn't seem to be | |
a pattern that will prefer the latter over the former. | |
So we use `weight`, but there's a bug in the font metadata | |
where DemiLight has the same weight as Regular, which causes | |
us to get DemiLight. Fix that bug too. | |
To use: | |
1. Put this file in place at `/etc/fonts/conf.d/71-noto-fix.conf`. | |
2. Run `sudo dpkg-reconfigure fontconfig` to rebuild the | |
fontconfig cache. (Otherwise the `target=pattern` rules will | |
take effect, but not the `target=scan` rules.) | |
3. (Optional) Run `fc-match "Noto Sans CJK JP"` and observe that | |
you now get the Regular variant. | |
--> | |
<fontconfig> | |
<match target="pattern"> | |
<test name="family" compare="contains"> | |
<string>Noto Sans CJK</string> | |
</test> | |
<edit name="weight"> | |
<const>regular</const> | |
</edit> | |
</match> | |
<match target="pattern"> | |
<test name="family" compare="contains"> | |
<string>Noto Sans Mono CJK</string> | |
</test> | |
<edit name="weight"> | |
<const>regular</const> | |
</edit> | |
</match> | |
<!-- Regular has weight 80. For a corrected DemiLight weight, we | |
pick 55, somewhat arbitrarily but because that's the | |
"demilight" value mentioned in the fontconfig manual: | |
https://www.freedesktop.org/software/fontconfig/fontconfig-user.html | |
--> | |
<match target="scan"> | |
<test name="family" compare="contains"> | |
<string>Noto Sans CJK</string> | |
</test> | |
<test name="style"> | |
<string>DemiLight</string> | |
</test> | |
<edit name="weight"> | |
<int>55</int> | |
</edit> | |
</match> | |
<!-- Similarly Thin is at 50, same as Light. --> | |
<match target="scan"> | |
<test name="family" compare="contains"> | |
<string>Noto Sans CJK</string> | |
</test> | |
<test name="style"> | |
<string>Thin</string> | |
</test> | |
<edit name="weight"> | |
<int>40</int> | |
</edit> | |
</match> | |
</fontconfig> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment