Skip to content

Commit

Permalink
move subset.py and add script to create DejaVuDisplay
Browse files Browse the repository at this point in the history
  • Loading branch information
zblz committed Dec 4, 2015
1 parent 258c4b8 commit d540f43
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 13 deletions.
Binary file modified lib/matplotlib/mpl-data/fonts/ttf/DejaVuSansDisplay.ttf
Binary file not shown.
Binary file modified lib/matplotlib/mpl-data/fonts/ttf/DejaVuSerifDisplay.ttf
Binary file not shown.
29 changes: 29 additions & 0 deletions tools/create_DejaVuDisplay.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/bin/bash

# Subsetting DejaVu fonts to create a display-math-only font

# The DejaVu fonts include math display variants outside of the unicode range,
# and it is currently hard to access them from matploltib. The subset.py script
# in `tools` has been modified to move the math display variants found in DejaVu
# fonts into a new TTF font with these variants in the unicode range.

# This bash script calls the subset.py scripts with the appropriate options to
# generate the new font files `DejaVuSansDisplay.ttf` and
# `DejaVuSerifDisplay.ttf`:

mpldir=$(dirname $0)/../

# test that fontforge is installed
python -c 'import fontforge' 2> /dev/null
if [ $? != 0 ]; then
echo "The python installation at $(which python) does not have fontforge"
echo "installed. Please install it before using subset.py."
exit 1
fi

FONTDIR=$mpldir/lib/matplotlib/mpl-data/fonts/ttf/

python $mpldir/tools/subset.py --move-display --subset=dejavu-ext $FONTDIR/DejaVuSans.ttf \
$FONTDIR/DejaVuSansDisplay.ttf
python $mpldir/tools/subset.py --move-display --subset=dejavu-ext $FONTDIR/DejaVuSerif.ttf \
$FONTDIR/DejaVuSerifDisplay.ttf
15 changes: 2 additions & 13 deletions lib/matplotlib/mpl-data/fonts/ttf/subset.py → tools/subset.py
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/python
#!/usr/bin/env python
#
# Copyright 2010-2012, Google Inc.
# Author: Mikhail Kashkin (mkashkin@gmail.com)
Expand Down Expand Up @@ -117,11 +117,11 @@ def subset_font_raw(font_in, font_out, unicodes, opts):
print("Clear()", file=pe)

if '--move-display' in opts:
print("Moving display glyphs into unicode ranges...")
font.familyname += " Display"
font.fullname += " Display"
font.fontname += "Display"
font.appendSFNTName('English (US)', 'Family', font.familyname)
font.appendSFNTName('English (US)', 'UniqueID', font.familyname)
font.appendSFNTName('English (US)', 16, font.familyname)
font.appendSFNTName('English (US)', 17, 'Display')
font.appendSFNTName('English (US)', 'Fullname', font.fullname)
Expand All @@ -135,17 +135,6 @@ def subset_font_raw(font_in, font_out, unicodes, opts):
newgl = glname.replace('.display','')
font.selection.select(newgl)
font.paste()
print(font[newgl].glyphname)
# print(newgl)
# if newgl.startswith('uni'):
# newgl = int(newgl[3:], base=16)
# else:
# newgl = fontforge.unicodeFromName(newgl)

# new = font.createChar(newgl)
# new = font[glname]
# print(new)
# font[glname.replace('.display','')] = font[glname]
font.selection.select(glname)
font.cut()

Expand Down

0 comments on commit d540f43

Please sign in to comment.