|
From: Deron M. <der...@gm...> - 2012-08-26 06:44:26
|
I finally found a sequence which works; it effectively removes just
one of the encoding slots—it is not particularly straight-forward or
obvious. Also I don't know enough to make sure this is entirely
correct; such that any other related, like kerning pairs, if they
exist, are maintained.
As an illustration, again using the "broken"
LiberationSerif-Regular.sfd (version 2.00.0)... which has a single
glyph object for both U+F001 and U+FB01. Note I had to use the
removeGlyph() function as the selection + cut() method doesn't seem to
work in this case.
$ python
>>> import fontforge
>>> font=fontforge.open('LiberationSerif-Regular.sfd')
>>> g, h = font[0xF001], font[0xFB01]
>>> #### Test if it is the same glyph object
>>> g is h
True
>>> ### Copy and delete glyph
>>> font.selection.select( g )
<fontforge.selection object at 0x7f82bca1a110>
>>> font.copy()
<fontforge.font object at 0x7f82b5ce9630>
>>> font.removeGlyph( g )
<fontforge.font object at 0x7f82b5ce9630>
>>> del g, h
>>> ### Check that glyph is now gone
>>> 0xFB01 in font
False
>>> 0xF001 in font
False
>>> ### Reinsert glyph back at ONE of the encodings
>>> font.selection.select( ('unicode',), 0xFB01 )
<fontforge.selection object at 0x7f82bca1a110>
>>> font.paste()
<fontforge.font object at 0x7f82b5ce9630>
>>> ### Now check that glyph exists and only has one Unicode mapping
>>> 0xFB01 in font
True
>>> 0xF001 in font
False
>>> g = font[ 0xFB01 ]
>>> print '%X' % g.unicode
FB01
>>> print repr( g.altuni )
None
--
Deron Meranda
http://deron.meranda.us/
|