diff options
author | Karl Berry <karl@freefriends.org> | 2012-05-06 23:27:09 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2012-05-06 23:27:09 +0000 |
commit | 8b30277ca27b1e7626d2611111006f4fa40b7ff8 (patch) | |
tree | 89d91907a7adeac20eaadff1dbce24e1c508b8b0 /Master/texmf-dist/doc/fonts/gnu-freefont/tools/script-menu/nameBySlot.py | |
parent | 6e142f4e4ff464728ac333fa9ab9e46ee6f97161 (diff) |
gnu-freefont 20120503 (6may12)
git-svn-id: svn://tug.org/texlive/trunk@26232 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/doc/fonts/gnu-freefont/tools/script-menu/nameBySlot.py')
-rwxr-xr-x | Master/texmf-dist/doc/fonts/gnu-freefont/tools/script-menu/nameBySlot.py | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/Master/texmf-dist/doc/fonts/gnu-freefont/tools/script-menu/nameBySlot.py b/Master/texmf-dist/doc/fonts/gnu-freefont/tools/script-menu/nameBySlot.py new file mode 100755 index 00000000000..1ab97411aa0 --- /dev/null +++ b/Master/texmf-dist/doc/fonts/gnu-freefont/tools/script-menu/nameBySlot.py @@ -0,0 +1,62 @@ +__license__ = """ +This file is part of Gnu FreeFont. + +Gnu FreeFont is free software: you can redistribute it and/or modify it under +the terms of the GNU General Public License as published by the Free Software +Foundation, either version 3 of the License, or (at your option) any later +version. + +Gnu FreeFont is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License along with +Gnu FreeFont. If not, see <http://www.gnu.org/licenses/>. +""" +__author__ = "Stevan White" +__email__ = "stevan.white@googlemail.com" +__copyright__ = "Copyright 2009, 2010, Stevan White" +__date__ = "$Date: 2010-09-14 13:02:02 $" +__version__ = "$Revision: 1.3 $" + +__doc__ = """ +For use from the FontForge Script Menu. +Add it to the Scripts Menu using the Preferences dialog. + +Sets the name and unicode values of the selected range of slots to the +encoding, that is + Name: uniXXXX + Unocode: u+XXXX +where XXXX is the n-digit hex value for the slot encoding. + +Careful! it changes the value whether it was previously set or not. + +Detailed info is printed to standard output (see by launching FontForge +from a console). +""" +import fontforge + +def explain_error_and_quit( e ): + if e: + print 'Error: ', e + exit( 1 ) + +try: + glyphs = fontforge.activeFont().selection.byGlyphs + for g in glyphs: + if g.encoding <= 0xFFFF: + newname = 'uni%0.4x' %( g.encoding ) + elif g.encoding <= 0xFFFFF: + newname = 'uni%0.5x' %( g.encoding ) + elif g.encoding <= 0xFFFFFF: + newname = 'uni%0.6x' %( g.encoding ) + elif g.encoding <= 0xFFFFFFF: + newname = 'uni%0.7x' %( g.encoding ) + elif g.encoding <= 0xFFFFFFFF: + newname = 'uni%0.8x' %( g.encoding ) + print "naming " + str( g.glyphname ) + ' as ' + newname + g.glyphname = newname + g.unicode = g.encoding +except ValueError, e: + explain_error_and_quit( e ) + |