def to_ufo_glyph(self, ufo_glyph, layer, glyph):
ufo_glyph.unicodes = [int(uval, <NUM_LIT:16>) for uval in glyph.unicodes]<EOL>note = glyph.note<EOL>if note is not None:<EOL><INDENT>ufo_glyph.note = note<EOL><DEDENT>last_change = glyph.lastChange<EOL>if last_change is not None:<EOL><INDENT>ufo_glyph.lib[GLYPHLIB_PREFIX + "<STR_LIT>"] = to_ufo_time(last_change)<EOL><DEDENT>color_index = glyph.color<EOL>if color_index is not None:<EOL><INDENT>if (<EOL>isinstance(color_index, list)<EOL>and len(color_index) == <NUM_LIT:4><EOL>and all(<NUM_LIT:0> <= v < <NUM_LIT> for v in color_index)<EOL>):<EOL><INDENT>ufo_glyph.markColor = "<STR_LIT:U+002C>".join(<EOL>"<STR_LIT>".format(v / <NUM_LIT:255>) for v in color_index<EOL>)<EOL><DEDENT>elif isinstance(color_index, int) and color_index in range(len(GLYPHS_COLORS)):<EOL><INDENT>ufo_glyph.markColor = GLYPHS_COLORS[color_index]<EOL><DEDENT>else:<EOL><INDENT>logger.warning(<EOL>"<STR_LIT>".format(<EOL>glyph.name, layer.name, color_index<EOL>)<EOL>)<EOL><DEDENT><DEDENT>export = glyph.export<EOL>if not export:<EOL><INDENT>if "<STR_LIT>" not in self._designspace.lib:<EOL><INDENT>self._designspace.lib["<STR_LIT>"] = []<EOL><DEDENT>self._designspace.lib["<STR_LIT>"].append(glyph.name)<EOL><DEDENT>glyphinfo = glyphsLib.glyphdata.get_glyph(ufo_glyph.name)<EOL>production_name = glyph.production or glyphinfo.production_name<EOL>if production_name != ufo_glyph.name:<EOL><INDENT>postscriptNamesKey = PUBLIC_PREFIX + "<STR_LIT>"<EOL>if postscriptNamesKey not in ufo_glyph.font.lib:<EOL><INDENT>ufo_glyph.font.lib[postscriptNamesKey] = dict()<EOL><DEDENT>ufo_glyph.font.lib[postscriptNamesKey][ufo_glyph.name] = production_name<EOL><DEDENT>for key in ["<STR_LIT>", "<STR_LIT>", "<STR_LIT>"]:<EOL><INDENT>value = getattr(layer, key, None)<EOL>if value:<EOL><INDENT>ufo_glyph.lib[GLYPHLIB_PREFIX + "<STR_LIT>" + key] = value<EOL><DEDENT>value = getattr(glyph, key, None)<EOL>if value:<EOL><INDENT>ufo_glyph.lib[GLYPHLIB_PREFIX + "<STR_LIT>" + key] = value<EOL><DEDENT><DEDENT>if glyph.script is not None:<EOL><INDENT>ufo_glyph.lib[SCRIPT_LIB_KEY] = glyph.script<EOL><DEDENT>category = glyph.category<EOL>if category is None:<EOL><INDENT>category = glyphinfo.category<EOL><DEDENT>else:<EOL><INDENT>ufo_glyph.lib[GLYPHLIB_PREFIX + "<STR_LIT>"] = category<EOL><DEDENT>subCategory = glyph.subCategory<EOL>if subCategory is None:<EOL><INDENT>subCategory = glyphinfo.subCategory<EOL><DEDENT>else:<EOL><INDENT>ufo_glyph.lib[GLYPHLIB_PREFIX + "<STR_LIT>"] = subCategory<EOL><DEDENT>width = layer.width<EOL>if width is None:<EOL><INDENT>pass<EOL><DEDENT>elif category == "<STR_LIT>" and subCategory == "<STR_LIT>" and width > <NUM_LIT:0>:<EOL><INDENT>ufo_glyph.lib[ORIGINAL_WIDTH_KEY] = width<EOL>ufo_glyph.width = <NUM_LIT:0><EOL><DEDENT>else:<EOL><INDENT>ufo_glyph.width = width<EOL><DEDENT>self.to_ufo_background_image(ufo_glyph, layer)<EOL>self.to_ufo_guidelines(ufo_glyph, layer)<EOL>self.to_ufo_glyph_background(ufo_glyph, layer)<EOL>self.to_ufo_annotations(ufo_glyph, layer)<EOL>self.to_ufo_hints(ufo_glyph, layer)<EOL>self.to_ufo_glyph_user_data(ufo_glyph.font, glyph)<EOL>self.to_ufo_layer_user_data(ufo_glyph, layer)<EOL>self.to_ufo_smart_component_axes(ufo_glyph, glyph)<EOL>self.to_ufo_paths(ufo_glyph, layer)<EOL>self.to_ufo_components(ufo_glyph, layer)<EOL>self.to_ufo_glyph_anchors(ufo_glyph, layer.anchors)<EOL>
Add .glyphs metadata, paths, components, and anchors to a glyph.