def _submit_form(self, handle): # a dictionary for storing the form inputs data = {} # FIXME: Validate these entries and show an alert if the input is wrong # FIXME: Ask for confirmation before the submission data["familyName"] = self.family_name.get_text() data["copyright"] = self.copyright.get_text() data["trademark"] = self.trademark.get_text() data["styleName"] = self.style_name_combo.get_active_text() data["ascender"] = int(self.ascender.get_text()) data["descender"] = int(self.descender.get_text()) data["capHeight"] = int(self.cap_height.get_text()) data["unitsPerEm"] = int(self.unit_per_em.get_text()) data["xHeight"] = int(self.x_height.get_text()) data["year"] = int(self.year.get_text()) version = self.version.get_text().split('.') data["versionMajor"] = int(version[0]) data["versionMinor"] = int(version[1]) globals.FONT = BaseFont.new_standard_font(data=data) # FIXME: Check if font was created or not globals.SELF.set_page("SUMMARY")
def import_font(self, file_path=None): """Import the font from a .otf or .ttf file.""" if file_path is None: # FIXME: Add compatibility for earlier versions # FIXME: Fix the filter type to include either # all the objects or only the .otf and .ttf font files try: chooser = ObjectChooser( parent=self, what_filter=self.get_bundle_id(), filter_type=None) except Exception: self._show_alert("Error", "This feature is not Implemented") logging.error("This feature is not Implemented") return else: try: result = chooser.run() if result == Gtk.ResponseType.ACCEPT: jobject = chooser.get_selected_object() if jobject and jobject.file_path: file_path = jobject.file_path finally: chooser.destroy() del chooser font = BaseFont.import_from_binary(file_path) if font is None: self._show_alert("Error", "Invalid file chosen") return else: # save the ufo in the instance folder # so that we have a font path which can be # needed to perform other actions on the font path = self._create_font_instance() globals.FONT = font if path is not None: self.set_page("SUMMARY") # print success message self._show_alert("Success", "Imported Font: %s" % globals.FONT.info.familyName)
def import_font(self, file_path=None): """Import the font from a .otf or .ttf file.""" if file_path is None: # FIXME: Add compatibility for earlier versions # FIXME: Fix the filter type to include either # all the objects or only the .otf and .ttf font files try: chooser = ObjectChooser( parent=self, what_filter=self.get_bundle_id(), filter_type=None) except: self._show_alert("Error", "This feature is not Implemented") logging.error("This feature is not Implemented") return else: try: result = chooser.run() if result == Gtk.ResponseType.ACCEPT: jobject = chooser.get_selected_object() if jobject and jobject.file_path: file_path = jobject.file_path finally: chooser.destroy() del chooser font = BaseFont.import_from_binary(file_path) if font is None: self._show_alert("Error", "Invalid file chosen") return else: # save the ufo in the instance folder # so that we have a font path which can be # needed to perform other actions on the font path = self._create_font_instance() globals.FONT = font if path is not None: self.set_page("SUMMARY") # print success message self._show_alert("Success", "Imported Font: %s" % globals.FONT.info.familyName)
# the activity import weakref from gi.repository import Gdk from editfonts.core.basefont import BaseFont # from defcon import Font from sugar3.graphics.xocolor import XoColor # handle for the activity class SELF = None # The Sample font that will always be loaded SAMPLE_FONT_PATH = './test_fonts/Geo-Regular.ufo' SAMPLE_FONT = BaseFont(SAMPLE_FONT_PATH) SAMPLE_FONT_REF = weakref.ref(SAMPLE_FONT) # The Path for the font file # set this to be SAMPLE_FONT_PATH in the beginning FONT_PATH = SAMPLE_FONT_PATH # The global variable to store the current working font across the # entire activity FONT = BaseFont(SAMPLE_FONT_PATH) FONT_REF = weakref.ref(FONT) if FONT_REF() is not None: GLYPH = FONT_REF()["A"] h = FONT_REF().info.ascender - FONT_REF().info.descender b = 0 - FONT_REF().info.descender