Skip to content

Instantly share code, notes, and snippets.

@Lenchik
Forked from gramian/hack4tex
Created March 8, 2016 11:12
Show Gist options
  • Save Lenchik/fe2c53bbb253b78fff25 to your computer and use it in GitHub Desktop.
Save Lenchik/fe2c53bbb253b78fff25 to your computer and use it in GitHub Desktop.
A small script to use the hack truetype font in pdflatex
#!/bin/sh
# hack4tex 0.1
# Copyright (c) 2016 Christian Himpe
# released under BSD 2-Clause License ( opensource.org/licenses/BSD-2-Clause )
# based on Stephan Lehmke's answer to "How do I use TrueType Fonts with PDFTeX
# using otftotfm?" on tex.stackexchange.com/a/52902
#
# requires otftotfm which is part of lcdf-typetools
#
# copy tex4hack and Hack-*.ttf to some folder and run hack4tex
#
# copy t1hack.fd and Hack-*.ttf to document folder
#
# use in pdflatex with
# \pdfmapfile{hack.map}
# \renewcommand\ttdefault{Hack} % for example
otftotfm -a -e ec -fkern -fliga --verbose --vendor hack Hack-Regular.ttf T1--Hack--Regular &>> hack.log
otftotfm -a -e ec -fkern -fliga --verbose --vendor hack Hack-Bold.ttf T1--Hack--Bold &>> hack.log
otftotfm -a -e ec -fkern -fliga --verbose --vendor hack Hack-Italic.ttf T1--Hack--Italic &>> hack.log
otftotfm -a -e ec -fkern -fliga --verbose --vendor hack Hack-BoldItalic.ttf T1--Hack--BoldItalic &>> hack.log
echo "\ProvidesFile{t1hack.fd}
\DeclareFontFamily{T1}{Hack}{}
\DeclareFontShape{T1}{Hack}{m}{n}{
<-> T1--Hack--Regular
}{}
\DeclareFontShape{T1}{Hack}{b}{n}{
<-> T1--Hack--Bold
}{}
\DeclareFontShape{T1}{Hack}{m}{sl}{
<-> T1--Hack--Italic
}{}
\DeclareFontShape{T1}{Hack}{b}{sl}{
<-> T1--Hack--BoldItalic
}{}" > t1hack.fd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment