#!/usr/bin/env ../utility/fontforge-interp.sh from __future__ import print_function __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: 3916 $" import fontforge from sys import argv, exit, stdout, stderr preamble = """ Private Use area """ def makePreamble(): return preamble postamble=""" """ def print_private( fontPath ): font = fontforge.open( fontPath ) print( '
' % ( font.familyname ) ) 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( '
' ) stdout.flush() def printentity( font, s ): if s == -1: print( 'Missing glyph:', a ) stdout.write( ' ' ) else: stdout.write( formatted_hex_value( s ) ) def formatted_hex_value( n ): return '%s%0.4x%s' %( "&#x", n, ";" ) args = argv[1:] __usage = """Usage private_use.py font_file_name """ if len( args ) < 1 or len( args[0].strip() ) == 0: print( __usage, file=stderr ) exit( 1 ) print( makePreamble() ) for font_name in args: print_private( font_name ) print( postamble )