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

Skip to content

Commit 214e388

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

File tree

2 files changed

+30
-13
lines changed

2 files changed

+30
-13
lines changed

tools/create_DejaVuDisplay.sh

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
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'
18+
if [ $? != 0 ]; then
19+
echo "The fontforge python package is not installed but subset.py requires it"
20+
exit 1
21+
fi
22+
23+
FONTDIR=$mpldir/lib/matplotlib/mpl-data/fonts/ttf/
24+
25+
python $mpldir/tools/subset.py --move-display --subset=dejavu-ext $FONTDIR/DejaVuSans.ttf \
26+
$FONTDIR/DejaVuSansDisplay.ttf
27+
python $mpldir/tools/subset.py --move-display --subset=dejavu-ext $FONTDIR/DejaVuSerif.ttf \
28+
$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