# Installing Fonts

See the [Arch wiki on Fonts](https://wiki.archlinux.org/index.php/Fonts) for much more information. Some of this information has been copied from there for my own reference / notes.

### List Installed Fonts

These commands will list installed fonts, see the subcategories below for sorting through installed fonts.

```bash
# List all installed fonts
fc-list

# List verbose information on a font
# Shows us font family, full-name, and postscriptname
# If this isn't grepped, we will list ALL fonts verbosely
fc-list -v | grep Weather

# List fonts for specified lang
fc-list -f '%{file}\n' :lang=ar
#+ list all japanese font families
fc-list -f "%{family}\n" :lang=ja
```

#### Aliases

Font aliases such as `serif`, `sans-serif`, `monospace`, and others can be used to list fonts with the below command -  

```bash
fc-match monospace
```

#### Unicode Character Support

This is useful when trying to verify that the proper font is installed for displaying a unicode character.

For example, the below is matching a font for the character for [a pile of poo](https://www.fileformat.info/info/unicode/char/1f4a9/index.htm), or `U+1F4A9` - 

```bash
# Match unicode character with supported font
fc-match -s monospace:charset=1F4A9 
```

Input this character into vim by running `:UnicodeSearch! U+1F4A9` or enter `<Ctrl><V>U1F4A9` while in insert mode within vim.

### Installed by Package Manager

To list fonts installed by Pacman - 

```bash
## list font packages installed by pacman
fc-list -f "%{file} " | xargs pacman -Qqo | sort -u
```

#### Manual Installation

To install fonts manually, see the `~/.local/share/fonts` directory and copy the correct font file format within. For example, to install [Weather Icons](https://erikflowers.github.io/weather-icons/) simply clone the repository and copy the needed [Font File](https://github.com/erikflowers/weather-icons/tree/master/font) to the `~/.local/share/fonts` directory.

For me, the file I needed was `weathericons-regular-webfont.ttf`, which installed the font with the full-name `Weather Icons`, seen by the output below - 

```bash
fc-list -v | grep Weather
        family: "Weather Icons"(s)
        fullname: "Weather Icons Regular"(s)
        postscriptname: "WeatherIcons-Regular"(s)
```

Sometimes it may be necessary to then run `fc-cache` to update the font configuration cache on our system, but generally this will be handled automatically. Nevertheless, it is a simple step to perform and ensures the font is fully recognized by our system.

If the font is not appearing in a terminal or application, ensure that the app or terminal is configured to use the newly installed font.

### Misc

The below, and some of the other commands here, from user thisoldman on [Arch discussions](https://bbs.archlinux.org/viewtopic.php?id=139831) - 

 ```bash
## list all fonts and styles known to fontconfig
fc-list : | sort
## list monospace fonts by family and file
fc-list -f "%{family} : %{file}\n" :spacing=100 | sort
## all bold fonts
fc-list :style=Bold | sort
```