[fondue-commits] [SCM] Fondue Font Editor branch, master, updated. a4f9064b406b795fe91b4c357d58a68286684bae

Eugeniy Meshcheryakov eugen at debian.org
Thu Sep 6 14:11:16 UTC 2007


The branch, master has been updated
       via  a4f9064b406b795fe91b4c357d58a68286684bae (commit)
       via  592528ef6486aee587a45484e439b57b772a50a0 (commit)
       via  30c2b1fff9f69386216eacaca42acfbb0da96c8a (commit)
       via  8732278738dc9a2cc3cd7132fb6570b5c582cb86 (commit)
       via  bf1fe4e074afd7ccc5a9d6767cd0e737da44d662 (commit)
       via  b0e1c5c81bbc80b5c2be568524dfed71d952e8e7 (commit)
       via  d92cabe0f5001f1f742a5f3381ecba26ba0ada19 (commit)
       via  cd5e1db752c9707f0e70b2b3c257cdd25adf9447 (commit)
       via  b7b0ff2f165deec6374cbb20b90ea87f2dce1622 (commit)
       via  84f1fa2fcab10ef0181520d200b95448d1e6819b (commit)
      from  27cf9e647f964aa8405f8f640064c8a4bf67a88f (commit)


- Shortlog ------------------------------------------------------------
a4f9064 save maxp table
592528e read maxp table from xml file
30c2b1f import maxp table from sfd files
8732278 use data from FontDocument for maxp table
bf1fe4e add maxp editing support (no save/restore yet)
b0e1c5c return data also for Qt::EditRole
d92cabe return correct value from setData()
cd5e1db emit dataChanged() signal in setData()
b7b0ff2 raise max stack depth in maxp table
84f1fa2 remove some debug code, it generates too much output

Summary of changes:
 gui/gui.rules                 |    9 ++-
 gui/mainwindow.cxx            |   16 ++++++
 gui/mainwindow.h              |    5 ++
 gui/maxpeditor.cxx            |  113 +++++++++++++++++++++++++++++++++++++++++
 gui/maxpeditor.h              |   39 ++++++++++++++
 nongui/cvtmodel.cxx           |   17 ++++--
 nongui/fontdocument.cxx       |   67 ++++++++++++++++++++++++
 nongui/fontdocument.h         |   26 +++++++++
 nongui/fontdocumentreader.cxx |   64 +++++++++++++++++++++++
 nongui/fontdocumentreader.h   |    1 +
 nongui/fontdocumentwriter.cxx |    8 +++
 nongui/maxpmodel.cxx          |   91 +++++++++++++++++++++++++++++++++
 nongui/maxpmodel.h            |   34 ++++++++++++
 nongui/nongui.rules           |    6 ++-
 nongui/ttfencode.cxx          |    3 -
 nongui/ttfwriter.cxx          |   12 ++--
 scripts/conv.rb               |   16 ++++++-
 17 files changed, 507 insertions(+), 20 deletions(-)
-----------------------------------------------------------------------
Details of changes:

commit a4f9064b406b795fe91b4c357d58a68286684bae
Author: Eugeniy Meshcheryakov <eugen at debian.org>
Date:   Thu Sep 6 16:11:00 2007 +0200

    save maxp table

diff --git a/nongui/fontdocumentwriter.cxx b/nongui/fontdocumentwriter.cxx
index 4813493..e072ced 100644
--- a/nongui/fontdocumentwriter.cxx
+++ b/nongui/fontdocumentwriter.cxx
@@ -104,6 +104,14 @@ bool FontDocumentWriter::writeInstructionTables()
 		writeEndElement(); // cvt
 	}
 
+	writeEmptyElement("maxp");
+	writeAttribute("zones", QString::number(doc->zonesCount()));
+	writeAttribute("twilight", QString::number(doc->maxTwilightPoints()));
+	writeAttribute("storage", QString::number(doc->maxStorage()));
+	writeAttribute("funcs", QString::number(doc->maxFDEFs()));
+	writeAttribute("instrs", QString::number(doc->maxIDEFs()));
+	writeAttribute("stack", QString::number(doc->maxStackDepth()));
+
 	return true;
 }
 

commit 592528ef6486aee587a45484e439b57b772a50a0
Author: Eugeniy Meshcheryakov <eugen at debian.org>
Date:   Thu Sep 6 16:06:04 2007 +0200

    read maxp table from xml file

diff --git a/nongui/fontdocumentreader.cxx b/nongui/fontdocumentreader.cxx
index 7f56c74..ef64ea5 100644
--- a/nongui/fontdocumentreader.cxx
+++ b/nongui/fontdocumentreader.cxx
@@ -37,6 +37,7 @@ bool FontDocumentReader::read(QIODevice *device)
 			break;
 		}
 	}
+	doc->setChanged(false);
 	return !error();
 }
 
@@ -124,6 +125,8 @@ void FontDocumentReader::readFont()
 				readPrep();
 			else if (name() == "cvt")
 				readCvt();
