New argument for writeUFO: doHints if the glyph hints need to be exported. Default set to False. New argument for readUFO: doHints: if the hints need to be imported. Defaults set to True. font._supportHints is set to True so at least internally hints are supported.
git-svn-id: http://svn.robofab.com/trunk@52 b5fa9d6c-a76f-4ffd-b3cb-f825fc41095c
This commit is contained in:
parent
47e7af1af8
commit
92f1b1c979
@ -238,6 +238,7 @@ class PostScriptGlyphHintValues(BasePostScriptGlyphHintValues):
|
|||||||
|
|
||||||
def copy(self):
|
def copy(self):
|
||||||
from robofab.objects.objectsRF import PostScriptGlyphHintValues as _PostScriptGlyphHintValues
|
from robofab.objects.objectsRF import PostScriptGlyphHintValues as _PostScriptGlyphHintValues
|
||||||
|
print "FL copy", self.asDict()
|
||||||
return _PostScriptGlyphHintValues(data=self.asDict())
|
return _PostScriptGlyphHintValues(data=self.asDict())
|
||||||
|
|
||||||
def _hintObjectsToList(self, item):
|
def _hintObjectsToList(self, item):
|
||||||
@ -271,6 +272,9 @@ class PostScriptGlyphHintValues(BasePostScriptGlyphHintValues):
|
|||||||
# 2 = vertical hints and links
|
# 2 = vertical hints and links
|
||||||
# 3 = all hints and links
|
# 3 = all hints and links
|
||||||
self._object.RemoveHints(2)
|
self._object.RemoveHints(2)
|
||||||
|
if values is None:
|
||||||
|
# just clearing it then
|
||||||
|
return
|
||||||
values.sort()
|
values.sort()
|
||||||
for hint in self._listToHintObjects(values):
|
for hint in self._listToHintObjects(values):
|
||||||
self._object.vhints.append(hint)
|
self._object.vhints.append(hint)
|
||||||
@ -283,6 +287,9 @@ class PostScriptGlyphHintValues(BasePostScriptGlyphHintValues):
|
|||||||
# 2 = vertical hints and links
|
# 2 = vertical hints and links
|
||||||
# 3 = all hints and links
|
# 3 = all hints and links
|
||||||
self._object.RemoveHints(1)
|
self._object.RemoveHints(1)
|
||||||
|
if values is None:
|
||||||
|
# just clearing it then
|
||||||
|
return
|
||||||
values.sort()
|
values.sort()
|
||||||
for hint in self._listToHintObjects(values):
|
for hint in self._listToHintObjects(values):
|
||||||
self._object.hhints.append(hint)
|
self._object.hhints.append(hint)
|
||||||
@ -367,10 +374,10 @@ def _dictHintsToGlyph(glyph, aDict):
|
|||||||
##
|
##
|
||||||
if aDict.has_key('hHints'):
|
if aDict.has_key('hHints'):
|
||||||
for d in aDict['hHints']:
|
for d in aDict['hHints']:
|
||||||
glyph.hhints.append(Hint(d['position'], d['width']))
|
glyph.hhints.append(Hint(d[0], d[1]))
|
||||||
if aDict.has_key('vHints'):
|
if aDict.has_key('vHints'):
|
||||||
for d in aDict['vHints']:
|
for d in aDict['vHints']:
|
||||||
glyph.vhints.append(Hint(d['position'], d['width']))
|
glyph.vhints.append(Hint(d[0], d[1]))
|
||||||
##
|
##
|
||||||
## horizontal and vertical links
|
## horizontal and vertical links
|
||||||
##
|
##
|
||||||
@ -524,7 +531,7 @@ class RFont(BaseFont):
|
|||||||
#raise RoboFabError, "RFont: there's nothing to wrap!?"
|
#raise RoboFabError, "RFont: there's nothing to wrap!?"
|
||||||
self._object = font
|
self._object = font
|
||||||
self._lib = {}
|
self._lib = {}
|
||||||
self._supportHints = False
|
self._supportHints = True
|
||||||
|
|
||||||
def keys(self):
|
def keys(self):
|
||||||
keys = {}
|
keys = {}
|
||||||
@ -1006,8 +1013,7 @@ class RFont(BaseFont):
|
|||||||
fontLib["org.robofab.opentype.features"] = features
|
fontLib["org.robofab.opentype.features"] = features
|
||||||
fontLib["org.robofab.opentype.featureorder"] = order
|
fontLib["org.robofab.opentype.featureorder"] = order
|
||||||
|
|
||||||
def writeUFO(self, path=None, doProgress=False,
|
def writeUFO(self, path=None, doProgress=False, glyphNameToFileNameFunc=None, doHints=False):
|
||||||
glyphNameToFileNameFunc=None):
|
|
||||||
"""write a font to .ufo"""
|
"""write a font to .ufo"""
|
||||||
from robofab.ufoLib import makeUFOPath, UFOWriter
|
from robofab.ufoLib import makeUFOPath, UFOWriter
|
||||||
from robofab.interface.all.dialogs import ProgressBar
|
from robofab.interface.all.dialogs import ProgressBar
|
||||||
@ -1024,7 +1030,6 @@ class RFont(BaseFont):
|
|||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
path = makeUFOPath(self.path)
|
path = makeUFOPath(self.path)
|
||||||
doHints = self._supportHints
|
|
||||||
nonGlyphCount = 4
|
nonGlyphCount = 4
|
||||||
bar = None
|
bar = None
|
||||||
if doProgress:
|
if doProgress:
|
||||||
@ -1127,12 +1132,11 @@ class RFont(BaseFont):
|
|||||||
for tag, src in orderedFeatures:
|
for tag, src in orderedFeatures:
|
||||||
self.naked().features.append(Feature(tag, src))
|
self.naked().features.append(Feature(tag, src))
|
||||||
|
|
||||||
def readUFO(self, path, doProgress=False):
|
def readUFO(self, path, doProgress=False, doHints=True):
|
||||||
"""read a .ufo into the font"""
|
"""read a .ufo into the font"""
|
||||||
from robofab.ufoLib import UFOReader
|
from robofab.ufoLib import UFOReader
|
||||||
from robofab.pens.flPen import FLPointPen
|
from robofab.pens.flPen import FLPointPen
|
||||||
from robofab.interface.all.dialogs import ProgressBar
|
from robofab.interface.all.dialogs import ProgressBar
|
||||||
doHints = self._supportHints
|
|
||||||
nonGlyphCount = 4
|
nonGlyphCount = 4
|
||||||
bar = None
|
bar = None
|
||||||
u = UFOReader(path)
|
u = UFOReader(path)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user