예제 #1
0
    def openFile(self, path=None):
        if not path:
            fileFormat = self.tr("UFO Fonts {}")
            if platformSpecific.treatPackageAsFile():
                ext = "(*.ufo)"
            else:
                ext = "(metainfo.plist)"

            path, _ = QFileDialog.getOpenFileName(
                self.activeWindow(), self.tr("Open File"), '',
                fileFormat.format(ext)
            )
            if not path:
                return
        if ".plist" in path:
            path = os.path.dirname(path)
        path = os.path.normpath(path)
        for widget in self.topLevelWidgets():
            if isinstance(widget, FontWindow):
                font = widget.font_()
                if font is not None and font.path == path:
                    widget.raise_()
                    return
        try:
            font = TFont(path)
            window = FontWindow(font)
        except Exception as e:
            msg = self.tr(
                "There was an issue when opening the font at {}.".format(
                    path))
            errorReports.showCriticalException(e, msg)
            return
        window.show()
        self.setCurrentFile(font.path)
예제 #2
0
 def _loadBinary(self, path):
     font = TFont()
     try:
         font.extract(path)
     except Exception as e:
         errorReports.showCriticalException(e)
         return
     window = FontWindow(font)
     window.show()
예제 #3
0
 def _loadFont(self, font):
     currentFont = self.currentFont()
     # Open new font in current font window if it contains an unmodified
     # empty font (e.g. after startup).
     if currentFont is not None and currentFont.path is None and \
             currentFont.binaryPath is None and currentFont.dirty is False:
         window = self._currentFontWindow
         window.setFont_(font)
     else:
         window = FontWindow(font)
     window.show()
예제 #4
0
 def _loadUFO(self, path):
     for widget in self.topLevelWidgets():
         if isinstance(widget, FontWindow):
             font = widget.font_()
             if font is not None and font.path == path:
                 widget.raise_()
                 return
     try:
         font = TFont(path)
         window = FontWindow(font)
     except Exception as e:
         msg = self.tr("There was an issue opening the font at {}.".format(path))
         errorReports.showCriticalException(e, msg)
         return
     window.show()
     self.setCurrentFile(font.path)
예제 #5
0
 def _loadBinary(self, path):
     for widget in self.topLevelWidgets():
         if isinstance(widget, FontWindow):
             font = widget.font_()
             if font is not None and font.binaryPath == path:
                 widget.raise_()
                 return
     font = TFont()
     try:
         font.extract(path)
     except Exception as e:
         errorReports.showCriticalException(e)
         return
     window = FontWindow(font)
     window.show()
     self.setCurrentFile(font.binaryPath)
예제 #6
0
 def openFile(self, path):
     if ".plist" in path:
         path = os.path.dirname(path)
     path = os.path.normpath(path)
     for window in self.topLevelWidgets():
         if isinstance(window, FontWindow):
             font = window.font_()
             if font is not None and font.path == path:
                 window.raise_()
                 return
     try:
         font = TFont(path)
         window = FontWindow(font)
     except Exception as e:
         errorReports.showCriticalException(e)
         return
     window.show()
예제 #7
0
 def newFile(self):
     font = TFont.newStandardFont()
     window = FontWindow(font)
     window.show()
예제 #8
0
 def newFile(self):
     font = TFont.new()
     window = FontWindow(font)
     window.show()
예제 #9
0
 def newFile(self):
     font = TFont.new()
     window = FontWindow(font)
     window.show()