+			else if (name() == "maxp")
+				readMaxp();
 			else if (name() == "glyphs")
 				readGlyphs();
 			else 
@@ -468,3 +471,64 @@ void FontDocumentReader::readCvt()
 		}
 	}
 }
+
+void FontDocumentReader::readMaxp()
+{
+	Q_ASSERT(isStartElement() && name() == "maxp");
+	QStringRef e = attributes().value("zones");
+	bool ok;
+	if (!e.isEmpty()) {
+		unsigned zones = c.toUInt(e.toString(), &ok);
+		if (!ok) {
+			raiseError("maxp: invalid value for attribute zones");
+			return;
+		}
+		doc->setZonesCount(zones);
+	}
+	e = attributes().value("twilight");
+	if (!e.isEmpty()) {
+		unsigned twilight = c.toUInt(e.toString(), &ok);
+		if (!ok) {
+			raiseError("maxp: invalid value for attribute twilight");
+			return;
+		}
+		doc->setMaxTwilightPoints(twilight);
+	}
+	e = attributes().value("storage");
+	if (!e.isEmpty()) {
+		unsigned storage = c.toUInt(e.toString(), &ok);
+		if (!ok) {
+			raiseError("maxp: invalid value for attribute storage");
+			return;
+		}
+		doc->setMaxStorage(storage);
+	}
+	e = attributes().value("funcs");
+	if (!e.isEmpty()) {
+		unsigned funcs = c.toUInt(e.toString(), &ok);
+		if (!ok) {
+			raiseError("maxp: invalid value for attribute funcs");
+			return;
+		}
+		doc->setMaxFDEFs(funcs);
+	}
+	e = attributes().value("instrs");
+	if (!e.isEmpty()) {
+		unsigned instrs = c.toUInt(e.toString(), &ok);
+		if (!ok) {
+			raiseError("maxp: invalid value for attribute instrs");
+			return;
+		}
+		doc->setMaxIDEFs(instrs);
+	}
+	e = attributes().value("stack");
+	if (!e.isEmpty()) {
+		unsigned stack = c.toUInt(e.toString(), &ok);
+		if (!ok) {
+			raiseError("maxp: invalid value for attribute stack");
+			return;
+		}
+		doc->setMaxStackDepth(stack);
+	}
+	readUnknownElement();
+}
diff --git a/nongui/fontdocumentreader.h b/nongui/fontdocumentreader.h
index 7b3631f..138b715 100644
--- a/nongui/fontdocumentreader.h
+++ b/nongui/fontdocumentreader.h
@@ -54,6 +54,7 @@ private:
 	void readFeature(Lookup &lookup);
 	void readScript(Lookup &lookup);
 	void readCvt();
+	void readMaxp();
 
 	QLocale c;
 };

commit 30c2b1fff9f69386216eacaca42acfbb0da96c8a
Author: Eugeniy Meshcheryakov <eugen at debian.org>
Date:   Thu Sep 6 15:43:39 2007 +0200

    import maxp table from sfd files

diff --git a/scripts/conv.rb b/scripts/conv.rb
index 0533f8c..2bbbcf2 100755
--- a/scripts/conv.rb
+++ b/scripts/conv.rb
@@ -66,7 +66,21 @@ def read_file(f, doc)
 	    cv["v"] = v.to_s
 	  end
 	when "maxp"
-	  # TODO
+	  raise("Bad maxp table nbytes = #{nbytes}") if (nbytes.to_i != 32)
+	  maxpTable = Fe::decode_ascii85(data, nbytes.to_i).unpack("n*");
+	  maxZones = maxpTable[7];
+	  maxTwilightPoints = maxpTable[8];
+	  maxStorage = maxpTable[9];
+	  maxFDEFs = maxpTable[10];
+	  maxIDEFs = maxpTable[11];
+	  maxStackDepth = maxpTable[12];
+	  doc.root << maxp = XML::Node.new("maxp");
+	  maxp["zones"] = maxZones.to_s;
+	  maxp["twilight"] = maxTwilightPoints.to_s;
+	  maxp["storage"] = maxStorage.to_s;
+	  maxp["funcs"] = maxFDEFs.to_s;
+	  maxp["instrs"] = maxIDEFs.to_s;
+	  maxp["stack"] = maxStackDepth.to_s;
 	else
 	  raise "Unknown truetype table: #{tname}"
 	end

commit 8732278738dc9a2cc3cd7132fb6570b5c582cb86
Author: Eugeniy Meshcheryakov <eugen at debian.org>
Date:   Thu Sep 6 15:33:49 2007 +0200

    use data from FontDocument for maxp table

diff --git a/nongui/ttfwriter.cxx b/nongui/ttfwriter.cxx
index 9dda707..7b27e24 100644
--- a/nongui/ttfwriter.cxx
+++ b/nongui/ttfwriter.cxx
@@ -423,12 +423,12 @@ bool TTFWriter::writeMaxp()
 	ret = ret && writeBigEndian(&buffer, (qint16)100); // FIXME Max number of contours in non-composite glyph
 	ret = ret && writeBigEndian(&buffer, (qint16)100); // FIXME Max number of points in composite glyph
 	ret = ret && writeBigEndian(&buffer, (qint16)100); // FIXME Max number of contours in composite glyph
