diff options
| author | Adrien Tétar | 2015-10-09 23:46:37 +0200 | 
|---|---|---|
| committer | Adrien Tétar | 2015-10-09 23:46:37 +0200 | 
| commit | 327ffb95f9449575ab28960d5016b910d7161841 (patch) | |
| tree | 724ef9f3c8e138df4d0df6cd34f8429056f8f4dd /Lib/defconQt/fontView.py | |
| parent | c7d2caf40164696eeb07d42da5bcd21591c19687 (diff) | |
| download | trufont-327ffb95f9449575ab28960d5016b910d7161841.tar.bz2 | |
fontView: allow saving as ufo3 or ufo2
Diffstat (limited to 'Lib/defconQt/fontView.py')
| -rw-r--r-- | Lib/defconQt/fontView.py | 20 | 
1 files changed, 15 insertions, 5 deletions
| diff --git a/Lib/defconQt/fontView.py b/Lib/defconQt/fontView.py index dab393f..033a6df 100644 --- a/Lib/defconQt/fontView.py +++ b/Lib/defconQt/fontView.py @@ -11,6 +11,7 @@ from defconQt.spaceCenter import MainSpaceWindow  from PyQt5.QtCore import *  from PyQt5.QtGui import *  from PyQt5.QtWidgets import * +from collections import OrderedDict  import os, pickle, traceback  cannedDesign = [ @@ -681,7 +682,7 @@ class MainWindow(QMainWindow):          fontPath = self.sender().toolTip()          self.openFile(fontPath) -    def saveFile(self, path=None): +    def saveFile(self, path=None, ufoFormatVersion=3):          if path is None and self.font.path is None:              self.saveFileAs()          else: @@ -693,7 +694,7 @@ class MainWindow(QMainWindow):              for glyph in glyphs:                  glyphNames.append(glyph.name)              self.font.lib["public.glyphOrder"] = glyphNames -            self.font.save(path=path) +            self.font.save(path, ufoFormatVersion)              self.font.dirty = False              for glyph in self.font:                  glyph.dirty = False @@ -701,10 +702,19 @@ class MainWindow(QMainWindow):              self.setWindowModified(False)      def saveFileAs(self): -        path, ok = QFileDialog.getSaveFileName(self, "Save File", '', -                "UFO Fonts (*.ufo)") +        fileFormats = OrderedDict([ +            ("UFO Font version 3 (*.ufo)", 3), +            ("UFO Fonts version 2 (*.ufo)", 2), +        ]) +        # TODO: see if OSX works nicely with UFO as files, then switch to directory +        # on platforms that need it +        dialog = QFileDialog(self, "Save File", None, ";;".join(fileFormats.keys())) +        dialog.setAcceptMode(QFileDialog.AcceptSave) +        ok = dialog.exec_()          if ok: -            self.saveFile(path) +            nameFilter = dialog.selectedNameFilter() +            path = dialog.selectedFiles()[0] +            self.saveFile(path, fileFormats[nameFilter])              self.setWindowTitle()          #return ok | 
