def init_from_filename(self, set_names=True): '''Initiate `hFont` object from ufo, get parent project, parse name parts.''' ufo_file = os.path.basename(self.ufo.path) self.file_name = os.path.splitext(ufo_file)[0] family_name, self.style_name = self.file_name.split('_') # get parent project self.project = hProject(family_name) # set font names if set_names: set_font_names(self.ufo, family_name, self.style_name) # get parameters from name, create dict try: name_parameters = self.style_name.split('-') parameters_order = self.project.libs['project']['parameters_order'] self.parameters = dict(zip(parameters_order, name_parameters)) # keep parameters dict empty except: # print 'there is no parameters lib for this font.\n' pass
def init_from_filename(self, set_names=True): """Initiate ``hFont`` object from ``RFont``, get parent project, parse name parts.""" ufo_file = os.path.basename(self.ufo.path) self.file_name = os.path.splitext(ufo_file)[0] try: # break file name into family- and style name family_name, self.style_name = self.file_name.split('_') # get parent project self.project = hProject(family_name) # set font names if set_names: set_font_names(self.ufo, family_name, self.style_name) # get parameters from name and store them into a dict try: name_parameters = self.style_name.split('-') parameters_order = self.project.libs['project']['parameters_order'] self.parameters = dict(zip(parameters_order, name_parameters)) # keep parameters dict empty except: # print 'Error: no parameters lib for this font.\n' pass except: print 'Error: font name is not in the format family_style'
def __init__(self, project_name): self.project = hProject(project_name) self.import_project_parameters() self.build()