-	ret = ret && writeBigEndian(&buffer, (qint16)2); // Max number of zones
-	ret = ret && writeBigEndian(&buffer, (qint16)100); // FIXME Max number of points in Z0
-	ret = ret && writeBigEndian(&buffer, (qint16)100); // FIXME Max storage
-	ret = ret && writeBigEndian(&buffer, (qint16)100); // FIXME Number of FDEFs
-	ret = ret && writeBigEndian(&buffer, (qint16)100); // FIXME Number of IDEFs
-	ret = ret && writeBigEndian(&buffer, (qint16)10000); // FIXME Max stack depth
+	ret = ret && writeBigEndian(&buffer, (qint16)m_doc->zonesCount()); // Max number of zones
+	ret = ret && writeBigEndian(&buffer, (qint16)m_doc->maxTwilightPoints()); // Max number of points in Z0
+	ret = ret && writeBigEndian(&buffer, (qint16)m_doc->maxStorage()); // Max storage
+	ret = ret && writeBigEndian(&buffer, (qint16)m_doc->maxFDEFs()); // Number of FDEFs
+	ret = ret && writeBigEndian(&buffer, (qint16)m_doc->maxIDEFs()); // Number of IDEFs
+	ret = ret && writeBigEndian(&buffer, (qint16)m_doc->maxStackDepth()); // Max stack depth
 	ret = ret && writeBigEndian(&buffer, (qint16)10000); // FIXME Max size of instructions
 	ret = ret && writeBigEndian(&buffer, (qint16)100); // FIXME Max top-level components
 	ret = ret && writeBigEndian(&buffer, (qint16)100); // FIXME Max levels of recursion

commit bf1fe4e074afd7ccc5a9d6767cd0e737da44d662
Author: Eugeniy Meshcheryakov <eugen at debian.org>
Date:   Thu Sep 6 15:29:14 2007 +0200

    add maxp editing support (no save/restore yet)

diff --git a/gui/gui.rules b/gui/gui.rules
index 254a9bf..597d266 100644
--- a/gui/gui.rules
+++ b/gui/gui.rules
@@ -16,7 +16,8 @@ libfonduegui_a_SOURCES =		\
 	gui/colorcombobox.cxx		\
 	gui/unicodevalueeditor.cxx	\
 	gui/unicodeproxymodel.cxx	\
-	gui/cvteditor.cxx
+	gui/cvteditor.cxx		\
+	gui/maxpeditor.cxx
 
 nodist_libfonduegui_a_SOURCES =			\
 	gui/ttihighlighter.moc.cxx		\
@@ -32,7 +33,8 @@ nodist_libfonduegui_a_SOURCES =			\
 	gui/glyphsmodel.moc.cxx			\
 	gui/glyphsmodeldelegate.moc.cxx		\
 	gui/unicodeproxymodel.moc.cxx		\
-	gui/cvteditor.moc.cxx
+	gui/cvteditor.moc.cxx			\
+	gui/maxpeditor.moc.cxx
 
 gui/instnames.tbl.cxx: data/instructions.xml
 gui/instnames.tbl.cxx: DATAFILE=$(srcdir)/data/instructions.xml
@@ -55,7 +57,8 @@ noinst_HEADERS += 			\
 	gui/unicodevalueeditor.h	\
 	gui/colorcombobox.h		\
 	gui/unicodeproxymodel.h		\
-	gui/cvteditor.h
+	gui/cvteditor.h			\
+	gui/maxpeditor.h
 
 CLEANFILES += gui/*.moc.cxx gui/*.tbl.cxx
 EXTRA_DIST += gui/instnames.xsl
diff --git a/gui/mainwindow.cxx b/gui/mainwindow.cxx
index c6ea988..9e91046 100644
--- a/gui/mainwindow.cxx
+++ b/gui/mainwindow.cxx
@@ -35,6 +35,8 @@
 #include "cvtmodel.h"
 #include "cvteditor.h"
 #include "ttfwriter.h"
+#include "maxpeditor.h"
+#include "maxpmodel.h"
 
 #include "config.h"
 
@@ -101,6 +103,9 @@ void MainWindow::createActions()
 	editCvtAction = new QAction("Edit cvt Table...", this);
 	connect(editCvtAction, SIGNAL(triggered()), this, SLOT(editCvt()));
 
+	editMaxpAction = new QAction("Edit maxp Table...", this);
+	connect(editMaxpAction, SIGNAL(triggered()), this, SLOT(editMaxp()));
+
 	aboutAction = new QAction("About Fondue...", this);
 	connect(aboutAction, SIGNAL(triggered()), this, SLOT(about()));
 
@@ -110,6 +115,7 @@ void MainWindow::createActions()
 	editPrepAction->setEnabled(false);
 	editFpgmAction->setEnabled(false);
 	editCvtAction->setEnabled(false);
+	editMaxpAction->setEnabled(false);
 
 	connect(this, SIGNAL(documentAvailable(bool)), saveAction, SLOT(setEnabled(bool)));
 	connect(this, SIGNAL(documentAvailable(bool)), saveAsAction, SLOT(setEnabled(bool)));
@@ -117,6 +123,7 @@ void MainWindow::createActions()
 	connect(this, SIGNAL(documentAvailable(bool)), editPrepAction, SLOT(setEnabled(bool)));
 	connect(this, SIGNAL(documentAvailable(bool)), editFpgmAction, SLOT(setEnabled(bool)));
 	connect(this, SIGNAL(documentAvailable(bool)), editCvtAction, SLOT(setEnabled(bool)));
+	connect(this, SIGNAL(documentAvailable(bool)), editMaxpAction, SLOT(setEnabled(bool)));
 }
 
 void MainWindow::createMenus()
@@ -139,6 +146,7 @@ void MainWindow::createMenus()
 	instructionsMenu->addAction(editPrepAction);
 	instructionsMenu->addAction(editFpgmAction);
 	instructionsMenu->addAction(editCvtAction);
+	instructionsMenu->addAction(editMaxpAction);
 
 	menuBar()->addSeparator();
 
@@ -202,6 +210,7 @@ void MainWindow::setupModels()
 	unicodeProxy->setSourceModel(model);
 
 	cvtModel = new CVTModel(m_doc, this);
+	maxpModel = new MAXPModel(m_doc, this);
 }
 
 void MainWindow::changeDocumentName(const QString &name)
@@ -352,6 +361,13 @@ void MainWindow::editCvt()
 	editor->show();
 }
 
+void MainWindow::editMaxp()
+{
+	MAXPEditor *editor = new MAXPEditor(maxpModel, this);
+	editor->setWindowTitle(QString("MAXP in %1").arg(m_doc->fontName()));
+	editor->show();
+}
+
 void MainWindow::about()
 {
 	// TODO add some information
diff --git a/gui/mainwindow.h b/gui/mainwindow.h
index 8e9ea2f..8eec09f 100644
--- a/gui/mainwindow.h
+++ b/gui/mainwindow.h
@@ -28,6 +28,7 @@ class QModelIndex;
 class QActionGroup;
 class UnicodeProxyModel;
 class CVTModel;
+class MAXPModel;
 
 class MainWindow: public QMainWindow {
 	Q_OBJECT
@@ -47,6 +48,7 @@ public slots:
 	void editPrep();
 	void editFpgm();
 	void editCvt();
+	void editMaxp();
 
 	void about();
 
@@ -96,12 +98,15 @@ private:
 	QAction *editPrepAction;
 	QAction *editFpgmAction;
 	QAction *editCvtAction;
+	QAction *editMaxpAction;
+
 	QAction *aboutAction;
 
 	GlyphsGridWidget *glyphsView;
 	GlyphsModel *model;
 	UnicodeProxyModel *unicodeProxy;
 	CVTModel *cvtModel;
+	MAXPModel *maxpModel;
 };
 
 #endif
diff --git a/gui/maxpeditor.cxx b/gui/maxpeditor.cxx
new file mode 100644
index 0000000..d6ac432
--- /dev/null
+++ b/gui/maxpeditor.cxx
@@ -0,0 +1,113 @@
+/* Copyright (C) 2007 Євгеній Мещеряков <eugen at debian.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
+ */
+#include "maxpeditor.h"
+#include <QGridLayout>
+#include <QLabel>
+#include <QSpinBox>
+#include <QDialogButtonBox>
+#include <QDataWidgetMapper>
+#include "maxpmodel.h"
+
+MAXPEditor::MAXPEditor(QAbstractItemModel *model, QWidget *parent) : QDialog(parent)
+{
+	Q_ASSERT(model);
+
+	setAttribute(Qt::WA_DeleteOnClose);
+
+	QLabel *zonesLabel = new QLabel("Zones:");
+	QSpinBox *zonesEdit = new QSpinBox; // TODO use something else
+	zonesEdit->setMinimum(1);
+	zonesEdit->setMaximum(2);
+
+	QLabel *twilightPtsLabel = new QLabel("Twilight Points:");
+	QSpinBox *twilightPtsEdit = new QSpinBox;
+	twilightPtsEdit->setMaximum(0xFFFF);
+
+	QLabel *storageLabel = new QLabel("Storage:");
+	QSpinBox *storageEdit = new QSpinBox;
+	storageEdit->setMaximum(0xFFFF);
+
+	QLabel *stackLabel = new QLabel("Max Stack Depth:");
+	QSpinBox *stackEdit = new QSpinBox;
+	stackEdit->setMaximum(0xFFFF);
+
+	QLabel *FDEFsLabel = new QLabel("FDEFs:");
+	QSpinBox *FDEFsEdit = new QSpinBox;
+	FDEFsEdit->setMaximum(0xFFFF);
+
+	QLabel *IDEFsLabel = new QLabel("IDEFs:");
+	QSpinBox *IDEFsEdit = new QSpinBox;
+	IDEFsEdit->setMaximum(0xFFFF);
+
+	buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok |
+			QDialogButtonBox::Cancel | QDialogButtonBox::Apply);
+	connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
+	connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
+	connect(buttonBox, SIGNAL(clicked(QAbstractButton *)),
+			this, SLOT(buttonClicked(QAbstractButton *)));
+
+	QGridLayout *grid = new QGridLayout();	
+	grid->addWidget(zonesLabel, 0, 0);
+	grid->addWidget(zonesEdit, 0, 1);
+	grid->addWidget(twilightPtsLabel, 0, 2);
+	grid->addWidget(twilightPtsEdit, 0, 3);
+
+	grid->addWidget(storageLabel, 1, 0);
+	grid->addWidget(storageEdit, 1, 1);
+	grid->addWidget(stackLabel, 1, 2);
+	grid->addWidget(stackEdit, 1, 3);
+
+	grid->addWidget(FDEFsLabel, 2, 0);
+	grid->addWidget(FDEFsEdit, 2, 1);
+	grid->addWidget(IDEFsLabel, 2, 2);
+	grid->addWidget(IDEFsEdit, 2, 3);
+
+	grid->addWidget(buttonBox, 4, 0, 1, 4);
+	
+	// resizeable columns and rows
+	grid->setRowStretch(3, 1);
+	grid->setColumnStretch(1, 1);
+	grid->setColumnStretch(3, 1);
+
+	setLayout(grid);
+
+	mapper = new QDataWidgetMapper(this);
+	mapper->setModel(model);
+	mapper->setOrientation(Qt::Vertical);
+
+	mapper->addMapping(zonesEdit, MAXPModel::ZonesRow, "value");
+	mapper->addMapping(twilightPtsEdit, MAXPModel::TwilightPointsRow, "value");
+	mapper->addMapping(storageEdit, MAXPModel::StorageRow, "value");
+	mapper->addMapping(stackEdit, MAXPModel::MaxStackRow, "value");
+	mapper->addMapping(FDEFsEdit, MAXPModel::FDEFsRow, "value");
+	mapper->addMapping(IDEFsEdit, MAXPModel::IDEFsRow, "value");
+
+	mapper->setSubmitPolicy(QDataWidgetMapper::ManualSubmit);
+	mapper->toFirst();
+}
+
+void MAXPEditor::buttonClicked(QAbstractButton *button)
+{
+	if (buttonBox->buttonRole(button) == QDialogButtonBox::ApplyRole)
+		mapper->submit();
+}
+
+void MAXPEditor::accept()
+{
+	mapper->submit();
+	QDialog::accept();
+}
diff --git a/gui/glyphpropertieseditor.h b/gui/maxpeditor.h
similarity index 81%
copy from gui/glyphpropertieseditor.h
copy to gui/maxpeditor.h
index a2eef37..60ba187 100644
--- a/gui/glyphpropertieseditor.h
+++ b/gui/maxpeditor.h
@@ -14,29 +14,26 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
  */
