def __init__(self, currentGlyphs=None, parent=None): super().__init__(parent) self.setWindowModality(Qt.WindowModal) self.setWindowTitle(self.tr("Add Glyphs…")) self.currentGlyphs = currentGlyphs self.currentGlyphNames = [glyph.name for glyph in currentGlyphs] layout = QGridLayout(self) self.markColorWidget = ColorVignette(self) self.markColorWidget.setFixedWidth(56) self.importCharDrop = QComboBox(self) self.importCharDrop.addItem(self.tr("Import glyph names…")) glyphSets = settings.readGlyphSets() for name, glyphNames in glyphSets.items(): self.importCharDrop.addItem(name, glyphNames) self.importCharDrop.currentIndexChanged[int].connect(self.importGlyphs) self.addGlyphsEdit = QPlainTextEdit(self) self.addGlyphsEdit.setFocus(Qt.OtherFocusReason) self.addUnicodeBox = QCheckBox(self.tr("Add Unicode"), self) self.addUnicodeBox.setChecked(True) self.addAsTemplateBox = QCheckBox(self.tr("Add as template"), self) self.addAsTemplateBox.setChecked(True) self.sortFontBox = QCheckBox(self.tr("Sort font"), self) self.overrideBox = QCheckBox(self.tr("Override"), self) buttonBox = QDialogButtonBox( QDialogButtonBox.Ok | QDialogButtonBox.Cancel) buttonBox.accepted.connect(self.accept) buttonBox.rejected.connect(self.reject) l = 0 layout.addWidget(self.markColorWidget, l, 0) layout.addWidget(self.importCharDrop, l, 3, 1, 2) l += 1 layout.addWidget(self.addGlyphsEdit, l, 0, 1, 5) l += 1 layout.addWidget(self.addUnicodeBox, l, 0) layout.addWidget(self.addAsTemplateBox, l, 1) layout.addWidget(self.sortFontBox, l, 2) layout.addWidget(self.overrideBox, l, 3) layout.addWidget(buttonBox, l, 4) self.setLayout(layout)
def __init__(self, currentGlyphs=None, parent=None): super().__init__(parent) self.setWindowModality(Qt.WindowModal) self.setWindowTitle(self.tr("Add Glyphs…")) self.currentGlyphs = currentGlyphs self.currentGlyphNames = [glyph.name for glyph in currentGlyphs] layout = QGridLayout(self) self.markColorWidget = ColorVignette(self) self.markColorWidget.setFixedWidth(56) self.importCharDrop = QComboBox(self) self.importCharDrop.addItem(self.tr("Import glyph names…")) glyphSets = settings.readGlyphSets() for name, glyphNames in glyphSets.items(): self.importCharDrop.addItem(name, glyphNames) self.importCharDrop.currentIndexChanged[int].connect(self.importGlyphs) self.addGlyphsEdit = QPlainTextEdit(self) self.addGlyphsEdit.setFocus(True) self.addUnicodeBox = QCheckBox(self.tr("Add Unicode"), self) self.addUnicodeBox.setChecked(True) self.addAsTemplateBox = QCheckBox(self.tr("Add as template"), self) self.addAsTemplateBox.setChecked(True) self.sortFontBox = QCheckBox(self.tr("Sort font"), self) self.overrideBox = QCheckBox(self.tr("Override"), self) buttonBox = QDialogButtonBox( QDialogButtonBox.Ok | QDialogButtonBox.Cancel) buttonBox.accepted.connect(self.accept) buttonBox.rejected.connect(self.reject) l = 0 layout.addWidget(self.markColorWidget, l, 0) layout.addWidget(self.importCharDrop, l, 3, 1, 2) l += 1 layout.addWidget(self.addGlyphsEdit, l, 0, 1, 5) l += 1 layout.addWidget(self.addUnicodeBox, l, 0) layout.addWidget(self.addAsTemplateBox, l, 1) layout.addWidget(self.sortFontBox, l, 2) layout.addWidget(self.overrideBox, l, 3) layout.addWidget(buttonBox, l, 4) self.setLayout(layout)
def new(cls): font = cls() font.info.unitsPerEm = 1000 font.info.ascender = 750 font.info.capHeight = 700 font.info.xHeight = 500 font.info.descender = -250 defaultGlyphSet = settings.defaultGlyphSet() if defaultGlyphSet: glyphNames = None glyphSets = settings.readGlyphSets() if defaultGlyphSet in glyphSets: glyphNames = glyphSets[defaultGlyphSet] if glyphNames is not None: for name in glyphNames: font.get(name, asTemplate=True) font.dirty = False app = QApplication.instance() data = dict(font=font) app.postNotification("newFontCreated", data) return font
def newStandardFont(cls): font = cls() font.info.unitsPerEm = 1000 font.info.ascender = 750 font.info.descender = -250 font.info.capHeight = 750 font.info.xHeight = 500 defaultGlyphSet = settings.defaultGlyphSet() if defaultGlyphSet: glyphNames = None glyphSets = settings.readGlyphSets() if defaultGlyphSet in glyphSets: glyphNames = glyphSets[defaultGlyphSet] if glyphNames is not None: for name in glyphNames: font.newStandardGlyph(name, asTemplate=True) font.dirty = False app = QApplication.instance() data = dict(font=font) app.postNotification("newFontCreated", data) return font
def readSettings(self): defaultGlyphSet = settings.defaultGlyphSet() self.defaultGlyphSetBox.setChecked(len(defaultGlyphSet)) self.glyphSets = settings.readGlyphSets() self.defaultGlyphSetDrop.clear() self.defaultGlyphSetDrop.addItems(self.glyphSets.keys()) self.glyphSetList.clear() glyphSetNames = self.glyphSets.keys() # Normally we should be enforcing this rather decently in the interface # already if glyphSetNames: for glyphSetName in glyphSetNames: item = QListWidgetItem(glyphSetName, self.glyphSetList) item.setFlags(item.flags() | Qt.ItemIsEditable) self.glyphSetList.setCurrentRow(0) self.removeGlyphSetButton.setEnabled(len(self.glyphSets) > 1) glyphListPath = settings.glyphListPath() self.glyphListBox.setChecked(bool(glyphListPath)) self.glyphListEdit.setEnabled(bool(glyphListPath)) self.glyphListEdit.setText(glyphListPath) self.glyphListButton.setEnabled(bool(glyphListPath))
def __init__(self, desc=None, parent=None): super().__init__(parent) self.setWindowModality(Qt.WindowModal) self.setWindowTitle(self.tr("Sort…")) self.smartSortBox = QRadioButton(self.tr("Canned sort"), self) self.smartSortBox.setToolTip( self.tr("A combination of simple, complex and custom " "sorts that give optimized ordering results.")) self.glyphSetBox = QRadioButton(self.tr("Glyph set"), self) self.glyphSetBox.toggled.connect(self.glyphSetToggle) self.glyphSetDrop = QComboBox(self) self.glyphSetDrop.setEnabled(False) glyphSets = settings.readGlyphSets() for name, glyphNames in glyphSets.items(): self.glyphSetDrop.addItem(name, glyphNames) self.customSortBox = QRadioButton(self.tr("Custom…"), self) self.customSortBox.toggled.connect(self.customSortToggle) self.customSortGroup = QGroupBox(parent=self) self.customSortGroup.setEnabled(False) descriptorsCount = 6 if desc is None: pass elif desc[0]["type"] == "glyphSet": self.glyphSetBox.setChecked(True) self.glyphSetDrop.setEnabled(True) # XXX: we must handle unknown glyphSets... or glyphSets with # the same name but different self.glyphSetDrop.setCurrentText(desc[0]["name"]) elif desc[0]["type"] == "cannedDesign": self.smartSortBox.setChecked(True) else: self.customSortBox.setChecked(True) self.customSortGroup.setEnabled(True) descriptorsCount = len(desc) self.customDescriptors = [[] for i in range(descriptorsCount)] self.customSortLayout = QGridLayout() for i, line in enumerate(self.customDescriptors): line.append(QComboBox(self)) line[0].insertItems(0, sortItems) line.append(QCheckBox(self.tr("Ascending"), self)) line.append(QCheckBox(self.tr("Allow pseudo-unicode"), self)) if self.customSortBox.isChecked(): line[0].setCurrentIndex( self.indexFromItemName(desc[i]["type"])) line[1].setChecked(desc[i]["ascending"]) line[2].setChecked(desc[i]["allowPseudoUnicode"]) else: line[0].setCurrentIndex(i) line[1].setChecked(True) line[2].setChecked(True) self.customSortLayout.addWidget(line[0], i, 0) self.customSortLayout.addWidget(line[1], i, 1) self.customSortLayout.addWidget(line[2], i, 2) btn = QPushButton(self) btn.setFixedWidth(32) btn.setProperty("index", i) line.append(btn) self.customSortLayout.addWidget(btn, i, 3) if i == 0: btn.setText("+") btn.clicked.connect(self._addRow) self.addLineButton = btn else: btn.setText("−") btn.clicked.connect(self._deleteRow) self.customSortGroup.setLayout(self.customSortLayout) buttonBox = QDialogButtonBox( QDialogButtonBox.Ok | QDialogButtonBox.Cancel) buttonBox.accepted.connect(self.accept) buttonBox.rejected.connect(self.reject) layout = QVBoxLayout(self) layout.addWidget(self.smartSortBox) layout.addWidget(self.glyphSetBox) layout.addWidget(self.glyphSetDrop) layout.addWidget(self.customSortBox) layout.addWidget(self.customSortGroup) layout.addWidget(buttonBox) self.setLayout(layout)