|
Packit |
f0e7df |
#!/usr/bin/env ../utility/fontforge-interp.sh
|
|
Packit |
f0e7df |
__license__ = """
|
|
Packit |
f0e7df |
This file is part of Gnu FreeFont.
|
|
Packit |
f0e7df |
|
|
Packit |
f0e7df |
Gnu FreeFont is free software: you can redistribute it and/or modify it under
|
|
Packit |
f0e7df |
the terms of the GNU General Public License as published by the Free Software
|
|
Packit |
f0e7df |
Foundation, either version 3 of the License, or (at your option) any later
|
|
Packit |
f0e7df |
version.
|
|
Packit |
f0e7df |
|
|
Packit |
f0e7df |
Gnu FreeFont is distributed in the hope that it will be useful, but WITHOUT
|
|
Packit |
f0e7df |
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
|
Packit |
f0e7df |
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
|
Packit |
f0e7df |
|
|
Packit |
f0e7df |
You should have received a copy of the GNU General Public License along with
|
|
Packit |
f0e7df |
Gnu FreeFont. If not, see <http://www.gnu.org/licenses/>.
|
|
Packit |
f0e7df |
"""
|
|
Packit |
f0e7df |
__author__ = "Stevan White"
|
|
Packit |
f0e7df |
__email__ = "stevan.white@googlemail.com"
|
|
Packit |
f0e7df |
__copyright__ = "Copyright 2009, 2010, Stevan White"
|
|
Packit |
f0e7df |
__date__ = "$Date: 2011-11-03 01:51:05 +0100 (Thu, 03 Nov 2011) $"
|
|
Packit |
f0e7df |
__version__ = "$Revision: 1864 $"
|
|
Packit |
f0e7df |
|
|
Packit |
f0e7df |
__doc__ = """
|
|
Packit |
f0e7df |
Diagnostic tool that checks that fonts are really monospace.
|
|
Packit |
f0e7df |
|
|
Packit |
f0e7df |
Allows characters to have 0 width though (note this is controversial)
|
|
Packit |
f0e7df |
|
|
Packit |
f0e7df |
Also: in order for box-drawing characters to connect properly, it is
|
|
Packit |
f0e7df |
important that the glyphs all lie between 800 and -200EM vertically.
|
|
Packit |
f0e7df |
"""
|
|
Packit |
f0e7df |
|
|
Packit |
f0e7df |
import fontforge
|
|
Packit |
f0e7df |
import sys
|
|
Packit |
f0e7df |
|
|
Packit |
f0e7df |
problem = False
|
|
Packit |
f0e7df |
|
|
Packit |
f0e7df |
def ismonomono( fontfilename ):
|
|
Packit |
f0e7df |
print "Checking character bounding boxes: " + fontfilename
|
|
Packit |
f0e7df |
font = fontforge.open( fontfilename )
|
|
Packit |
f0e7df |
|
|
Packit |
f0e7df |
g = font.selection.all()
|
|
Packit |
f0e7df |
g = font.selection.byGlyphs
|
|
Packit |
f0e7df |
|
|
Packit |
f0e7df |
nonzero = 0
|
|
Packit |
f0e7df |
|
|
Packit |
f0e7df |
for e in g:
|
|
Packit |
f0e7df |
if nonzero == 0:
|
|
Packit |
f0e7df |
if e.width > 0:
|
|
Packit |
f0e7df |
nonzero = e.width
|
|
Packit |
f0e7df |
else:
|
|
Packit |
f0e7df |
if e.width > 0 and e.width != nonzero:
|
|
Packit |
f0e7df |
print ' ' + e.glyphname \
|
|
Packit |
f0e7df |
+ '(' + str( e.encoding ) \
|
|
Packit |
f0e7df |
+ ') width is ' + str( e.width ) \
|
|
Packit |
f0e7df |
+ ' not ' + str( nonzero )
|
|
Packit |
f0e7df |
problem = True
|
|
Packit |
f0e7df |
|
|
Packit |
f0e7df |
( xmin, ymin, xmax, ymax ) = e.boundingBox()
|
|
Packit |
f0e7df |
if ymin < -200 or ymax > 800:
|
|
Packit |
f0e7df |
print ' ' + e.glyphname + ' goes between heights ' \
|
|
Packit |
f0e7df |
+ str( ymin ) + ' and ' + str( ymax )
|
|
Packit |
f0e7df |
"""
|
|
Packit |
f0e7df |
For FontForge handling of TrueType/OpenType magic characters:
|
|
Packit |
f0e7df |
1) check that 0x0000 0x0001, 0x000D exist and have names
|
|
Packit |
f0e7df |
.notdef, .null, nonmarkingreturn
|
|
Packit |
f0e7df |
2) check that 0x0000 and 0x000D are width 600, and
|
|
Packit |
f0e7df |
0x0001 has no glyph and is width 0
|
|
Packit |
f0e7df |
|
|
Packit |
f0e7df |
Othewise complain that FontForge may not treat it right.
|
|
Packit |
f0e7df |
"""
|
|
Packit |
f0e7df |
if not font[0x0000] \
|
|
Packit |
f0e7df |
or font[0x0000].glyphname != '.notdef' \
|
|
Packit |
f0e7df |
or font[0x0000].width != nonzero:
|
|
Packit |
f0e7df |
print 'Should be full-width ".notdef" glyph at 0x0000.'
|
|
Packit |
f0e7df |
if not font[0x0001] \
|
|
Packit |
f0e7df |
or font[0x0001].glyphname != '.null' \
|
|
Packit |
f0e7df |
or font[0x0001].width != 0:
|
|
Packit |
f0e7df |
print 'Should be zero-width ".null" glyph at 0x0001.'
|
|
Packit |
f0e7df |
if not font[0x000D] \
|
|
Packit |
f0e7df |
or font[0x000D].glyphname != 'nonmarkingreturn' \
|
|
Packit |
f0e7df |
or font[0x000D].width != nonzero:
|
|
Packit |
f0e7df |
print 'Should be full-width "nonmarkingreturn" glyph at 0x000D.'
|
|
Packit |
f0e7df |
|
|
Packit |
f0e7df |
scriptname = sys.argv[0];
|
|
Packit |
f0e7df |
argc = len( sys.argv )
|
|
Packit |
f0e7df |
|
|
Packit |
f0e7df |
if argc > 1:
|
|
Packit |
f0e7df |
for i in range( 1, argc ):
|
|
Packit |
f0e7df |
ismonomono( sys.argv[i] )
|
|
Packit |
f0e7df |
|
|
Packit |
f0e7df |
if problem:
|
|
Packit |
f0e7df |
sys.exit( 1 )
|
|
Packit |
f0e7df |
else:
|
|
Packit |
f0e7df |
sys.exit( 0 )
|