-#ifndef GLYPHPROPERTIESEDITOR_H
-#define GLYPHPROPERTIESEDITOR_H
+#ifndef MAXPEDITOR_H
+#define MAXPEDITOR_H
 #include <QDialog>
 
+class QDialogButtonBox;
+class QAbstractButton;
 class QAbstractItemModel;
 class QDataWidgetMapper;
-class QModelIndex;
-class QAbstractButton;
-class QDialogButtonBox;
 
-class GlyphPropertiesEditor : public QDialog
+class MAXPEditor : public QDialog
 {
 	Q_OBJECT
 public:
-	GlyphPropertiesEditor(QAbstractItemModel *model, const QModelIndex &item, QWidget *parent = 0);
+	MAXPEditor(QAbstractItemModel *model, QWidget *parent = 0);
 public slots:
-	void accept();
-	void next();
-	void previous();
 	void buttonClicked(QAbstractButton *button);
+	void accept();
 private:
-	QDataWidgetMapper *mapper;
 	QDialogButtonBox *buttonBox;
+	QDataWidgetMapper *mapper;
 };
 
 #endif
diff --git a/nongui/fontdocument.cxx b/nongui/fontdocument.cxx
index 3b4f4e9..2338efd 100644
--- a/nongui/fontdocument.cxx
+++ b/nongui/fontdocument.cxx
@@ -145,3 +145,70 @@ void FontDocument::insertCvtEntries(int first, int count)
 	m_cvt.insert(first, count, CVTEntry());
 	setChanged();
 }
