#!/usr/bin/env ../utility/fontforge-interp.sh __doc__ = """ private_use.py fontforge -script private_use.py font_file_path... Output is HTML showing all the font's glyphs that are in Unicode "Private Use" areas. Also reports whether glyphs have references, or if they are ligatures. """ __author__ = "Stevan White " __date__ = "Dec 2009" __version__ = "$Revision: 1.2 $" import fontforge import sys preamble = """ Private Use area """ def makePreamble(): return preamble postamble=""" """ def print_private( fontPath ): font = fontforge.open( fontPath ) print '
' print '

Private Use Area in ' + font.fontname + '

' font.selection.select(("ranges",None),0xe000,0xf8ff) print '' for g in font.selection.byGlyphs: print '' print '
' print '%s%0.4x%s' %( "0x", g.encoding, "" ) print '' print '' + g.glyphname print '' if g.getPosSub( '*' ): print "is ligature" if g.references: print "has references" print '' print '
' print '
' sys.stdout.flush() def printentity( font, s ): if s == -1: print >> sys.stderr, 'Missing glyph: ' + a sys.stdout.write( ' ' ) else: sys.stdout.write( formatted_hex_value( s ) ) def formatted_hex_value( n ): return '%s%0.4x%s' %( "&#x", n, ";" ) args = sys.argv[1:] if len( args ) < 1 or len( args[0].strip() ) == 0: sys.exit( 0 ) print makePreamble() for font_name in args: print_private( font_name ) print postamble