Skip to content

Small CLI tool to download and install nerdfonts on Termux environment

License

Notifications You must be signed in to change notification settings

massix/gleamfonts

Repository files navigation

Project Logo

Gleamfonts

Simple command line tool to easily fetch and install Nerdfonts in a Termux environment.

The tool is written using the Gleam programming language and needs a working Erlang VM to be used locally.

Install from source

You can manually install gleamfonts into your system by following the steps below.

  1. Clone the repository locally, somewhere in your home folder in Termux:
    mkdir -p ~/dev
    cd ~/dev
    git clone https://github.com/massix/gleamfonts.git
    cd gleamfonts
        
  2. Install Erlang, Gleam and SQLite using the official package manager:
    pkg update && pkg install -y erlang gleam libsqlite
        
  3. Compile the project
    make clean install
        

    This step will install the binary distribution inside the /data/data/com.termux/files/usr/opt/gleamfonts folder, along with a convenient script to make it easier to launch the application without knowing all the details of how to launch an Erlang application. The script will be installed inside /data/data/com.termux/files/usr/bin, making it available in your PATH.

To verify that the installation is successful, reload your environment (or restart the Termux application) and launch gleamfonts --help, you should be greeted with the help page of the application.

Install from a release

At the releases page, choose the most recent one and download the enclosed tarball, then extract it into /data/data/com.termux/files using the following command:

tar -xzf gleamfonts-x.x.x.tgz --strip-components=1 -C /data/data/com.termux/files

You will still need to install the Erlang VM and the SQLite library using the default package manager:

pkg update && pkg install erlang libsqlite

How it works

The first time the program is run, it will fetch all the needed information from the GitHub’s releases page of the official repository, presenting the user with a wide variety of choices regarding which specific release to use and which asset (font) to download. Once the user has made their choice, Gleamfonts will download the corresponding ZIP file and ask the user which specific variant of the font to install (this is due to the fact that Termux does not support multiple variants, only a single ttf file can be installed).

Gleamfonts will then extract that variant of the chosen font into a temporary folder and ask the user if they trust Gleamfonts enough to replace the default Termux font with the newly downloaded one. Should the user refuse, Gleamfonts will exit right after printing the local path where the file can be found.

Translations

Gleamfonts is actually translated in three different languages: English, French and Italian. By default, it will try to detect which language to use based on the value of the environment variable LANG. If you want to force a specific language, you can inject the environment variable at launch time:

LANG=it_IT.UTF-8 gleamfonts --help
istruzioni: gleamfonts [--delete-cache] [--no-cache] [--help] [--version]
  --no-cache recupera tutti i dati da GitHub, ignorando la cache
  --delete-cache rimuove la cache esistente prima
  --help mostra questa pagina di aiuto ed esci
  --version mostra la versione del software ed esci

If you want to add a translation for your language, feel free to submit a pull request, you just need to add your language under the priv folder, in a file named following the convention of the UNIX locale (for example: de_DE.json for the German translation)

Contributions

All contributions are of course welcome, this is a hobby project and I think it is simple enough to be used a starting point for learning Gleam. There are quite some unit tests which should cover most of the codebase.