+
+bool FontDocument::setZonesCount(unsigned count)
+{
+	// font can only have one or two zones
+	if (count != 1 && count != 2)
+		return false;
+	if (count != maxp.zonesCount) {
+		maxp.zonesCount = count;
+		setChanged();
+	}
+	return true;
+}
+
+bool FontDocument::setMaxTwilightPoints(unsigned count)
+{
+	if (count > 0xFFFF)
+		count = 0xFFFF;
+	if (maxp.maxTwilightPoints != count) {
+		maxp.maxTwilightPoints = count;
+		setChanged();
+	}
+	return true;
+}
+
+bool FontDocument::setMaxStorage(unsigned size)
+{
+	if (size > 0xFFFF)
+		size = 0xFFFF;
+	if (maxp.maxStorage != size) {
+		maxp.maxStorage = size;
+		setChanged();
+	}
+	return true;
+}
+
+bool FontDocument::setMaxFDEFs(unsigned count)
+{
+	if (count > 0xFFFF)
+		count = 0xFFFF;
+	if (maxp.maxFDEFs != count) {
+		maxp.maxFDEFs = count;
+		setChanged();
+	}
+	return true;
+}
+
+bool FontDocument::setMaxIDEFs(unsigned count)
+{
+	if (count > 0xFFFF)
+		count = 0xFFFF;
+	if (maxp.maxIDEFs != count) {
+		maxp.maxIDEFs = count;
+		setChanged();
+	}
+	return true;
+}
+
+bool FontDocument::setMaxStackDepth(unsigned depth)
+{
+	if (depth > 0xFFFF)
+		depth = 0xFFFF;
+	if (maxp.maxStackDepth != depth) {
+		maxp.maxStackDepth = depth;
+		setChanged();
+	}
+	return true;
+}
diff --git a/nongui/fontdocument.h b/nongui/fontdocument.h
index b01d6a1..7dc87da 100644
--- a/nongui/fontdocument.h
+++ b/nongui/fontdocument.h
@@ -125,6 +125,20 @@ public:
 	bool changeCvtEntry(int index, const CVTEntry &newEntry);
 	void removeCvtEntries(int first, int count);
 	void insertCvtEntries(int first, int count);
+
+	// maxp table related functions
+	unsigned zonesCount() const {return maxp.zonesCount;}
+	bool setZonesCount(unsigned count);
+	unsigned maxTwilightPoints() const {return maxp.maxTwilightPoints;}
+	bool setMaxTwilightPoints(unsigned count);
+	unsigned maxStorage() const {return maxp.maxStorage;}
+	bool setMaxStorage(unsigned size);
+	unsigned maxFDEFs() const {return maxp.maxFDEFs;}
+	bool setMaxFDEFs(unsigned count);
+	unsigned maxIDEFs() const {return maxp.maxIDEFs;}
+	bool setMaxIDEFs(unsigned count);
+	unsigned maxStackDepth() const {return maxp.maxStackDepth;}
+	bool setMaxStackDepth(unsigned depth);
 signals:
 	void documentChanged();
 private:
@@ -142,6 +156,17 @@ private:
 		/* TODO panose */ 
 	};
 
+	class MAXPData {
+	public:
+		MAXPData() : zonesCount(1), maxTwilightPoints(0), maxStorage(0), maxFDEFs(0), maxIDEFs(0), maxStackDepth(0) {}
+		unsigned zonesCount;
+		unsigned maxTwilightPoints;
+		unsigned maxStorage;
+		unsigned maxFDEFs;
+		unsigned maxIDEFs;
+		unsigned maxStackDepth;
+	};
+
 	QString m_copyright;
 	QString m_prep;
 	QString m_fpgm;
@@ -151,6 +176,7 @@ private:
 	QHash<int, Glyph *> unicodeHash;
 	FontFace m_fontFace;
 	bool m_documentChanged;
+	MAXPData maxp;
 };
 
 #endif
diff --git a/nongui/maxpmodel.cxx b/nongui/maxpmodel.cxx
new file mode 100644
index 0000000..0001373
--- /dev/null
+++ b/nongui/maxpmodel.cxx
@@ -0,0 +1,91 @@
+/* Copyright (C) 2007 Євгеній Мещеряков <eugen at debian.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
+ */
+#include "maxpmodel.h"
+#include "fontdocument.h"
+
+MAXPModel::MAXPModel(FontDocument *doc, QObject *parent) : QAbstractListModel(parent), m_doc(doc)
+{
+	Q_ASSERT(m_doc);
+}
+
+int MAXPModel::rowCount(const QModelIndex &parent) const
+{
+	if (parent.isValid())
+		return 0;
+	return NRows;
+}
+
+QVariant MAXPModel::data(const QModelIndex &index, int role) const
+{
+	if (!index.isValid() || index.column() != 0)
+		return QVariant();
+	if (role == Qt::DisplayRole || role == Qt::EditRole) {
+		switch (index.row()) {
+		case ZonesRow:
+			return m_doc->zonesCount();
+		case TwilightPointsRow:
+			return m_doc->maxTwilightPoints();
+		case StorageRow:
+			return m_doc->maxStorage();
+		case FDEFsRow:
+			return m_doc->maxFDEFs();
+		case IDEFsRow:
+			return m_doc->maxIDEFs();
+		case MaxStackRow:
+			return m_doc->maxStackDepth();
+		default:
+			return QVariant();
+		}
+	}
+	return QVariant();
+}
+
+bool MAXPModel::setData(const QModelIndex &index, const QVariant &value, int role)
+{
+	if (!index.isValid() || index.column() != 0)
+		return false;
+
+	bool ret = false;
+
+	if (role == Qt::EditRole) {
+		switch (index.row()) {
+		case ZonesRow:
+			ret = m_doc->setZonesCount(value.toUInt());
+			break;
+		case TwilightPointsRow:
+			ret = m_doc->setMaxTwilightPoints(value.toUInt());
+			break;
+		case StorageRow:
+			ret = m_doc->setMaxStorage(value.toUInt());
+			break;
+		case FDEFsRow:
+			ret = m_doc->setMaxFDEFs(value.toUInt());
+			break;
+		case IDEFsRow:
+			ret = m_doc->setMaxIDEFs(value.toUInt());
+			break;
+		case MaxStackRow:
+			ret = m_doc->setMaxStackDepth(value.toUInt());
+			break;
+		default:
+			break;
+		}
+		if (ret)
+			emit dataChanged(index, index);
+	}
+	return ret;
+}
diff --git a/nongui/cvtmodel.h b/nongui/maxpmodel.h
similarity index 64%
copy from nongui/cvtmodel.h
copy to nongui/maxpmodel.h
index 771a606..353ee66 100644
--- a/nongui/cvtmodel.h
+++ b/nongui/maxpmodel.h
@@ -14,24 +14,19 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
  */
-#ifndef CVTMODEL_H
-#define CVTMODEL_H
-#include <QAbstractTableModel>
+#ifndef MAXPMODEL_H
+#define MAXPMODEL_H
+#include <QAbstractListModel>
 
 class FontDocument;
 
-class CVTModel : public QAbstractTableModel {
+class MAXPModel : public QAbstractListModel {
 public:
-	enum {ValueColumn, VariableColumn, CommentColumn, NColumns};
-	CVTModel(FontDocument *doc, QObject *parent = 0);
+	enum {ZonesRow, TwilightPointsRow, StorageRow, FDEFsRow, IDEFsRow, MaxStackRow, NRows};
+	MAXPModel(FontDocument *doc, QObject *parent = 0);
 	int rowCount(const QModelIndex &parent = QModelIndex()) const;
-	int columnCount(const QModelIndex &parent = QModelIndex()) const;
 	QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
-	QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
 	bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole);
-	Qt::ItemFlags flags(const QModelIndex &index) const;
-	bool removeRows(int row, int count, const QModelIndex &parent = QModelIndex());
-	bool insertRows(int row, int count, const QModelIndex &parent = QModelIndex());
 private:
 	FontDocument *m_doc;
 };
diff --git a/nongui/nongui.rules b/nongui/nongui.rules
index 2146829..2a3dfcd 100644
--- a/nongui/nongui.rules
+++ b/nongui/nongui.rules
@@ -8,7 +8,8 @@ libfonduenongui_a_SOURCES =		\
 	nongui/ttfencode.cxx		\
 	nongui/cvtmodel.cxx		\
 	nongui/ttfwriter.cxx		\
-	nongui/glyph.cxx
+	nongui/glyph.cxx		\
+	nongui/maxpmodel.cxx
 
 nodist_libfonduenongui_a_SOURCES = 	\
 	nongui/decodertable.tbl.cxx	\
@@ -40,7 +41,8 @@ noinst_HEADERS +=			\
 	nongui/script.h			\
 	nongui/ttfencode.h		\
 	nongui/cvtmodel.h		\
-	nongui/ttfwriter.h
+	nongui/ttfwriter.h		\
+	nongui/maxpmodel.h
 
 EXTRA_DIST +=			\
 	nongui/decodertable.xsl	\

commit b0e1c5c81bbc80b5c2be568524dfed71d952e8e7
Author: Eugeniy Meshcheryakov <eugen at debian.org>
Date:   Thu Sep 6 15:27:17 2007 +0200

    return data also for Qt::EditRole

diff --git a/nongui/cvtmodel.cxx b/nongui/cvtmodel.cxx
index 0a5a935..a67902d 100644
--- a/nongui/cvtmodel.cxx
+++ b/nongui/cvtmodel.cxx
@@ -43,7 +43,7 @@ QVariant CVTModel::data(const QModelIndex &index, int role) const
 	if (!index.isValid())
 		return QVariant();
 
