Create a gist now

Instantly share code, notes, and snippets.

@dantmnf /fonts.sh
Last active Jun 21, 2017

Embed
one-key script to set correct font family fallbacks on Arch Linux (and maybe other distros)
#!/bin/bash
if (( EUID != 0 ))
then
echo "I need root!"
exit 1
fi
echo "writing /etc/fonts/conf.d/79-order.conf"
cat > /etc/fonts/conf.d/79-order.conf <<EOFC
<?xml version='1.0'?>
<!DOCTYPE fontconfig SYSTEM 'fonts.dtd'>
<fontconfig>
<match target="font">
<edit name="autohint" mode="assign"><bool>false</bool></edit>
</match>
<alias binding="strong">
<family>sans-serif</family>
<prefer>
<family>.sans-serif-latin</family>
<family>.dantCJK-Hei-CHS</family>
<family>.dantCJK-Hei-CHT</family>
<family>.dantCJK-Gothic-J</family>
<family>.dantCJK-Gothic-K</family>
<family>.dantCJK-Global-Fallback</family>
</prefer>
</alias>
<alias binding="strong">
<family>sans-serif-cht</family>
<prefer>
<family>.sans-serif-latin</family>
<family>.dantCJK-Hei-CHT</family>
<family>.dantCJK-Hei-CHS</family>
<family>.dantCJK-Gothic-J</family>
<family>.dantCJK-Gothic-K</family>
<family>.dantCJK-Global-Fallback</family>
</prefer>
</alias>
<alias binding="strong">
<family>sans-serif-j</family>
<prefer>
<family>.sans-serif-latin</family>
<family>.dantCJK-Gothic-J</family>
<family>.dantCJK-Gothic-K</family>
<family>.dantCJK-Hei-CHT</family>
<family>.dantCJK-Hei-CHS</family>
<family>.dantCJK-Global-Fallback</family>
</prefer>
</alias>
<alias binding="strong">
<family>sans-serif-k</family>
<prefer>
<family>.sans-serif-latin</family>
<family>.dantCJK-Gothic-K</family>
<family>.dantCJK-Gothic-J</family>
<family>.dantCJK-Hei-CHT</family>
<family>.dantCJK-Hei-CHS</family>
<family>.dantCJK-Global-Fallback</family>
</prefer>
</alias>
<alias binding="same">
<family>serif</family>
<prefer>
<family>.serif-latin</family>
<family>.dantCJK-Song-CHS</family>
<family>.dantCJK-Song-CHT</family>
<family>.dantCJK-Mincho</family>
<family>.dantCJK-Myeongjo</family>
<family>.dantCJK-Global-Fallback</family>
</prefer>
</alias>
<alias binding="same">
<family>serif-cht</family>
<prefer>
<family>.serif-latin</family>
<family>.dantCJK-Song-CHT</family>
<family>.dantCJK-Song-CHS</family>
<family>.dantCJK-Mincho</family>
<family>.dantCJK-Myeongjo</family>
<family>.dantCJK-Global-Fallback</family>
</prefer>
</alias>
<alias binding="same">
<family>serif-j</family>
<prefer>
<family>.serif-latin</family>
<family>.dantCJK-Mincho</family>
<family>.dantCJK-Myungjo</family>
<family>.dantCJK-Song-CHT</family>
<family>.dantCJK-Song-CHS</family>
<family>.dantCJK-Global-Fallback</family>
</prefer>
</alias>
<alias binding="same">
<family>serif-k</family>
<prefer>
<family>.serif-latin</family>
<family>.dantCJK-Myeongjo</family>
<family>.dantCJK-Mincho</family>
<family>.dantCJK-Song-CHT</family>
<family>.dantCJK-Song-CHS</family>
<family>.dantCJK-Global-Fallback</family>
</prefer>
</alias>
<alias binding="strong">
<family>monospace</family>
<prefer>
<family>.monospace-latin</family>
<family>.dantCJK-Hei-CHS</family>
<family>.dantCJK-Hei-CHT</family>
<family>.dantCJK-Gothic-J</family>
<family>.dantCJK-Gothic-K</family>
<family>.dantCJK-Global-Fallback</family>
</prefer>
</alias>
<alias binding="strong">
<family>monospace-cht</family>
<prefer>
<family>.monospace-latin</family>
<family>.dantCJK-Hei-CHT</family>
<family>.dantCJK-Hei-CHS</family>
<family>.dantCJK-Gothic-J</family>
<family>.dantCJK-Gothic-K</family>
<family>.dantCJK-Global-Fallback</family>
</prefer>
</alias>
<alias binding="strong">
<family>monospace-j</family>
<prefer>
<family>.monospace-latin</family>
<family>.dantCJK-Gothic-J</family>
<family>.dantCJK-Gothic-K</family>
<family>.dantCJK-Hei-CHT</family>
<family>.dantCJK-Hei-CHS</family>
<family>.dantCJK-Global-Fallback</family>
</prefer>
</alias>
<alias binding="strong">
<family>monospace-k</family>
<prefer>
<family>.monospace-latin</family>
<family>.dantCJK-Gothic-K</family>
<family>.dantCJK-Gothic-J</family>
<family>.dantCJK-Hei-CHT</family>
<family>.dantCJK-Hei-CHS</family>
<family>.dantCJK-Global-Fallback</family>
</prefer>
</alias>
<alias binding="strong">
<family>.sans-serif-latin</family>
<prefer>
<family>Segoe UI</family>
<family>Source Sans Pro</family>
<family>DejaVu Sans</family>
</prefer>
</alias>
<alias binding="strong">
<family>.serif-latin</family>
<prefer>
<family>Source Serif Pro</family>
<family>Times New Roman</family>
</prefer>
</alias>
<alias binding="strong">
<family>.monospace-latin</family>
<prefer>
<family>Source Code Pro</family>
<family>Consolas</family>
</prefer>
</alias>
<alias binding="strong">
<family>.dantCJK-Song-CHS</family>
<prefer>
<family>Noto Serif CJK SC</family>
<family>SimSun</family>
</prefer>
</alias>
<alias binding="strong">
<family>.dantCJK-Song-CHT</family>
<prefer>
<family>Noto Serif CJK TC</family>
<family>PMingLiU</family>
</prefer>
</alias>
<alias binding="strong">
<family>.dantCJK-Kai-CHS</family>
<prefer>
<family>Kaiti SC</family>
<family>SimKai</family>
</prefer>
</alias>
<alias binding="strong">
<family>.dantCJK-Kai-CHT</family>
<prefer>
<family>Kaiti TC</family>
<family>DFKai-SB</family>
</prefer>
</alias>
<alias binding="strong">
<family>.dantCJK-Hei-CHS</family>
<prefer>
<family>Noto Sans CJK SC</family>
<family>Hiragino Sans GB</family>
<family>Heiti SC</family>
<family>SimHei</family>
</prefer>
</alias>
<alias binding="strong">
<family>.dantCJK-Hei-CHT</family>
<prefer>
<family>Noto Sans CJK TC</family>
<family>Heiti TC</family>
<family>Microsoft JhengHei</family>
</prefer>
</alias>
<alias binding="strong">
<family>.dantCJK-Mincho</family>
<prefer>
<family>Noto Serif CJK JP</family>
<family>Yu Mincho</family>
<family>HanaMinA</family>
</prefer>
</alias>
<alias binding="strong">
<family>.dantCJK-Myeongjo</family>
<prefer>
<family>Noto Serif CJK KR</family>
<family>Nanum Myeongjo</family>
</prefer>
</alias>
<alias binding="strong">
<family>.dantCJK-Gothic-J</family>
<prefer>
<family>Noto Sans CJK JP</family>
<family>Hiragino Kaku Gothic Pro</family>
</prefer>
</alias>
<alias binding="strong">
<family>.dantCJK-Gothic-K</family>
<prefer>
<family>Noto Sans CJK KR</family>
<family>Nanum Gothic</family>
</prefer>
</alias>
<alias binding="strong">
<family>.dantCJK-Global-Fallback</family>
<prefer>
<family>HanaMinA</family>
<family>HanaMinB</family>
</prefer>
</alias>
<alias binding="strong">
<family>HanaMinA</family>
<accept><family>HanaMinB</family></accept>
</alias>
</fontconfig>
EOFC
if command -v pacman &>/dev/null
then
echo "pacman -S adobe-source-{sans,serif,code}-pro-fonts noto-fonts-cjk"
pacman -S adobe-source-{sans,serif,code}-pro-fonts noto-fonts-cjk
else
echo "Install Source Sans Pro, Source Serif Pro, Source Code Pro, Noto Sans CJK "
echo "and Noto Serif CJK."
fi
echo "Additionally install Hanazono Mincho (HanaMinA/HanaMinB) for extra CJK support"
@scateu

This comment has been minimized.

Show comment
Hide comment

scateu commented Jun 21, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment