def _to_ufo_features(self, master, ufo):
<EOL>original = master.userData[ORIGINAL_FEATURE_CODE_KEY]<EOL>if original is not None:<EOL><INDENT>ufo.features.text = original<EOL>return<EOL><DEDENT>prefixes = []<EOL>for prefix in self.font.featurePrefixes:<EOL><INDENT>strings = []<EOL>if prefix.name != ANONYMOUS_FEATURE_PREFIX_NAME:<EOL><INDENT>strings.append("<STR_LIT>" % prefix.name)<EOL><DEDENT>strings.append(autostr(prefix.automatic))<EOL>strings.append(prefix.code)<EOL>prefixes.append("<STR_LIT>".join(strings))<EOL><DEDENT>prefix_str = "<STR_LIT>".join(prefixes)<EOL>class_defs = []<EOL>for class_ in self.font.classes:<EOL><INDENT>prefix = "<STR_LIT:@>" if not class_.name.startswith("<STR_LIT:@>") else "<STR_LIT>"<EOL>name = prefix + class_.name<EOL>class_defs.append(<EOL>"<STR_LIT>".format(autostr(class_.automatic), name, class_.code)<EOL>)<EOL><DEDENT>class_str = "<STR_LIT>".join(class_defs)<EOL>feature_defs = []<EOL>for feature in self.font.features:<EOL><INDENT>code = feature.code<EOL>lines = ["<STR_LIT>" % feature.name]<EOL>if feature.notes:<EOL><INDENT>lines.append("<STR_LIT>")<EOL>lines.extend("<STR_LIT>" + line for line in feature.notes.splitlines())<EOL><DEDENT>if feature.automatic:<EOL><INDENT>lines.append("<STR_LIT>")<EOL><DEDENT>if feature.disabled:<EOL><INDENT>lines.append("<STR_LIT>")<EOL>lines.extend("<STR_LIT:#>" + line for line in code.splitlines())<EOL><DEDENT>else:<EOL><INDENT>lines.append(code)<EOL><DEDENT>lines.append("<STR_LIT>" % feature.name)<EOL>feature_defs.append("<STR_LIT:\n>".join(lines))<EOL><DEDENT>fea_str = "<STR_LIT>".join(feature_defs)<EOL>gdef_str = None<EOL>if self.generate_GDEF:<EOL><INDENT>if re.search(r"<STR_LIT>", prefix_str, flags=re.MULTILINE):<EOL><INDENT>raise ValueError(<EOL>"<STR_LIT>"<EOL>"<STR_LIT>"<EOL>)<EOL><DEDENT>gdef_str = _build_gdef(<EOL>ufo, self._designspace.lib.get("<STR_LIT>")<EOL>)<EOL><DEDENT>full_text = (<EOL>"<STR_LIT>".join(filter(None, [class_str, prefix_str, fea_str, gdef_str])) + "<STR_LIT:\n>"<EOL>)<EOL>ufo.features.text = full_text if full_text.strip() else "<STR_LIT>"<EOL>
Write an UFO's OpenType feature file.