Skip to content

Commit

Permalink
Generate a Bold Italic font variant.
Browse files Browse the repository at this point in the history
Needed by IntelliJ in order to recognize the font as being monospaced.
  • Loading branch information
Tblue committed May 3, 2016
1 parent 12cf817 commit 204f7eb
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 9 deletions.
8 changes: 4 additions & 4 deletions dist.sh
Original file line number Diff line number Diff line change
Expand Up @@ -64,26 +64,26 @@ mkdir -p other_systems
cd other_systems

if [ -z "$ZIP_ONLY" ]; then
rm -rf Normal Bold Italic
rm -rf Normal Bold Italic 'Bold Italic'
"${MYDIR}/mkttf.sh" "${FONTSRCDIR}" "${FONTVER}" "TerminusTTF" "Terminus (TTF)"
fi

bsdtar -c --format zip --gid 0 --uid 0 -f "../terminus-ttf-${FONTVER}.zip" \
-s "|^.*/terminus_ttf_distribution_license\.txt$|terminus-ttf-${FONTVER}/COPYING|" \
-s "|^.*/|terminus-ttf-${FONTVER}/|" \
{Normal,Bold,Italic}/*.ttf "${MYDIR}/terminus_ttf_distribution_license.txt"
{Normal,Bold,Italic,Bold\ Italic}/*.ttf "${MYDIR}/terminus_ttf_distribution_license.txt"


# 2. Generate fonts WITH Windows-specific fixes and zip them.
mkdir -p ../windows
cd ../windows

if [ -z "$ZIP_ONLY" ]; then
rm -rf Normal Bold Italic
rm -rf Normal Bold Italic 'Bold Italic'
"${MYDIR}/mkttf.sh" "${FONTSRCDIR}" "${FONTVER}" "TerminusTTFWindows" "Terminus (TTF) for Windows" -s
fi

bsdtar -c --format zip --gid 0 --uid 0 -f "../terminus-ttf-${FONTVER}-windows.zip" \
-s "|^.*/terminus_ttf_distribution_license\.txt$|terminus-ttf-${FONTVER}-windows/COPYING|" \
-s "|^.*/|terminus-ttf-${FONTVER}-windows/|" \
{Normal,Bold,Italic}/*.ttf "${MYDIR}/terminus_ttf_distribution_license.txt"
{Normal,Bold,Italic,Bold\ Italic}/*.ttf "${MYDIR}/terminus_ttf_distribution_license.txt"
10 changes: 8 additions & 2 deletions mkttf.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,11 @@

# fsSelection: Set bit 5 ("BOLD").
# macStyle: Set bit 0 (which presumably also means "BOLD").
'bold': (0x20, 0x1)
'bold': (0x20, 0x1),

# fsSelection: Set bits 0 ("ITALIC"), 9 ("OBLIQUE") and 5 ("BOLD").
# macStyle: Set bits 1 (italic) and 0 (bold).
'bolditalic': (0x221, 0x3),
}


Expand Down Expand Up @@ -231,6 +235,8 @@ def setFontAttrsFromArgs(font, args):
os2_weight = baseFont.weight.lower()
if os2_weight == "medium" and baseFont.fontname.lower().endswith("italic"):
os2_weight = "italic"
elif os2_weight == "bold" and baseFont.fontname.lower().endswith("italic"):
os2_weight = "bolditalic"

try:
styleMap, macStyle = _weightToStyleMap[os2_weight]
Expand Down Expand Up @@ -300,4 +306,4 @@ def setFontAttrsFromArgs(font, args):
print('Saving SFD file...')
baseFont.save(basename + '.sfd')

print('Done!')
print('Done!')
13 changes: 10 additions & 3 deletions mkttf.sh
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ if [ -n "$SRCDIR_TEST" -a ! -e "${SRCDIR}/${SRCDIR_TEST}" ]; then
fi

# -p to suppress errors.
mkdir -p Normal Bold Italic || error 4 'Could not create target directories.'
mkdir -p Normal Bold Italic 'Bold Italic' || error 4 'Could not create target directories.'

##################################################
# NOTE: The following code is Terminus-specific! #
Expand All @@ -136,10 +136,11 @@ echo 'Generating italic BDF files...'
for bdf in "$SRCDIR"/ter-u*n.bdf; do
BDF_BASENAME="$(basename "$bdf" n.bdf)"
mkitalic < "$bdf" > "${SRCDIR}/${BDF_BASENAME}i.bdf"
mkbolditalic < "$bdf" > "${SRCDIR}/${BDF_BASENAME}BI.bdf"
done

# Generate the TTF fonts.
for weight in Normal Bold Italic; do
for weight in Normal Bold Italic 'Bold Italic'; do
echo "Generating ${weight} font..."
cd "$weight"

Expand All @@ -149,13 +150,19 @@ for weight in Normal Bold Italic; do
unset WEIGHT_NAME
fi

if [ "${weight}" = 'Bold Italic' ]; then
FILE_SUFFIX=BI
else
FILE_SUFFIX=$(echo "$weight"|cut -b 1|tr '[:upper:]' '[:lower:]')
fi

"${MYDIR}/mkttf.py" \
-f "${NICEFONTNAME}" -n "${FONTNAME}${WEIGHT_NAME:+"-${WEIGHT_NAME}"}" \
-N "${NICEFONTNAME}${WEIGHT_NAME:+" ${WEIGHT_NAME}"}" \
-C "; Copyright (C) $(date '+%Y') Tilman Blumenbach; Licensed under the SIL Open Font License, Version 1.1" \
-A ' -a -1' -V "${FONTVER}" -O \
"$@" \
"$SRCDIR"/ter-u*"$(echo "$weight"|cut -b 1|tr '[:upper:]' '[:lower:]').bdf"
"$SRCDIR"/ter-u*"${FILE_SUFFIX}.bdf"

if [ $? -gt 0 ]; then
error 5 "Could not run mkttf.py!"
Expand Down

0 comments on commit 204f7eb

Please sign in to comment.