Skip to content

Instantly share code, notes, and snippets.

@untainsYD
Created January 22, 2024 21:14
Show Gist options
  • Save untainsYD/300d7db5a321544f41b08244dd5249bb to your computer and use it in GitHub Desktop.
Save untainsYD/300d7db5a321544f41b08244dd5249bb to your computer and use it in GitHub Desktop.
Fonts setup

Fonts

Find out what your default fonts and aliases are with fc-match:

for family in serif sans-serif monospace Arial Helvetica Verdana "Times New Roman" "Courier New"; do
    echo -n "$family: "
    fc-match "$family"
done

Main fonts

Install Jet Brains Mono (patched) from Nerd Fonts.

  • NOTES: check for new version, and if present then change the urls below.
mkdir -p $XDG_DATA_HOME/fonts/JetBrainsMono; \
cd $XDG_DATA_HOME/fonts/JetBrainsMono && \
curl -fLo "JetBrainsMonoNerdFontComplete-Bold.ttf" https://github.com/ryanoasis/nerd-fonts/blob/v2.3.3/patched-fonts/JetBrainsMono/Ligatures/Bold/complete/JetBrains%20Mono%20Bold%20Nerd%20Font%20Complete%20Mono.ttf && \
curl -fLo "JetBrainsMonoNerdFontComplete-BoldItalic.ttf" https://github.com/ryanoasis/nerd-fonts/blob/v2.3.3/patched-fonts/JetBrainsMono/Ligatures/BoldItalic/complete/JetBrains%20Mono%20Bold%20Italic%20Nerd%20Font%20Complete%20Mono.ttf && \
curl -fLo "JetBrainsMonoNerdFontComplete-ExtraBold.ttf" https://github.com/ryanoasis/nerd-fonts/blob/v2.3.3/patched-fonts/JetBrainsMono/Ligatures/ExtraBold/complete/JetBrains%20Mono%20ExtraBold%20Nerd%20Font%20Complete%20Mono.ttf && \
curl -fLo "JetBrainsMonoNerdFontComplete-ExtraBold-Italic.ttf" https://github.com/ryanoasis/nerd-fonts/blob/v2.3.3/patched-fonts/JetBrainsMono/Ligatures/ExtraBoldItalic/complete/JetBrains%20Mono%20ExtraBold%20Italic%20Nerd%20Font%20Complete%20Mono.ttf && \
curl -fLo "JetBrainsMonoNerdFontComplete-ExtraLight.ttf" https://github.com/ryanoasis/nerd-fonts/blob/v2.3.3/patched-fonts/JetBrainsMono/Ligatures/ExtraLight/complete/JetBrains%20Mono%20ExtraLight%20Nerd%20Font%20Complete%20Mono.ttf && \
curl -fLo "JetBrainsMonoNerdFontComplete-ExtraLightItalic.ttf" https://github.com/ryanoasis/nerd-fonts/blob/v2.3.3/patched-fonts/JetBrainsMono/Ligatures/ExtraLightItalic/complete/JetBrains%20Mono%20ExtraLight%20Italic%20Nerd%20Font%20Complete%20Mono.ttf && \
curl -fLo "JetBrainsMonoNerdFontComplete-Italic.ttf" https://github.com/ryanoasis/nerd-fonts/blob/v2.3.3/patched-fonts/JetBrainsMono/Ligatures/Italic/complete/JetBrains%20Mono%20Italic%20Nerd%20Font%20Complete%20Mono.ttf && \
curl -fLo "JetBrainsMonoNerdFontComplete-Light.ttf" https://github.com/ryanoasis/nerd-fonts/blob/v2.3.3/patched-fonts/JetBrainsMono/Ligatures/Light/complete/JetBrains%20Mono%20Light%20Nerd%20Font%20Complete%20Mono.ttf && \
curl -fLo "JetBrainsMonoNerdFontComplete-LightItalic.ttf" https://github.com/ryanoasis/nerd-fonts/blob/v2.3.3/patched-fonts/JetBrainsMono/Ligatures/LightItalic/complete/JetBrains%20Mono%20Light%20Italic%20Nerd%20Font%20Complete%20Mono.ttf && \
curl -fLo "JetBrainsMonoNerdFontComplete-Medium.ttf" https://github.com/ryanoasis/nerd-fonts/blob/v2.3.3/patched-fonts/JetBrainsMono/Ligatures/Medium/complete/JetBrains%20Mono%20Medium%20Nerd%20Font%20Complete%20Mono.ttf && \
curl -fLo "JetBrainsMonoNerdFontComplete-MediumItalic.ttf" https://github.com/ryanoasis/nerd-fonts/blob/v2.3.3/patched-fonts/JetBrainsMono/Ligatures/MediumItalic/complete/JetBrains%20Mono%20Medium%20Italic%20Nerd%20Font%20Complete%20Mono.ttf && \
curl -fLo "JetBrainsMonoNerdFontComplete-Regular.ttf" https://github.com/ryanoasis/nerd-fonts/blob/v2.3.3/patched-fonts/JetBrainsMono/Ligatures/Regular/complete/JetBrains%20Mono%20Regular%20Nerd%20Font%20Complete%20Mono.ttf && \
curl -fLo "JetBrainsMonoNerdFontComplete-SemiBold.ttf" https://github.com/ryanoasis/nerd-fonts/blob/v2.3.3/patched-fonts/JetBrainsMono/Ligatures/SemiBold/complete/JetBrains%20Mono%20SemiBold%20Nerd%20Font%20Complete%20Mono.ttf && \
curl -fLo "JetBrainsMonoNerdFontComplete-SemiBoldItalic.ttf" https://github.com/ryanoasis/nerd-fonts/blob/v2.3.3/patched-fonts/JetBrainsMono/Ligatures/SemiBoldItalic/complete/JetBrains%20Mono%20SemiBold%20Italic%20Nerd%20Font%20Complete%20Mono.ttf && \
curl -fLo "JetBrainsMonoNerdFontComplete-Thin.ttf" https://github.com/ryanoasis/nerd-fonts/blob/v2.3.3/patched-fonts/JetBrainsMono/Ligatures/Thin/complete/JetBrains%20Mono%20Thin%20Nerd%20Font%20Complete%20Mono.ttf && \
curl -fLo "JetBrainsMonoNerdFontComplete-ThinItalic.ttf" https://github.com/ryanoasis/nerd-fonts/blob/v2.3.3/patched-fonts/JetBrainsMono/Ligatures/ThinItalic/complete/JetBrains%20Mono%20Thin%20Italic%20Nerd%20Font%20Complete%20Mono.ttf && \
chmod 644 $XDG_DATA_HOME/fonts/JetBrainsMono/*
cd $HOME && fc-cache -frv

Install DejaVu fonts (patched) from Nerd Fonts.

  • NOTES: check for new version, and if present then change the urls below.
mkdir -p $XDG_DATA_HOME/fonts/DejaVu; \
cd $XDG_DATA_HOME/fonts/DejaVu && \
curl -fLo "DejaVuSansMonoNerdFontComplete-BoldOblique.ttf" https://github.com/ryanoasis/nerd-fonts/blob/v2.3.3/patched-fonts/DejaVuSansMono/Bold-Italic/complete/DejaVu%20Sans%20Mono%20Bold%20Oblique%20Nerd%20Font%20Complete.ttf && \
curl -fLo "DejaVuSansMonoNerdFontComplete-Bold.ttf" https://github.com/ryanoasis/nerd-fonts/blob/v2.3.3/patched-fonts/DejaVuSansMono/Bold/complete/DejaVu%20Sans%20Mono%20Bold%20Nerd%20Font%20Complete.ttf && \
curl -fLo "DejaVuSansMonoNerdFontComplete-Oblique.ttf" https://github.com/ryanoasis/nerd-fonts/blob/v2.3.3/patched-fonts/DejaVuSansMono/Italic/complete/DejaVu%20Sans%20Mono%20Oblique%20Nerd%20Font%20Complete.ttf && \
curl -fLo "DejaVuSansMonoNerdFontComplete.ttf" https://github.com/ryanoasis/nerd-fonts/blob/v2.3.3/patched-fonts/DejaVuSansMono/Regular/complete/DejaVu%20Sans%20Mono%20Nerd%20Font%20Complete.ttf && \
chmod 644 $XDG_DATA_HOME/fonts/DejaVu/*
cd $HOME && fc-cache -rfv

If fc-cache doesn't generate new cache for installed fonts (JetBrainsMono, DejaVu), as shown in example below:

...
/home/$USER/.config/local/share/fonts/JetBrainsMono: caching, new cache contents: 0 fonts, 0 dirs
...
/home/$USER/.config/local/share/fonts/JetBrainsMono: skipping, looped directory detected

NOTES: also, you can check it by running fc-list | grep 'JetBrains', if it doesn't find anything, then follow the instructions below.

Then, you need to install these fonts (JetBrainsMono Nerd Font and DejaVuSansMono Nerd Font) mannualy from Nerd Fonts Download.

  1. Remove previous installed fonts: rm -r $XDG_DATA_HOME/fonts/DejaVu/* && rm -r $XDG_DATA_HOME/fonts/JetBrainsMono/*.
  2. Unzip downloaded archive: mkdir -p Downloads/DejaVu | unzip Downloads/DejaVuSansMono.zip -d Downloads/DejaVu.
    • NOTES: repeat for both fonts.
  3. Remove unnecessary windows fonts: rm -r Downloads/DejaVu/*Windows*.
    • NOTES: repeat for both fonts.
  4. Move fonts to our XDG_DATA_HOME folders: mv -v Downloads/DejaVu/* $XDG_DATA_HOME/fonts/DejaVu.
    • NOTES: repeat for both fonts.
  5. Change permissions: chmod 644 $XDG_DATA_HOME/fonts/DejaVu/*.
    • NOTES: repeat for both fonts.
  6. Cleare and generate new cache: fc-cache -rfv.
  7. Check if it works: fc-list | grep 'JetBrains'.

Install additional fonts pacman -S noto-fonts adobe-source-code-pro-fonts adobe-source-han-sans-jp-fonts && sudo fc-cache -rfv.

Install windows and chrome os fallback fonts paru -S ttf-ms-fonts ttf-croscore.

You need some Math fonts, namely Latin Modern Math and STIX, to display MathML correctly. Install fonts: paru -S otf-stix otf-latinmodern-math. Run fc-cache -rfv to regenerate the fontconfig cache.

Default fonts configuration nvim .config/fontconfig/fonts.conf. I also, overwrite default ms-fonts by chrome-fonts. NOTES: see How To Set Default Fonts and Font Aliases on Linux for more information.

<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "urn:fontconfig:fonts.dtd">
<fontconfig>

    <!-- Set preferred serif, sans serif, and monospace fonts -->
    <alias>
        <family>serif</family>
        <prefer><family>DejaVuSansMono Nerd Font</family></prefer>
    </alias>

    <alias>
        <family>sans-serif</family>
        <prefer><family>DejaVuSansMono Nerd Font</family></prefer>
    </alias>

    <alias>
        <family>sans</family>
        <prefer><family>DejaVuSansMono Nerd Font</family></prefer>
    </alias>

    <alias>
       <family>monospace</family>
       <prefer>
	       <family>JetBrainsMono Nerd Font Mono</family>
	       <family>JetBrainsMono Nerd Font</family>
       </prefer>
    </alias>

    <!-- Aliases for commonly used MS fonts -->
    <match>
        <test name="family"><string>Arial</string></test>
        <edit name="family" mode="assign" binding="strong">
            <string>Arimo</string>
        </edit>
    </match>

    <match>
        <test name="family"><string>Helvetica</string></test>
        <edit name="family" mode="assign" binding="strong">
            <string>Arimo</string>
    	</edit>
    </match>

    <match>
        <test name="family"><string>Verdana</string></test>
        <edit name="family" mode="assign" binding="strong">
            <string>Arimo</string>
        </edit>
    </match>

    <match>
        <test name="family"><string>Tahoma</string></test>
    	<edit name="family" mode="assign" binding="strong">
      	    <string>Arimo</string>
    	</edit>
    </match>

    <match>
        <test name="family"><string>Comic Sans MS</string></test>
        <edit name="family" mode="assign" binding="strong">
            <string>Arimo</string>
        </edit>
    </match>

    <match>
        <test name="family"><string>Times New Roman</string></test>
        <edit name="family" mode="assign" binding="strong">
            <string>Tinos</string>
        </edit>
    </match>

    <match>
        <test name="family"><string>Times</string></test>
        <edit name="family" mode="assign" binding="strong">
            <string>Tinos</string>
        </edit>
    </match>

    <match>
        <test name="family"><string>Courier New</string></test>
        <edit name="family" mode="assign" binding="strong">
           <string>Cousine</string>
        </edit>
    </match>

</fontconfig>
<!-- vim: set ft=xml: -->

Run fc-cache -rfv to regenerate the fontconfig cache.

You can verify that the aliases have been set up correctly with fc-match:

for family in serif sans-serif monospace Arial Helvetica Verdana "Times New Roman" "Courier New"; do
    echo -n "$family: "
    fc-match "$family"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment