| 1 |
__license__ = """ |
| 2 |
This file is part of Gnu FreeFont. |
| 3 |
|
| 4 |
Gnu FreeFont is free software: you can redistribute it and/or modify it under |
| 5 |
the terms of the GNU General Public License as published by the Free Software |
| 6 |
Foundation, either version 3 of the License, or (at your option) any later |
| 7 |
version. |
| 8 |
|
| 9 |
Gnu FreeFont is distributed in the hope that it will be useful, but WITHOUT |
| 10 |
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| 11 |
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. |
| 12 |
|
| 13 |
You should have received a copy of the GNU General Public License along with |
| 14 |
Gnu FreeFont. If not, see <http://www.gnu.org/licenses/>. |
| 15 |
""" |
| 16 |
__author__ = "Stevan White" |
| 17 |
__email__ = "[email protected]" |
| 18 |
__copyright__ = "Copyright 2009, 2010, Stevan White" |
| 19 |
__date__ = "$Date: 2010-09-14 13:02:02 $" |
| 20 |
__version__ = "$Revision: 1.3 $" |
| 21 |
|
| 22 |
__doc__ = """ |
| 23 |
For use from the FontForge Script Menu. |
| 24 |
Add it to the Scripts Menu using the Preferences dialog. |
| 25 |
|
| 26 |
Sets the name and unicode values of the selected range of slots to |
| 27 |
the encoding, that is |
| 28 |
Name: uniXXXX |
| 29 |
Unocode: u+XXXX |
| 30 |
where XXXX is the 4-digit hex value for the slot encoding. |
| 31 |
|
| 32 |
Careful! it changes the falue whether it was previously set or not. |
| 33 |
|
| 34 |
Detailed info is printed to standard output (see by launching FontForge |
| 35 |
from a console). |
| 36 |
""" |
| 37 |
|
| 38 |
import fontforge |
| 39 |
|
| 40 |
def explain_error_and_quit( e ): |
| 41 |
if e: |
| 42 |
print 'Error: ', e |
| 43 |
exit( 1 ) |
| 44 |
|
| 45 |
try: |
| 46 |
glyphs = fontforge.activeFont().selection.byGlyphs |
| 47 |
for g in glyphs: |
| 48 |
newname = 'NameMe.%s' %( str( g.encoding ) ) |
| 49 |
print "naming " + str( g.glyphname ) + ' as ' + newname |
| 50 |
g.glyphname = newname |
| 51 |
g.unicode = -1 |
| 52 |
except ValueError, e: |
| 53 |
explain_error_and_quit( e ) |
| 54 |
|