-	if (role == Qt::DisplayRole) {
+	if (role == Qt::DisplayRole || role == Qt::DisplayRole) {
 		Q_ASSERT(index.row() >= 0 && index.row() < m_doc->cvt().size());
 		switch (index.column()) {
 		case ValueColumn:

commit d92cabe0f5001f1f742a5f3381ecba26ba0ada19
Author: Eugeniy Meshcheryakov <eugen at debian.org>
Date:   Thu Sep 6 15:02:43 2007 +0200

    return correct value from setData()

diff --git a/nongui/cvtmodel.cxx b/nongui/cvtmodel.cxx
index 81d9f34..0a5a935 100644
--- a/nongui/cvtmodel.cxx
+++ b/nongui/cvtmodel.cxx
@@ -112,10 +112,10 @@ bool CVTModel::setData(const QModelIndex &index, const QVariant &value, int role
 		default:
 			break;
 		}
+		if (ret)
+			emit dataChanged(index, index);
 	}
-	if (ret)
-		emit dataChanged(index, index);
-	return false;
+	return ret;
 }
 
 Qt::ItemFlags CVTModel::flags(const QModelIndex &index) const

commit cd5e1db752c9707f0e70b2b3c257cdd25adf9447
Author: Eugeniy Meshcheryakov <eugen at debian.org>
Date:   Thu Sep 6 14:59:21 2007 +0200

    emit dataChanged() signal in setData()

diff --git a/nongui/cvtmodel.cxx b/nongui/cvtmodel.cxx
index b283206..81d9f34 100644
--- a/nongui/cvtmodel.cxx
+++ b/nongui/cvtmodel.cxx
@@ -85,6 +85,8 @@ bool CVTModel::setData(const QModelIndex &index, const QVariant &value, int role
 
 	Q_ASSERT(index.row() >= 0 && index.row() < m_doc->cvt().size());
 
+	bool ret = false;
+
 	if (role == Qt::EditRole) {
 		CVTEntry newEntry = m_doc->cvt().at(index.row());
 
@@ -93,21 +95,26 @@ bool CVTModel::setData(const QModelIndex &index, const QVariant &value, int role
 			if (!value.canConvert<int>())
 				return false;
 			newEntry.setValue(value.toInt());
-			return m_doc->changeCvtEntry(index.row(), newEntry);
+			ret = m_doc->changeCvtEntry(index.row(), newEntry);
+			break;
 		case VariableColumn:
 			if (!value.canConvert<QString>())
 				return false;
 			newEntry.setVariableName(value.toString());
-			return m_doc->changeCvtEntry(index.row(), newEntry);
+			ret = m_doc->changeCvtEntry(index.row(), newEntry);
+			break;
 		case CommentColumn:
 			if (!value.canConvert<QString>())
 				return false;
 			newEntry.setComment(value.toString());
-			return m_doc->changeCvtEntry(index.row(), newEntry);
+			ret =  m_doc->changeCvtEntry(index.row(), newEntry);
+			break;
 		default:
 			break;
 		}
 	}
+	if (ret)
+		emit dataChanged(index, index);
 	return false;
 }
 

commit b7b0ff2f165deec6374cbb20b90ea87f2dce1622
Author: Eugeniy Meshcheryakov <eugen at debian.org>
Date:   Thu Sep 6 11:17:37 2007 +0200

    raise max stack depth in maxp table

diff --git a/nongui/ttfwriter.cxx b/nongui/ttfwriter.cxx
index 5ed9752..9dda707 100644
--- a/nongui/ttfwriter.cxx
+++ b/nongui/ttfwriter.cxx
@@ -428,7 +428,7 @@ bool TTFWriter::writeMaxp()
 	ret = ret && writeBigEndian(&buffer, (qint16)100); // FIXME Max storage
 	ret = ret && writeBigEndian(&buffer, (qint16)100); // FIXME Number of FDEFs
 	ret = ret && writeBigEndian(&buffer, (qint16)100); // FIXME Number of IDEFs
-	ret = ret && writeBigEndian(&buffer, (qint16)1000); // FIXME Max stack depth
+	ret = ret && writeBigEndian(&buffer, (qint16)10000); // FIXME Max stack depth
 	ret = ret && writeBigEndian(&buffer, (qint16)10000); // FIXME Max size of instructions
 	ret = ret && writeBigEndian(&buffer, (qint16)100); // FIXME Max top-level components
 	ret = ret && writeBigEndian(&buffer, (qint16)100); // FIXME Max levels of recursion

commit 84f1fa2fcab10ef0181520d200b95448d1e6819b
Author: Eugeniy Meshcheryakov <eugen at debian.org>
Date:   Fri Aug 31 22:44:15 2007 +0200

    remove some debug code, it generates too much output

diff --git a/nongui/ttfencode.cxx b/nongui/ttfencode.cxx
index 9395554..13eb096 100644
--- a/nongui/ttfencode.cxx
+++ b/nongui/ttfencode.cxx
@@ -75,7 +75,6 @@ QString TTInstructionsEncoder::readToken()
 				return 0;
 			QString token = rx.cap(1);
 			inputOffset = pos + token.size();
-			qDebug() << "Token:" << token;
 			return token;
 		}
 	}
@@ -86,7 +85,6 @@ void TTInstructionsEncoder::putToken(const QString &token)
 {
 	Q_ASSERT(savedToken.isEmpty());
 
-	qDebug() << "Push:" << token;
 	savedToken = token;
 }
 
@@ -95,7 +93,6 @@ QString TTInstructionsEncoder::nextToken()
 	if (!savedToken.isEmpty()) {
 		QString ret = savedToken;
 		savedToken.clear();
-		qDebug() << "Saved token:" << ret;
 		return ret;
 	}
 	return readToken();

-- 
Fondue Font Editor



More information about the fondue-commits mailing list