Skip to content

Instantly share code, notes, and snippets.

@xero
Last active September 10, 2024 13:32
Show Gist options
  • Save xero/289b0e503986a33b3f83a5eb4bbb6280 to your computer and use it in GitHub Desktop.
Save xero/289b0e503986a33b3f83a5eb4bbb6280 to your computer and use it in GitHub Desktop.

Epsongelion nerd fonts build workflow

apt install fontforge python3-fontforge curl
curl -sL "https://github.com/ryanoasis/nerd-fonts/releases/latest/download/FontPatcher.zip" -o fontpatcher
cd fontpatcher

create and run the build script

#!/bin/sh

# get fonts
curl -sL "https://dl.dafont.com/dl/?f=linux_libertine" -o font.zip
unzip -p font.zip LinLibertine_R.ttf > libertine_r.ttf
unzip -p font.zip LinLibertine_aBL.ttf > libertine_bi.ttf
unzip -p font.zip LinLibertine_RB.ttf > libertine_b.ttf
unzip -p font.zip LinLibertine_RI.ttf > libertine_i.ttf
rm font.zip

# patch em
fontforge -script ../font-patcher ./libertine_r.ttf -c --name Epsongelion-Regular
fontforge -script ../font-patcher ./libertine_b.ttf -c --name Epsongelion-Bold
fontforge -script ../font-patcher ./libertine_i.ttf -c --name Epsongelion-Italic
fontforge -script ../font-patcher ./libertine_bi.ttf -c --name Epsongelion-BoldItalic

# encode em
R=$(base64 -i -w 0 Epsongelion-Regular.ttf)
B=$(base64 -i -w 0 Epsongelion-Regular.ttf)
I=$(base64 -i -w 0 Epsongelion-Regular.ttf)
BI=$(base64 -i -w 0 Epsongelion-Regular.ttf)

# generate the css
cat << X0 > Epsongelion.css
@font-face {
    font-family: "Epsongelion";
    font-style: normal;
    font-weight: 400;
    src: url(data:font/ttf;charset-utf-8;base64,${R})
}
@font-face {
    font-family: "Epsongelion";
    font-style: normal;
    font-weight: 700;
    src: url(data:font/ttf;charset-utf-8;base64,${B})
}
@font-face {
    font-family: "Epsongelion";
    font-style: italic;
    font-weight: 400;
    src: url(data:font/ttf;charset-utf-8;base64,${I})
}
@font-face {
    font-family: "Epsongelion";
    font-style: italic;
    font-weight: 700;
    src: url(data:font/ttf;charset-utf-8;base64,${BI})
}
X0
echo "Epsongelion.css generated"
This file has been truncated, but you can view the full file.
View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment