Closed typesupply closed 1 year ago
Follow the method names here:
https://github.com/robotools/fontParts/blob/master/Lib/fontParts/base/base.py#L258
great idea!
Im not a fan to add full dict support for info, just info.update
def update(self, otherInfo):
"""
Update the info object with an other info object.
"""
if isinstance(otherInfo, self.__class__):
otherInfo = otherInfo.asDict()
if not isinstance(otherInfo, dict):
raise TypeError("Not a valid info object or dictionary")
selfData = self.asDict()
selfData.update(otherInfo)
for name, value in selfData.items():
setattr(self, name, value)
That sounds good to me. Though... that implementation requires the info object to have an asDict
method, right?
just guidelines must be ignored... in fontParts they arent part of an info object!
from fontTools.ufoLib import fontInfoAttributesVersion3
def asDict(self):
return {attr: getattr(self, attr) for attr in fontInfoAttributesVersion3 if attr != "guidelines"}
There needs to be an easier way to copy data from one info object to another.
https://robofontcommunity.slack.com/archives/C039PGQAZ71/p1668114026079679