Example #1
0
    def importFile(self):
        # TODO: systematize this
        fileFormats = (
            self.tr("OpenType Font file {}").format("(*.otf *.ttf)"),
            self.tr("Type1 Font file {}").format("(*.pfa *.pfb)"),
            self.tr("ttx Font file {}").format("(*.ttx)"),
            self.tr("WOFF Font file {}").format("(*.woff)"),
            self.tr("All supported files {}").format(
                "(*.otf *.pfa *.pfb *.ttf *.ttx *.woff)"),
            self.tr("All files {}").format("(*.*)"),
        )

        path, _ = QFileDialog.getOpenFileName(
            self, self.tr("Import File"), None,
            ";;".join(fileFormats), fileFormats[-2])

        if path:
            font = TFont()
            try:
                font.extract(path)
            except Exception as e:
                errorReports.showCriticalException(e)
                return
            window = FontWindow(font)
            window.show()
Example #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()
Example #3
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)
         self._loadFont(font)
     except Exception as e:
         errorReports.showCriticalException(e)
         return
     self.setCurrentFile(font.binaryPath)
Example #4
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)
Example #5
0
    def setUp(self):
        self.font = TFont.new()

        self.mainWindow = FontWindow(self.font)
        self.mainWindow.fontInfo()
        self.fontInfo = self.mainWindow._infoWindow
        self.generalTab = self.fontInfo.tabWidget.widget(0)
        self.legalTab = self.fontInfo.tabWidget.widget(1)
        self.openTypeTab = self.fontInfo.tabWidget.widget(2)
        self.postScriptTab = self.fontInfo.tabWidget.widget(3)
        self.fontInfo.show()
Example #6
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)
         self._loadFont(font)
     except Exception as e:
         msg = self.tr("There was an issue opening the font at {}.").format(path)
         errorReports.showCriticalException(e, msg)
         return
     self.setCurrentFile(font.path)
Example #7
0
 def newFile(self):
     font = TFont.newStandardFont()
     window = FontWindow(font)
     window.show()
Example #8
0
 def newFile(self):
     font = TFont.new()
     window = FontWindow(font)
     window.show()
Example #9
0
 def newFile(self):
     font = TFont.new()
     window = FontWindow(font)
     window.show()