8000 move subset.py and add script to create DejaVuDisplay · notmatthancock/matplotlib@d540f43 · GitHub
[go: up one dir, main page]

Skip to content

Commit d540f43

Browse files
committed
move subset.py and add script to create DejaVuDisplay
1 parent 258c4b8 commit d540f43

File tree

4 files changed

+31
-13
lines changed

4 files changed

+31
-13
lines changed
Binary file not shown.
Binary file not shown.

tools/create_DejaVuDisplay.sh

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#!/bin/bash
2+
3+
# Subsetting DejaVu fonts to create a display-math-only font
4+
5+
# The DejaVu fonts include math display variants outside of the unicode range,
6+
# and it is currently hard to access them from matploltib. The subset.py script
7+
# in `tools` has been modified to move the math display variants found in DejaVu
8+
# fonts into a new TTF font with these variants in the unicode range.
9+
10+
# This bash script calls the subset.py scripts with the appropriate options to
11+
# generate the new font files `DejaVuSansDisplay.ttf` and
12+
# `DejaVuSerifDisplay.ttf`:
13+
14+
mpldir=$(dirname $0)/../
15+
16+
# test that fontforge is installed
17+
python -c 'import fontforge' 2> /dev/null
18+
if [ $? != 0 ]; then
19+
echo "The python installation at $(which python) does not have fontforge"
20+
echo "installed. Please install it before using subset.py."
21+
exit 1
22+
fi
23+
24+
FONTDIR=$mpldir/lib/matplotlib/mpl-data/fonts/ttf/
25+
26+
python $mpldir/tools/subset.py --move-display --subset=dejavu-ext $FONTDIR/DejaVuSans.ttf \
27+
$FONTDIR/DejaVuSansDisplay.ttf
28+
python $mpldir/tools/subset.py --move-display --subset=dejavu-ext $FONTDIR/DejaVuSerif.ttf \
29+
$FONTDIR/DejaVuSerifDisplay.ttf

lib/matplotlib/mpl-data/fonts/ttf/subset.py renamed to tools/subset.py

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/python
1+
#!/usr/bin/env python
22
#
33
# Copyright 2010-2012, Google Inc.
44
# Author: Mikhail Kashkin (mkashkin@gmail.com)
@@ -117,11 +117,11 @@ def subset_font_raw(font_in, font_out, unicodes, opts):
117117
print("Clear()", file=pe)
118118

119119
if '--move-display' in opts:
120+
print("Moving display glyphs into unicode ranges...")
120121
font.familyname += " Display"
121122
font.fullname += " Display"
122123
font.fontname += "Display"
123124
font.appendSFNTName('English (US)', 'Family', font.familyname)
124-
font.appendSFNTName('English (US)', 'UniqueID', font.familyname)
125125
font.appendSFNTName('English (US)', 16, font.familyname)
126126
font.appendSFNTName('English (US)', 17, 'Display')
127127
font.appendSFNTName('English (US)', 'Fullname', font.fullname)
@@ -135,17 +135,6 @@ def subset_font_raw(font_in, font_out, unicodes, opts):
135135
newgl = glname.replace('.display','')
136136
font.selection.select(newgl)
137137
font.paste()
138-
print(font[newgl].glyphname)
139-
# print(newgl)
140-
# if newgl.startswith('uni'):
141-
# newgl = int(newgl[3:], base=16)
142-
# else:
143-
# newgl = fontforge.unicodeFromName(newgl)
144-
145-
# new = font.createChar(newgl)
146-
# new = font[glname]
147-
# print(new)
148-
# font[glname.replace('.display','')] = font[glname]
149138
font.selection.select(glname)
150139
font.cut()
151140

0 commit comments

Comments
 (0)
0