Last active
July 21, 2021 15:05
-
-
Save andersonbosa/ba9ed6adfe743343edf73e3576983dd2 to your computer and use it in GitHub Desktop.
install custom fonts on linux system
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
#!/usr/bin/env bash | |
# -*- coding: utf-8 -*- | |
############################################################################### | |
############################################################################### | |
# Author: @darksmile92 <https://dev.to/darksmile92/get-emojis-working-on-arch-linux-with-noto-fonts-emoji-2a9/comments> | |
# Publisher: @t4inha <https://andersonbosa.bio.link> | |
# | |
# ! this script isn't working, it's an ideia. if you know how to make it works | |
# ! please consider contributing! sz | |
# ! contribute here: https://gist.github.com/andersonbosa/ba9ed6adfe743343edf73e3576983dd2 | |
# | |
exit # just for safety, in case someone download this and execute without know. | |
############################################################################### | |
set -e | |
if [[ $(id -u) -ne 0 ]]; then | |
echo "Please run as root." | |
exit 1 | |
fi | |
echo "Setting up your custom font '$1'..." | |
# 1 - install the custom font package | |
# ??? | |
echo "Input custom filepath:" | |
read custom_font_filepath | |
if [[ -z "$custom_font_filepath" ]]; then | |
echo "empty path" | |
return 1 | |
fi | |
# 2 - add font config | |
# back up first | |
echo "Backuping to '~/baks/'" && | |
mkdir -p ~/baks && | |
cp -rv /etc/fonts/local.conf ~/baks | |
# ??? | |
echo """<?xml version='1.0'?> | |
<!DOCTYPE fontconfig SYSTEM 'fonts.dtd'> | |
<fontconfig> | |
<alias> | |
<family>sans-serif</family> | |
<prefer> | |
<family>Noto Sans</family> | |
<family>Noto Color Emoji</family> | |
<family>Noto Emoji</family> | |
<family>DejaVu Sans</family> | |
</prefer> | |
</alias> | |
<alias> | |
<family>serif</family> | |
<prefer> | |
<family>Noto Serif</family> | |
<family>Noto Color Emoji</family> | |
<family>Noto Emoji</family> | |
<family>DejaVu Serif</family> | |
</prefer> | |
</alias> | |
<alias> | |
<family>monospace</family> | |
<prefer> | |
<family>Noto Mono</family> | |
<family>Noto Color Emoji</family> | |
<family>Noto Emoji</family> | |
<family>DejaVu Sans Mono</family> | |
</prefer> | |
</alias> | |
</fontconfig> | |
""" >/etc/fonts/local.conf | |
# 3 - update font cache via fc-cache | |
fc-cache -v | |
echo "$1 Font installed! You may need to restart applications like chrome." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment