aboutsummaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorAdrien Tétar2015-04-26 22:21:01 +0200
committerAdrien Tétar2015-04-26 22:21:01 +0200
commit6c3bb74bf1f1080d4bd18716c4bc3ffd8deaf4ff (patch)
tree41e0d1139c423d01e941ea996dbf82901e16d422 /Lib
parent03312b55db48df12792d931523bb3eb57a9634e9 (diff)
downloadtrufont-6c3bb74bf1f1080d4bd18716c4bc3ffd8deaf4ff.tar.bz2
Advancements
Diffstat (limited to 'Lib')
-rw-r--r--Lib/defconQt/__pycache__/syntaxhighlighter.cpython-34.pycbin6285 -> 0 bytes
-rw-r--r--Lib/defconQt/charmap.py294
-rw-r--r--Lib/defconQt/controls/__pycache__/__init__.cpython-34.pycbin151 -> 0 bytes
-rw-r--r--Lib/defconQt/controls/__pycache__/glyphCellView.cpython-34.pycbin4281 -> 0 bytes
-rw-r--r--Lib/defconQt/controls/__pycache__/glyphCellView_ex.cpython-34.pycbin4703 -> 0 bytes
-rw-r--r--Lib/defconQt/fontinfo.py220
-rw-r--r--Lib/defconQt/representationFactories/__pycache__/__init__.cpython-34.pycbin7097 -> 0 bytes
-rw-r--r--Lib/defconQt/spacecenter.py205
-rw-r--r--Lib/defconQt/syntaxhighlighter.py14
-rw-r--r--Lib/defconQt/windows/__pycache__/baseWindow.cpython-34.pycbin3518 -> 0 bytes
-rw-r--r--Lib/defconQt/windows/__pycache__/progressWindow.cpython-34.pycbin1391 -> 0 bytes
11 files changed, 458 insertions, 275 deletions
diff --git a/Lib/defconQt/__pycache__/syntaxhighlighter.cpython-34.pyc b/Lib/defconQt/__pycache__/syntaxhighlighter.cpython-34.pyc
deleted file mode 100644
index c53d3d6..0000000
--- a/Lib/defconQt/__pycache__/syntaxhighlighter.cpython-34.pyc
+++ /dev/null
Binary files differ
diff --git a/Lib/defconQt/charmap.py b/Lib/defconQt/charmap.py
index ca0b922..4545517 100644
--- a/Lib/defconQt/charmap.py
+++ b/Lib/defconQt/charmap.py
@@ -48,9 +48,9 @@ import unicodedata
from defcon import Font
from PyQt5.QtCore import pyqtSignal, QSize, Qt
-from PyQt5.QtGui import (QClipboard, QDoubleValidator, QFont, QFontDatabase, QFontMetrics,
- QIcon, QIntValidator, QPainter)
-from PyQt5.QtWidgets import (QApplication, QCheckBox, QComboBox, QDialog, QDialogButtonBox, QFileDialog, QFontComboBox,
+from PyQt5.QtGui import (QClipboard, QFont, QFontDatabase, QFontMetrics,
+ QIcon, QPainter)
+from PyQt5.QtWidgets import (QApplication, QCheckBox, QComboBox, QDialogButtonBox, QFileDialog, QFontComboBox,
QFrame, QHBoxLayout, QLabel, QLineEdit, QMainWindow, QMessageBox, QMenu, QPushButton,
QScrollArea, QTabWidget, QToolTip, QVBoxLayout, QWidget)
@@ -106,7 +106,7 @@ class CharacterWidget(QWidget):
text = '<p>Character: <span style="font-size: 24pt; font-family: %s">%s</span><p>Value: 0x%x' % (QFont().family(), self._chr(key), key)
QToolTip.showText(event.globalPos(), text, self)
'''
-
+
def mousePressEvent(self, event):
if event.button() == Qt.LeftButton:
self.lastKey = (event.y() // self.squareSize) * self.columns + event.x() // self.squareSize
@@ -118,7 +118,7 @@ class CharacterWidget(QWidget):
self.update()
else:
super(CharacterWidget, self).mousePressEvent(event)
-
+
def mouseDoubleClickEvent(self, event):
if event.button() == Qt.LeftButton:
self.lastKey = (event.y() // self.squareSize) * self.columns + event.x() // self.squareSize
@@ -135,7 +135,6 @@ class CharacterWidget(QWidget):
painter = QPainter(self)
painter.setRenderHint(QPainter.Antialiasing)
painter.fillRect(event.rect(), Qt.white)
- #painter.setFont(self.displayFont)
redrawRect = event.rect()
beginRow = redrawRect.top() // self.squareSize
@@ -150,27 +149,9 @@ class CharacterWidget(QWidget):
row * self.squareSize, self.squareSize,
self.squareSize)
-# fontMetrics = QFontMetrics(self.displayFont)
-# painter.setPen(Qt.black)
-
-
- """
- draw = self.displayFont["a"].getRepresentation("defconQt.QPainterPath")
- painter.save()
- painter.setBrushOrigin(50, 150)
-# painter.scale(1.0, -1.0)
-# painter.translate(0,-self.squareSize)
-# p_x,p_y,p_w,p_h = draw.controlPointRect().getRect()
-# measure = max(p_w, p_h)
-# painter.scale(measure/self.squareSize, measure/self.squareSize)
- painter.fillPath(draw, Qt.black)
- painter.restore()
- """
for row in range(beginRow, endRow + 1):
for column in range(beginColumn, endColumn + 1):
key = row * self.columns + column
- x,y,w,h = column * self.squareSize, row * self.squareSize, self.squareSize, self.squareSize
-# painter.setClipRect(x,y,w,h)
if key == self.lastKey:
painter.fillRect(column * self.squareSize + 1,
@@ -178,18 +159,9 @@ class CharacterWidget(QWidget):
self.squareSize - 2, self.col)
key_ch = str(self._chr(key))
-# painter.drawText(column * self.squareSize + (self.squareSize / 2) - fontMetrics.width(key_ch) / 2,
-# row * self.squareSize + 4 + fontMetrics.ascent(),
-# key_ch)
-# print(key)
+
if key > len(self.glyphs)-1: break
glyph = self.glyphs[key].getRepresentation("defconQt.QPainterPath")
-# if key_ch not in self.displayFont: continue
-# glyph = self.displayFont[key_ch].getRepresentation("defconQt.QPainterPath") # , width=self.squareSize, height=self.squareSize
- # When need to move the painter so that the path draws at the right place
-# print(glyph)
-# p_x,p_y,p_w,p_h = glyph.controlPointRect().getRect()
-# print(p_h, h)
if self.font.info.unitsPerEm is None: break
if not self.font.info.unitsPerEm > 0: self.font.info.unitsPerEm = 1000
factor = self.squareSize/(self.font.info.unitsPerEm*(1+2*.125))
@@ -198,16 +170,8 @@ class CharacterWidget(QWidget):
factor *= 1+2*x_offset/(self.glyphs[key].width*factor)
x_offset = 0
y_offset = self.font.info.descender*factor
-# print(self.glyphs[key].width)
-# print("xo: "+str(x_offset))
painter.save()
painter.translate(column * self.squareSize + x_offset, row * self.squareSize + self.squareSize + y_offset)
-# painter.setBrushOrigin((self.squareSize-self.glyphs[key].width)/2,self.font.info.descender)
-# painter.translate(column * self.squareSize + (self.squareSize / 2) - self.glyphs[key].width / 2,
-# row * self.squareSize + 4 + self.displayFont['hhea'].ascent)
-# painter.translate(p_x-x, p_y-y)
-# painter.scale(1.0, -1.0)
-# painter.translate(0,-self.squareSize)
painter.scale(factor, -factor)
painter.fillPath(glyph, Qt.black)
painter.restore()
@@ -221,230 +185,12 @@ class CharacterWidget(QWidget):
# Python v3.
return chr(codepoint)
-class TabDialog(QDialog):
-
- def __init__(self, font, parent=None):
- super(TabDialog, self).__init__(parent)
-
- # TODO: figure a proper correspondence to set and fetch widgets...
- self.tabs = {
- "General": 0
- }
-
-# fileInfo = QFileInfo(fileName)
- self.font = font
- self.tabWidget = QTabWidget()
- self.tabWidget.addTab(GeneralTab(self.font), "General")
-# tabWidget.addTab(PermissionsTab(fileInfo), "OpenType")
-# tabWidget.addTab(ApplicationsTab(fileInfo), "PostScript")
-# tabWidget.addTab(ApplicationsTab(fileInfo), "Miscellaneous")
-
- buttonBox = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel)
-
- buttonBox.accepted.connect(self.accept)
- buttonBox.rejected.connect(self.reject)
-
- mainLayout = QVBoxLayout()
- mainLayout.addWidget(self.tabWidget)
- mainLayout.addWidget(buttonBox)
- self.setLayout(mainLayout)
-
- self.setWindowTitle("Font Info")
-
- def accept(self):
- self.font.info.familyName = self.tabWidget.widget(self.tabs["General"]).fileNameEdit.text()
- self.font.info.styleName = self.tabWidget.widget(self.tabs["General"]).styleNameEdit.text()
- self.font.info.styleMapFamilyName = self.tabWidget.widget(self.tabs["General"]).styleMapFamilyEdit.text()
- sn = self.tabWidget.widget(self.tabs["General"]).styleMapStyleDrop.currentIndex()
- print(sn)
- if sn == 1: self.font.info.styleMapStyleName = "regular"
- elif sn == 2: self.font.info.styleMapStyleName = "italic"
- elif sn == 3: self.font.info.styleMapStyleName = "bold"
- elif sn == 4: self.font.info.styleMapStyleName = "bold italic"
- else: self.font.info.styleMapStyleName = None
- self.font.info.versionMajor = int(self.tabWidget.widget(self.tabs["General"]).versionMajorEdit.text())
- self.font.info.versionMinor = int(self.tabWidget.widget(self.tabs["General"]).versionMinorEdit.text())
- super(TabDialog, self).accept()
-
-class GeneralTab(QWidget):
- def __init__(self, font, parent=None):
- super(GeneralTab, self).__init__(parent)
-
- identLabel = QLabel("Identification")
- identLine = QFrame()
- identLine.setFrameShape(QFrame.HLine)
-
- fileNameLabel = QLabel("Family name:")
- self.fileNameEdit = QLineEdit(font.info.familyName)
-
- styleNameLabel = QLabel("Style name:")
- self.styleNameEdit = QLineEdit(font.info.styleName)
-
- styleMapFamilyLabel = QLabel("Style map family name:")
- self.styleMapFamilyEdit = QLineEdit(font.info.styleMapFamilyName)
-# self.styleMapFamilyCBox = QCheckBox("Use default value")
-
- styleMapStyleLabel = QLabel("Style map style name:")
- self.styleMapStyleDrop = QComboBox()
-# items = ["None", "Regular", "Italic", "Bold", "Bold Italic"]
- styleMapStyle = {
- "None": 0,
- "Regular": 1,
- "Italic": 2,
- "Bold": 3,
- "Bold Italic": 4
- }
- for name,index in styleMapStyle.items():
- self.styleMapStyleDrop.insertItem(index, name)
- sn = font.info.styleMapStyleName
- # TODO: index to set is statically known, should eventually get rid of dict overhead if any?
- if sn == "regular": self.styleMapStyleDrop.setCurrentIndex(styleMapStyle["Regular"])
- elif sn == "regular italic": self.styleMapStyleDrop.setCurrentIndex(styleMapStyle["Italic"])
- elif sn == "bold": self.styleMapStyleDrop.setCurrentIndex(styleMapStyle["Bold"])
- elif sn == "bold italic": self.styleMapStyleDrop.setCurrentIndex(styleMapStyle["Bold Italic"])
- else: self.styleMapStyleDrop.setCurrentIndex(styleMapStyle["None"])
-# self.styleMapStyleCBox = QCheckBox("Use default value")
-
- # TODO: give visual feedback of input data validity using QLineEdit lose focus event
- # http://snorf.net/blog/2014/08/09/using-qvalidator-in-pyqt4-to-validate-user-input/
- versionLabel = QLabel("Version:")
- self.versionMajorEdit = QLineEdit(str(font.info.versionMajor))
- self.versionMajorEdit.setValidator(QIntValidator())
- self.versionMinorEdit = QLineEdit(str(font.info.versionMinor))
- self.versionMinorEdit.setValidator(QIntValidator())
-
- dimensionsLabel = QLabel("Dimensions")
- dimensionsLine = QFrame()
- dimensionsLine.setFrameShape(QFrame.HLine)
-
- unitsPerEmLabel = QLabel("Units per em:")
- self.unitsPerEmEdit = QLineEdit(str(font.info.unitsPerEm))
- self.unitsPerEmEdit.setValidator(QIntValidator())
-
- ascenderLabel = QLabel("Ascender:")
- self.ascenderEdit = QLineEdit(str(font.info.ascender))
- self.ascenderEdit.setValidator(QIntValidator())
-
- descenderLabel = QLabel("Descender:")
- self.descenderEdit = QLineEdit(str(font.info.descender))
- self.descenderEdit.setValidator(QIntValidator())
-
- xHeightLabel = QLabel("x-height:")
- self.xHeightEdit = QLineEdit(str(font.info.xHeight))
- self.xHeightEdit.setValidator(QIntValidator())
-
- capHeightLabel = QLabel("Cap height:")
- self.capHeightEdit = QLineEdit(str(font.info.capHeight))
- self.capHeightEdit.setValidator(QIntValidator())
-
- italicAngleLabel = QLabel("Italic angle:")
- self.italicAngleEdit = QLineEdit(str(font.info.italicAngle))
- self.italicAngleEdit.setValidator(QDoubleValidator())
-
- legalLabel = QLabel("Legal")
- legalLine = QFrame()
- legalLine.setFrameShape(QFrame.HLine)
-
- copyrightLabel = QLabel("Copyright:")
- self.copyrightEdit = QLineEdit(font.info.copyright)
-
- trademarkLabel = QLabel("Trademark:")
- self.trademarkEdit = QLineEdit(font.info.trademark)
-
- licenseLabel = QLabel("License:")
- self.licenseEdit = QLineEdit(font.info.openTypeNameLicense)
-
- licenseURLLabel = QLabel("License URL:")
- self.licenseURLEdit = QLineEdit(font.info.openTypeNameLicenseURL)
-
- partiesLabel = QLabel("Parties")
- partiesLine = QFrame()
- partiesLine.setFrameShape(QFrame.HLine)
-
- designerLabel = QLabel("Designer:")
- self.designerEdit = QLineEdit(font.info.openTypeNameDesigner)
-
- designerURLLabel = QLabel("Designer URL:")
- self.designerURLEdit = QLineEdit(font.info.openTypeNameDesignerURL)
-
- manufacturerLabel = QLabel("Manufacturer:")
- self.manufacturerEdit = QLineEdit(font.info.openTypeNameManufacturer)
-
- manufacturerURLLabel = QLabel("Manufacturer URL:")
- self.manufacturerURLEdit = QLineEdit(font.info.openTypeNameManufacturerURL)
-
- mainLayout = QVBoxLayout()
- mainLayout.addWidget(identLabel)
- mainLayout.addWidget(identLine)
- mainLayout.addWidget(fileNameLabel)
- mainLayout.addWidget(self.fileNameEdit)
- mainLayout.addWidget(styleNameLabel)
- mainLayout.addWidget(self.styleNameEdit)
- mainLayout.addWidget(styleMapFamilyLabel)
- mainLayout.addWidget(self.styleMapFamilyEdit)
- mainLayout.addWidget(styleMapStyleLabel)
- mainLayout.addWidget(self.styleMapStyleDrop)
- mainLayout.addWidget(versionLabel)
- mainLayout.addWidget(self.versionMajorEdit)
- mainLayout.addWidget(self.versionMinorEdit)
-
- mainLayout.addWidget(dimensionsLabel)
- mainLayout.addWidget(dimensionsLine)
- mainLayout.addWidget(unitsPerEmLabel)
- mainLayout.addWidget(self.unitsPerEmEdit)
- mainLayout.addWidget(ascenderLabel)
- mainLayout.addWidget(self.ascenderEdit)
- mainLayout.addWidget(descenderLabel)
- mainLayout.addWidget(self.descenderEdit)
- mainLayout.addWidget(xHeightLabel)
- mainLayout.addWidget(self.xHeightEdit)
- mainLayout.addWidget(capHeightLabel)
- mainLayout.addWidget(self.capHeightEdit)
- mainLayout.addWidget(italicAngleLabel)
- mainLayout.addWidget(self.italicAngleEdit)
-
- mainLayout.addWidget(legalLabel)
- mainLayout.addWidget(legalLine)
- mainLayout.addWidget(copyrightLabel)
- mainLayout.addWidget(self.copyrightEdit)
- mainLayout.addWidget(trademarkLabel)
- mainLayout.addWidget(self.trademarkEdit)
- mainLayout.addWidget(licenseLabel)
- mainLayout.addWidget(self.licenseEdit)
- mainLayout.addWidget(licenseURLLabel)
- mainLayout.addWidget(self.licenseURLEdit)
-
- mainLayout.addWidget(partiesLabel)
- mainLayout.addWidget(partiesLine)
- mainLayout.addWidget(designerLabel)
- mainLayout.addWidget(self.designerEdit)
- mainLayout.addWidget(designerURLLabel)
- mainLayout.addWidget(self.designerURLEdit)
- mainLayout.addWidget(manufacturerLabel)
- mainLayout.addWidget(self.manufacturerEdit)
- mainLayout.addWidget(manufacturerURLLabel)
- mainLayout.addWidget(self.manufacturerURLEdit)
- mainLayout.addStretch(1)
-
- # http://nealbuerger.com/2013/11/pyside-qvboxlayout-with-qscrollarea/
- # Why so many layers of indirection? It might be possible to do this
- # in a simpler way...
- widget = QWidget()
- widget.setLayout(mainLayout)
- scrollArea = QScrollArea()
- scrollArea.setWidget(widget)
- scrollArea.setMinimumSize(170, 200)
- vLayout = QVBoxLayout()
- vLayout.addWidget(scrollArea)
-
- self.setLayout(vLayout)
-
class MainWindow(QMainWindow):
def __init__(self, font=Font()):
super(MainWindow, self).__init__()
centralWidget = QWidget()
-
+
self.font = font
self.scrollArea = QScrollArea()
self.characterWidget = CharacterWidget(self.font)
@@ -463,12 +209,14 @@ class MainWindow(QMainWindow):
fileMenu.addAction("&Save", self.saveFile, "Ctrl+S")
fileMenu.addAction("Save &As...", self.saveFileAs, "Ctrl+Shift+S")
fileMenu.addAction("E&xit", QApplication.instance().quit, "Ctrl+Q")
-
+
fontMenu = QMenu("&Font", self)
self.menuBar().addMenu(fontMenu)
-
+
fontMenu.addAction("Font &info", self.fontInfo, "Ctrl+I")
fontMenu.addAction("Font &features", self.fontFeatures, "Ctrl+F")
+ fontMenu.addSeparator()
+ fontMenu.addAction("&Space center", self.spaceCenter, "Ctrl+Y")
helpMenu = QMenu("&Help", self)
self.menuBar().addMenu(helpMenu)
@@ -499,20 +247,21 @@ class MainWindow(QMainWindow):
def saveFile(self, path=None):
self.font.save(path=path)
# self.font.path = path # done by defcon
-
+
def saveFileAs(self):
path, _ = QFileDialog.getSaveFileName(self, "Save File", '',
"UFO Fonts (*.ufo)")
print(path)
self.saveFile(path)
-
+
def fontInfo(self):
# If a window is already opened, bring it to the front, else make another one.
# TODO: see about calling super from the widget and del'eting the ptr to the widget
# otherwise it doesn't get swept?
# Else we can just play with visibility instead of respawning, given that the window
# is still valid by its ref after it's been closed
+ from fontinfo import TabDialog
if not (hasattr(self, 'fontInfoWindow') and self.fontInfoWindow.isVisible()):
self.fontInfoWindow = TabDialog(self.font)
self.fontInfoWindow.show()
@@ -522,14 +271,23 @@ class MainWindow(QMainWindow):
def fontFeatures(self):
# TODO: see up here
- import syntaxhighlighter
+ from syntaxhighlighter import MainEditWindow
if not (hasattr(self, 'fontFeaturesWindow') and self.fontFeaturesWindow.isVisible()):
- # XXX: trying to make a child window, let's see
- self.fontFeaturesWindow = syntaxhighlighter.MainWindow(self.font.features, self)
+ self.fontFeaturesWindow = MainEditWindow(self.font.features)
self.fontFeaturesWindow.show()
else:
self.fontFeaturesWindow.raise_()
+ def spaceCenter(self):
+ # TODO: see up here
+ from spacecenter import MainSpaceWindow
+ if not (hasattr(self, 'spaceCenterWindow') and self.spaceCenterWindow.isVisible()):
+ # XXX: trying to make a child window, let's see
+ self.spaceCenterWindow = MainSpaceWindow(self.font, "Hiyazee")
+ self.spaceCenterWindow.show()
+ else:
+ self.spaceCenterWindow.raise_()
+
def about(self):
QMessageBox.about(self, "About Fontes",
"<p>The <b>Fontes</b> font editor is a new UFO-centric " \
diff --git a/Lib/defconQt/controls/__pycache__/__init__.cpython-34.pyc b/Lib/defconQt/controls/__pycache__/__init__.cpython-34.pyc
deleted file mode 100644
index 019189a..0000000
--- a/Lib/defconQt/controls/__pycache__/__init__.cpython-34.pyc
+++ /dev/null
Binary files differ
diff --git a/Lib/defconQt/controls/__pycache__/glyphCellView.cpython-34.pyc b/Lib/defconQt/controls/__pycache__/glyphCellView.cpython-34.pyc
deleted file mode 100644
index 274e224..0000000
--- a/Lib/defconQt/controls/__pycache__/glyphCellView.cpython-34.pyc
+++ /dev/null
Binary files differ
diff --git a/Lib/defconQt/controls/__pycache__/glyphCellView_ex.cpython-34.pyc b/Lib/defconQt/controls/__pycache__/glyphCellView_ex.cpython-34.pyc
deleted file mode 100644
index 8a99b74..0000000
--- a/Lib/defconQt/controls/__pycache__/glyphCellView_ex.cpython-34.pyc
+++ /dev/null
Binary files differ
diff --git a/Lib/defconQt/fontinfo.py b/Lib/defconQt/fontinfo.py
new file mode 100644
index 0000000..f551512
--- /dev/null
+++ b/Lib/defconQt/fontinfo.py
@@ -0,0 +1,220 @@
+from PyQt5.QtGui import QDoubleValidator, QIntValidator
+from PyQt5.QtWidgets import QComboBox, QDialog, QDialogButtonBox, QFrame, QLabel, QLineEdit, QScrollArea, QTabWidget, QVBoxLayout, QWidget
+
+class TabDialog(QDialog):
+
+ def __init__(self, font, parent=None):
+ super(TabDialog, self).__init__(parent)
+
+ # TODO: figure a proper correspondence to set and fetch widgets...
+ self.tabs = {
+ "General": 0
+ }
+
+# fileInfo = QFileInfo(fileName)
+ self.font = font
+ self.tabWidget = QTabWidget()
+ self.tabWidget.addTab(GeneralTab(self.font), "General")
+# tabWidget.addTab(PermissionsTab(fileInfo), "OpenType")
+# tabWidget.addTab(ApplicationsTab(fileInfo), "PostScript")
+# tabWidget.addTab(ApplicationsTab(fileInfo), "Miscellaneous")
+
+ buttonBox = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel)
+
+ buttonBox.accepted.connect(self.accept)
+ buttonBox.rejected.connect(self.reject)
+
+ mainLayout = QVBoxLayout()
+ mainLayout.addWidget(self.tabWidget)
+ mainLayout.addWidget(buttonBox)
+ self.setLayout(mainLayout)
+
+ self.setWindowTitle("Font Info")
+
+ def accept(self):
+ self.font.info.familyName = self.tabWidget.widget(self.tabs["General"]).fileNameEdit.text()
+ self.font.info.styleName = self.tabWidget.widget(self.tabs["General"]).styleNameEdit.text()
+ self.font.info.styleMapFamilyName = self.tabWidget.widget(self.tabs["General"]).styleMapFamilyEdit.text()
+ sn = self.tabWidget.widget(self.tabs["General"]).styleMapStyleDrop.currentIndex()
+ print(sn)
+ if sn == 1: self.font.info.styleMapStyleName = "regular"
+ elif sn == 2: self.font.info.styleMapStyleName = "italic"
+ elif sn == 3: self.font.info.styleMapStyleName = "bold"
+ elif sn == 4: self.font.info.styleMapStyleName = "bold italic"
+ else: self.font.info.styleMapStyleName = None
+ self.font.info.versionMajor = int(self.tabWidget.widget(self.tabs["General"]).versionMajorEdit.text())
+ self.font.info.versionMinor = int(self.tabWidget.widget(self.tabs["General"]).versionMinorEdit.text())
+ super(TabDialog, self).accept()
+
+class GeneralTab(QWidget):
+ def __init__(self, font, parent=None):
+ super(GeneralTab, self).__init__(parent)
+
+ identLabel = QLabel("Identification")
+ identLine = QFrame()
+ identLine.setFrameShape(QFrame.HLine)
+
+ fileNameLabel = QLabel("Family name:")
+ self.fileNameEdit = QLineEdit(font.info.familyName)
+
+ styleNameLabel = QLabel("Style name:")
+ self.styleNameEdit = QLineEdit(font.info.styleName)
+
+ styleMapFamilyLabel = QLabel("Style map family name:")
+ self.styleMapFamilyEdit = QLineEdit(font.info.styleMapFamilyName)
+# self.styleMapFamilyCBox = QCheckBox("Use default value")
+
+ styleMapStyleLabel = QLabel("Style map style name:")
+ self.styleMapStyleDrop = QComboBox()
+# items = ["None", "Regular", "Italic", "Bold", "Bold Italic"]
+ styleMapStyle = {
+ "None": 0,
+ "Regular": 1,
+ "Italic": 2,
+ "Bold": 3,
+ "Bold Italic": 4
+ }
+ for name,index in styleMapStyle.items():
+ self.styleMapStyleDrop.insertItem(index, name)
+ sn = font.info.styleMapStyleName
+ # TODO: index to set is statically known, should eventually get rid of dict overhead if any?
+ if sn == "regular": self.styleMapStyleDrop.setCurrentIndex(styleMapStyle["Regular"])
+ elif sn == "regular italic": self.styleMapStyleDrop.setCurrentIndex(styleMapStyle["Italic"])
+ elif sn == "bold": self.styleMapStyleDrop.setCurrentIndex(styleMapStyle["Bold"])
+ elif sn == "bold italic": self.styleMapStyleDrop.setCurrentIndex(styleMapStyle["Bold Italic"])
+ else: self.styleMapStyleDrop.setCurrentIndex(styleMapStyle["None"])
+# self.styleMapStyleCBox = QCheckBox("Use default value")
+
+ # TODO: give visual feedback of input data validity using QLineEdit lose focus event
+ # http://snorf.net/blog/2014/08/09/using-qvalidator-in-pyqt4-to-validate-user-input/
+ versionLabel = QLabel("Version:")
+ self.versionMajorEdit = QLineEdit(str(font.info.versionMajor))
+ self.versionMajorEdit.setValidator(QIntValidator())
+ self.versionMinorEdit = QLineEdit(str(font.info.versionMinor))
+ self.versionMinorEdit.setValidator(QIntValidator())
+
+ dimensionsLabel = QLabel("Dimensions")
+ dimensionsLine = QFrame()
+ dimensionsLine.setFrameShape(QFrame.HLine)
+
+ unitsPerEmLabel = QLabel("Units per em:")
+ self.unitsPerEmEdit = QLineEdit(str(font.info.unitsPerEm))
+ self.unitsPerEmEdit.setValidator(QIntValidator())
+
+ ascenderLabel = QLabel("Ascender:")
+ self.ascenderEdit = QLineEdit(str(font.info.ascender))
+ self.ascenderEdit.setValidator(QIntValidator())
+
+ descenderLabel = QLabel("Descender:")
+ self.descenderEdit = QLineEdit(str(font.info.descender))
+ self.descenderEdit.setValidator(QIntValidator())
+
+ xHeightLabel = QLabel("x-height:")
+ self.xHeightEdit = QLineEdit(str(font.info.xHeight))
+ self.xHeightEdit.setValidator(QIntValidator())
+
+ capHeightLabel = QLabel("Cap height:")
+ self.capHeightEdit = QLineEdit(str(font.info.capHeight))
+ self.capHeightEdit.setValidator(QIntValidator())
+
+ italicAngleLabel = QLabel("Italic angle:")
+ self.italicAngleEdit = QLineEdit(str(font.info.italicAngle))
+ self.italicAngleEdit.setValidator(QDoubleValidator())
+
+ legalLabel = QLabel("Legal")
+ legalLine = QFrame()
+ legalLine.setFrameShape(QFrame.HLine)
+
+ copyrightLabel = QLabel("Copyright:")
+ self.copyrightEdit = QLineEdit(font.info.copyright)
+
+ trademarkLabel = QLabel("Trademark:")
+ self.trademarkEdit = QLineEdit(font.info.trademark)
+
+ licenseLabel = QLabel("License:")
+ self.licenseEdit = QLineEdit(font.info.openTypeNameLicense)
+
+ licenseURLLabel = QLabel("License URL:")
+ self.licenseURLEdit = QLineEdit(font.info.openTypeNameLicenseURL)
+
+ partiesLabel = QLabel("Parties")
+ partiesLine = QFrame()
+ partiesLine.setFrameShape(QFrame.HLine)
+
+ designerLabel = QLabel("Designer:")
+ self.designerEdit = QLineEdit(font.info.openTypeNameDesigner)
+
+ designerURLLabel = QLabel("Designer URL:")
+ self.designerURLEdit = QLineEdit(font.info.openTypeNameDesignerURL)
+
+ manufacturerLabel = QLabel("Manufacturer:")
+ self.manufacturerEdit = QLineEdit(font.info.openTypeNameManufacturer)
+
+ manufacturerURLLabel = QLabel("Manufacturer URL:")
+ self.manufacturerURLEdit = QLineEdit(font.info.openTypeNameManufacturerURL)
+
+ mainLayout = QVBoxLayout()
+ mainLayout.addWidget(identLabel)
+ mainLayout.addWidget(identLine)
+ mainLayout.addWidget(fileNameLabel)
+ mainLayout.addWidget(self.fileNameEdit)
+ mainLayout.addWidget(styleNameLabel)
+ mainLayout.addWidget(self.styleNameEdit)
+ mainLayout.addWidget(styleMapFamilyLabel)
+ mainLayout.addWidget(self.styleMapFamilyEdit)
+ mainLayout.addWidget(styleMapStyleLabel)
+ mainLayout.addWidget(self.styleMapStyleDrop)
+ mainLayout.addWidget(versionLabel)
+ mainLayout.addWidget(self.versionMajorEdit)
+ mainLayout.addWidget(self.versionMinorEdit)
+
+ mainLayout.addWidget(dimensionsLabel)
+ mainLayout.addWidget(dimensionsLine)
+ mainLayout.addWidget(unitsPerEmLabel)
+ mainLayout.addWidget(self.unitsPerEmEdit)
+ mainLayout.addWidget(ascenderLabel)
+ mainLayout.addWidget(self.ascenderEdit)
+ mainLayout.addWidget(descenderLabel)
+ mainLayout.addWidget(self.descenderEdit)
+ mainLayout.addWidget(xHeightLabel)
+ mainLayout.addWidget(self.xHeightEdit)
+ mainLayout.addWidget(capHeightLabel)
+ mainLayout.addWidget(self.capHeightEdit)
+ mainLayout.addWidget(italicAngleLabel)
+ mainLayout.addWidget(self.italicAngleEdit)
+
+ mainLayout.addWidget(legalLabel)
+ mainLayout.addWidget(legalLine)
+ mainLayout.addWidget(copyrightLabel)
+ mainLayout.addWidget(self.copyrightEdit)
+ mainLayout.addWidget(trademarkLabel)
+ mainLayout.addWidget(self.trademarkEdit)
+ mainLayout.addWidget(licenseLabel)
+ mainLayout.addWidget(self.licenseEdit)
+ mainLayout.addWidget(licenseURLLabel)
+ mainLayout.addWidget(self.licenseURLEdit)
+
+ mainLayout.addWidget(partiesLabel)
+ mainLayout.addWidget(partiesLine)
+ mainLayout.addWidget(designerLabel)
+ mainLayout.addWidget(self.designerEdit)
+ mainLayout.addWidget(designerURLLabel)
+ mainLayout.addWidget(self.designerURLEdit)
+ mainLayout.addWidget(manufacturerLabel)
+ mainLayout.addWidget(self.manufacturerEdit)
+ mainLayout.addWidget(manufacturerURLLabel)
+ mainLayout.addWidget(self.manufacturerURLEdit)
+ mainLayout.addStretch(1)
+
+ # http://nealbuerger.com/2013/11/pyside-qvboxlayout-with-qscrollarea/
+ # Why so many layers of indirection? It might be possible to do this
+ # in a simpler way...
+ widget = QWidget()
+ widget.setLayout(mainLayout)
+ scrollArea = QScrollArea()
+ scrollArea.setWidget(widget)
+ scrollArea.setMinimumSize(170, 200)
+ vLayout = QVBoxLayout()
+ vLayout.addWidget(scrollArea)
+
+ self.setLayout(vLayout) \ No newline at end of file
diff --git a/Lib/defconQt/representationFactories/__pycache__/__init__.cpython-34.pyc b/Lib/defconQt/representationFactories/__pycache__/__init__.cpython-34.pyc
deleted file mode 100644
index 56b40d2..0000000
--- a/Lib/defconQt/representationFactories/__pycache__/__init__.cpython-34.pyc
+++ /dev/null
Binary files differ
diff --git a/Lib/defconQt/spacecenter.py b/Lib/defconQt/spacecenter.py
new file mode 100644
index 0000000..f7b0707
--- /dev/null
+++ b/Lib/defconQt/spacecenter.py
@@ -0,0 +1,205 @@
+#!/usr/bin/env python
+
+
+#############################################################################
+##
+## Copyright (C) 2013 Riverbank Computing Limited.
+## Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+## All rights reserved.
+##
+## This file is part of the examples of PyQt.
+##
+## $QT_BEGIN_LICENSE:BSD$
+## You may use this file under the terms of the BSD license as follows:
+##
+## "Redistribution and use in source and binary forms, with or without
+## modification, are permitted provided that the following conditions are
+## met:
+## * Redistributions of source code must retain the above copyright
+## notice, this list of conditions and the following disclaimer.
+## * Redistributions in binary form must reproduce the above copyright
+## notice, this list of conditions and the following disclaimer in
+## the documentation and/or other materials provided with the
+## distribution.
+## * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+## the names of its contributors may be used to endorse or promote
+## products derived from this software without specific prior written
+## permission.
+##
+## THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+## "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+## LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+## A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+## OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+## SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+## LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+## DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+## THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+## (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+## OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+
+from math import cos, pi, sin
+
+from PyQt5.QtCore import QSize, Qt
+from PyQt5.QtGui import (QBrush, QColor, QFont, QLinearGradient, QPainter,
+ QPainterPath, QPalette, QPen)
+from PyQt5.QtWidgets import (QApplication, QComboBox, QGridLayout, QLabel,
+ QMainWindow, QSizePolicy, QSpinBox, QWidget)
+
+class MainSpaceWindow(QMainWindow):
+ def __init__(self, font, string, height=400, parent=None):
+ super(MainSpaceWindow, self).__init__(parent)
+
+ self.height = height
+ self.font = font
+ self.string = string
+# self.setupHelpMenu()
+ self.canvas = GlyphsCanvas(self.font, self.string, self.height, self)
+# self.resize(600,500)
+
+ self.setCentralWidget(self.canvas)
+ self.setWindowTitle("Space center")
+
+ def about(self):
+ QMessageBox.about(self, "About Syntax Highlighter",
+ "<p>The <b>Syntax Highlighter</b> example shows how to " \
+ "perform simple syntax highlighting by subclassing the " \
+ "QSyntaxHighlighter class and describing highlighting " \
+ "rules using regular expressions.</p>")
+
+ def newFile(self):
+ self.editor.clear()
+
+ def openFile(self, path=None):
+ if not path:
+ path, _ = QFileDialog.getOpenFileName(self, "Open File", '',
+ "C++ Files (*.cpp *.h)")
+
+ if path:
+ inFile = QFile(path)
+ if inFile.open(QFile.ReadOnly | QFile.Text):
+ text = inFile.readAll()
+
+ try:
+ # Python v3.
+ text = str(text, encoding='ascii')
+ except TypeError:
+ # Python v2.
+ text = str(text)
+
+ self.editor.setPlainText(text)
+
+ def save(self):
+ self.editor.write(self.features)
+
+ def setupFileMenu(self):
+ fileMenu = QMenu("&File", self)
+ self.menuBar().addMenu(fileMenu)
+
+# fileMenu.addAction("&New...", self.newFile, "Ctrl+N")
+# fileMenu.addAction("&Open...", self.openFile, "Ctrl+O")
+ fileMenu.addAction("&Save...", self.save, "Ctrl+S")
+ fileMenu.addAction("E&xit", QApplication.instance().quit, "Ctrl+Q")
+
+ def setupHelpMenu(self):
+ helpMenu = QMenu("&Help", self)
+ self.menuBar().addMenu(helpMenu)
+
+ helpMenu.addAction("&About", self.about)
+ helpMenu.addAction("About &Qt", QApplication.instance().aboutQt)
+
+class GlyphsCanvas(QWidget):
+ def __init__(self, font, string, height, parent=None):
+ super(GlyphsCanvas, self).__init__(parent)
+
+ self.font = font
+ self.string = string
+
+ self.height = height
+ self.padding = 30
+
+ self.penWidth = 1
+ self.rotationAngle = 0
+ self.setBackgroundRole(QPalette.Base)
+
+ '''
+ def minimumSizeHint(self):
+ return QSize(50, 50)
+
+ def sizeHint(self):
+ return QSize(100, 100)
+
+ def setFillRule(self, rule):
+ self.path.setFillRule(rule)
+ self.update()
+
+ def setFillGradient(self, color1, color2):
+ self.fillColor1 = color1
+ self.fillColor2 = color2
+ self.update()
+
+ def setPenWidth(self, width):
+ self.penWidth = width
+ self.update()
+
+ def setPenColor(self, color):
+ self.penColor = color
+ self.update()
+
+ def setRotationAngle(self, degrees):
+ self.rotationAngle = degrees
+ self.update()
+ '''
+
+ def paintEvent(self, event):
+ painter = QPainter(self)
+ painter.setRenderHint(QPainter.Antialiasing)
+ if self.font.info.unitsPerEm is None: return
+ if not self.font.info.unitsPerEm > 0: self.font.info.unitsPerEm = 1000
+ factor = self.height/(self.font.info.unitsPerEm*(1+2*.125))
+ painter.save()
+ painter.translate(self.padding, self.height+self.font.info.descender*factor)
+# painter.scale(self.width() / 100.0, self.height() / 100.0)
+# painter.rotate(-self.rotationAngle)
+# painter.translate(-50.0, -50.0)
+
+ width = 0
+ for c in self.string:
+ if c not in self.font: continue
+ glyph = self.font[c].getRepresentation("defconQt.QPainterPath")
+ painter.save()
+ painter.scale(factor, -factor)
+ painter.fillPath(glyph, Qt.black)
+ painter.restore()
+ painter.translate(self.font[c].width*factor, 0)
+ width += self.font[c].width*factor
+ painter.restore()
+# painter.fillRect(0, 0, width, self.height, Qt.white)
+# self.sizeHint(offset) whatever
+
+# for index, char in enumerate(self.string):
+
+ '''
+ painter.setPen(
+ QPen(self.penColor, self.penWidth, Qt.SolidLine, Qt.RoundCap,
+ Qt.RoundJoin))
+ gradient = QLinearGradient(0, 0, 0, 100)
+ gradient.setColorAt(0.0, self.fillColor1)
+ gradient.setColorAt(1.0, self.fillColor2)
+ painter.setBrush(QBrush(gradient))
+ painter.drawPath(self.path)
+ '''
+
+
+if __name__ == '__main__':
+
+ import sys
+# registerallfactories
+ app = QApplication(sys.argv)
+ window = Window()
+ window.show()
+ sys.exit(app.exec_())
diff --git a/Lib/defconQt/syntaxhighlighter.py b/Lib/defconQt/syntaxhighlighter.py
index 4db1c3e..c08d40a 100644
--- a/Lib/defconQt/syntaxhighlighter.py
+++ b/Lib/defconQt/syntaxhighlighter.py
@@ -48,9 +48,9 @@ from PyQt5.QtWidgets import (QApplication, QFileDialog, QMainWindow, QMenu,
QMessageBox, QTextEdit)
-class MainWindow(QMainWindow):
+class MainEditWindow(QMainWindow):
def __init__(self, features=None, parent=None):
- super(MainWindow, self).__init__(parent)
+ super(MainEditWindow, self).__init__(parent)
self.features = features
self.setupFileMenu()
@@ -89,7 +89,7 @@ class MainWindow(QMainWindow):
text = str(text)
self.editor.setPlainText(text)
-
+
def save(self):
self.editor.write(self.features)
@@ -97,8 +97,8 @@ class MainWindow(QMainWindow):
fileMenu = QMenu("&File", self)
self.menuBar().addMenu(fileMenu)
- fileMenu.addAction("&New...", self.newFile, "Ctrl+N")
- fileMenu.addAction("&Open...", self.openFile, "Ctrl+O")
+# fileMenu.addAction("&New...", self.newFile, "Ctrl+N")
+# fileMenu.addAction("&Open...", self.openFile, "Ctrl+O")
fileMenu.addAction("&Save...", self.save, "Ctrl+S")
fileMenu.addAction("E&xit", QApplication.instance().quit, "Ctrl+Q")
@@ -124,10 +124,10 @@ class TextEditor(QTextEdit):
self.text = text
self.highlighter = Highlighter(self.document())
-
+
def write(self, features):
features.text = self.toPlainText()
-
+
class Highlighter(QSyntaxHighlighter):
def __init__(self, parent=None):
super(Highlighter, self).__init__(parent)
diff --git a/Lib/defconQt/windows/__pycache__/baseWindow.cpython-34.pyc b/Lib/defconQt/windows/__pycache__/baseWindow.cpython-34.pyc
deleted file mode 100644
index 9814c61..0000000
--- a/Lib/defconQt/windows/__pycache__/baseWindow.cpython-34.pyc
+++ /dev/null
Binary files differ
diff --git a/Lib/defconQt/windows/__pycache__/progressWindow.cpython-34.pyc b/Lib/defconQt/windows/__pycache__/progressWindow.cpython-34.pyc
deleted file mode 100644
index ead3ca4..0000000
--- a/Lib/defconQt/windows/__pycache__/progressWindow.cpython-34.pyc
+++ /dev/null
Binary files differ