├── LICENSE ├── README.md └── hack-linux-installer.sh /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 Source Foundry 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## Hack font installer for Linux 2 | 3 | [![Build Status](https://semaphoreci.com/api/v1/sourcefoundry/hack-linux-installer/branches/master/badge.svg)](https://semaphoreci.com/sourcefoundry/hack-linux-installer) 4 | 5 | ### An install and upgrade script for the Hack typeface on the Linux platform 6 | 7 | The [`hack-linux-installer.sh` shell script](https://github.com/source-foundry/hack-linux-installer/blob/master/hack-linux-installer.sh) installs fonts from the [Hack typeface repository](https://github.com/source-foundry/Hack) at a requested release version number on the Linux platform. This script can be used for initial font installs and upgrades to new versions (or downgrades if ever necessary). 8 | 9 | #### Download and modify permissions 10 | 11 | ``` 12 | $ curl -L -O https://raw.githubusercontent.com/source-foundry/hack-linux-installer/master/hack-linux-installer.sh 13 | $ chmod +x hack-linux-installer.sh 14 | ``` 15 | 16 | #### Usage 17 | 18 | ``` 19 | $ ./hack-linux-installer.sh [VERSION] 20 | ``` 21 | 22 | Define the version number with the format `vX.XXX`. You must use a lowercase `v` followed by the version number string that is used in the repository releases. 23 | 24 | For example, install Hack v3.003 with the following command: 25 | 26 | ``` 27 | $ ./hack-linux-installer.sh v3.003 28 | ``` 29 | 30 | Alternatively, you can use the installer to install the latest version like so: 31 | 32 | ``` 33 | $ ./hack-linux-installer.sh latest 34 | ``` 35 | 36 | #### What it does 37 | 38 | - The release archive is pulled from the repository release 39 | - The release archive is unpacked 40 | - The fonts are installed on the path `$HOME/.local/share/fonts` 41 | - The font cache is cleared and regenerated 42 | - `fc-list | grep "Hack"` is executed to display the installed font paths. You should see expected install filepaths with this command. 43 | 44 | -------------------------------------------------------------------------------- /hack-linux-installer.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # ///////////////////////////////////////////////////////////////// 4 | # 5 | # hack-linux-installer.sh 6 | # A shell script that installs the Hack fonts from repository 7 | # releases by release version number 8 | # 9 | # Copyright 2018 Christopher Simpkins 10 | # MIT License 11 | # 12 | # Usage: ./hack-linux-installer.sh [VERSION] 13 | # Format the version number as vX.XXX or "latest" 14 | # 15 | # ///////////////////////////////////////////////////////////////// 16 | 17 | HACK_INSTALL_PATH="$HOME/.local/share/fonts" 18 | 19 | get_latest_release() { 20 | curl -s "https://api.github.com/repos/source-foundry/Hack/releases/latest" | 21 | grep '"tag_name":' | 22 | sed -E 's/.*"([^"]+)".*/\1/' 23 | } 24 | 25 | if [ $# -ne 1 ]; then 26 | echo "Please include a version number argument formatted as vX.XXX (or \"latest\")" 27 | exit 1 28 | fi 29 | 30 | if [ "$1" = "--help" ]; then 31 | echo "Usage: ./hack-linux-installer [VERSION]" 32 | echo "Format [VERSION] as vX.XXX for the desired release version of the fonts. Or just set it to \"latest\"." 33 | exit 0 34 | fi 35 | 36 | if [ ! -d "$HACK_INSTALL_PATH" ]; then 37 | echo "Unable to detect the install directory path '$HACK_INSTALL_PATH'. Please create this path and execute the script again." 38 | exit 1 39 | fi 40 | 41 | HACK_VERSION="${1:-latest}" 42 | if [ "$HACK_VERSION" = "latest" ] 43 | then 44 | HACK_VERSION="$(get_latest_release)" 45 | fi 46 | HACK_DL_URL="https://github.com/source-foundry/Hack/releases/download/$HACK_VERSION/Hack-$HACK_VERSION-ttf.tar.gz" 47 | HACK_ARCHIVE_PATH="Hack-$HACK_VERSION-ttf.tar.gz" 48 | 49 | # pull user requested fonts from the Hack repository releases & unpack 50 | echo " " 51 | echo "Pulling Hack $HACK_VERSION fonts from the Github repository release..." 52 | curl -L -O "$HACK_DL_URL" 53 | 54 | echo " " 55 | echo "Unpacking the font files..." 56 | if [ -f "$HACK_ARCHIVE_PATH" ]; then 57 | tar -xzvf "$HACK_ARCHIVE_PATH" 58 | else 59 | echo "Unable to find the pulled archive file. Install failed." 60 | exit 1 61 | fi 62 | 63 | # install 64 | if [ -d "ttf" ]; then 65 | echo " " 66 | echo "Installing the Hack fonts..." 67 | # clean up archive file 68 | rm "$HACK_ARCHIVE_PATH" 69 | 70 | # move fonts to install directory 71 | echo "Installing Hack-Regular.ttf on path $HACK_INSTALL_PATH/Hack-Regular.ttf" 72 | mv ttf/Hack-Regular.ttf "$HACK_INSTALL_PATH/Hack-Regular.ttf" 73 | 74 | echo "Installing Hack-Italic.ttf on path $HACK_INSTALL_PATH/Hack-Italic.ttf" 75 | mv ttf/Hack-Italic.ttf "$HACK_INSTALL_PATH/Hack-Italic.ttf" 76 | 77 | echo "Installing Hack-Bold.ttf on path $HACK_INSTALL_PATH/Hack-Bold.ttf" 78 | mv ttf/Hack-Bold.ttf "$HACK_INSTALL_PATH/Hack-Bold.ttf" 79 | 80 | echo "Installing Hack-BoldItalic.ttf on path $HACK_INSTALL_PATH/Hack-BoldItalic.ttf" 81 | mv ttf/Hack-BoldItalic.ttf "$HACK_INSTALL_PATH/Hack-BoldItalic.ttf" 82 | 83 | echo " " 84 | echo "Cleaning up..." 85 | rm -rf ttf 86 | 87 | # clear and regenerate font cache 88 | echo " " 89 | echo "Clearing and regenerating the font cache. You will see a stream of text as this occurs..." 90 | echo " " 91 | fc-cache -f -v 92 | 93 | echo " " 94 | echo "Testing. You should see the expected install filepaths in the output below..." 95 | fc-list | grep "Hack" 96 | 97 | echo " " 98 | echo "Install of Hack $HACK_VERSION complete." 99 | exit 0 100 | else 101 | echo "Unable to identify the unpacked font directory. Install failed." 102 | exit 1 103 | fi 104 | --------------------------------------------------------------------------------