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

Eugeniy Meshcheryakov eugen at debian.org
Tue Dec 25 16:04:21 UTC 2007


The branch, master has been updated
       via  fa7010f30f1b10e5e400fca09c676f75d93fa55b (commit)
       via  c11abd3b74b58ab3ad587a0b3c54ab502ac211a7 (commit)
       via  9c827ffc8e17243c3096dade7b97bc8f1e0b7a58 (commit)
       via  64713febaf6ec234e2f20102644319512cfb441a (commit)
       via  e33e30bfbeb024491c48ae7217d31575cb76d22d (commit)
       via  5f45471dca1a5762b894d4542efd7e63da45cb80 (commit)
       via  28b49ba4eff2da6571631bf7657b09977036f19d (commit)
       via  ed733bb38346104276ac50ebe2953c9d60a90d57 (commit)
       via  956195be1b5c8c243c7267353b3c1d71388844a6 (commit)
       via  7f93fb4b48592a3fd98c6beca7e8ebe3d35cfc2a (commit)
       via  2ee935fd0c2843e759c76e1b81574cbf1ae6b52e (commit)
       via  c0d7c72caa5fecbe9f68914873a8cacc7b389a1a (commit)
       via  9e47df9429e38ec0e353ea683e5583bdc7061806 (commit)
       via  95e23d582859c6492312b6b366b8b65bdd2e6baf (commit)
       via  47af000ae47825e25ebfc6e0f18db6a23e7ce337 (commit)
       via  ef63ea9d84d72740b0c2ebcab998e258a52e87a0 (commit)
      from  dc39790d9056b7c7647137566c4f3bfba317f2b1 (commit)


- Shortlog ------------------------------------------------------------
fa7010f use Q_INVOKABLE instead of undocumented Q_SCRIPTABLE
c11abd3 initialize m_on member og GlyphPoint using initializer list
9c827ff make GlyphContour's points list private
64713fe remove call to QScriptEngine::setDefaultPrototype()
e33e30b fix conversion function for CvtEntry
5f45471 make QPointF scriptable
28b49ba add change signals for GlyphReference
ed733bb add constructors for GlyphReference and GlyphContour
956195b declare metat types for Glyph{Contour,Reference} *
7f93fb4 declare meta type for FontDocument* in fontdocument.h
2ee935f Remove 'parent' argument from constructors of Glyph{ContentBase,Contour,Reference}.
c0d7c72 make GlyphContentList scriptable
9e47df9 hide member variable Glyph::content
95e23d5 ignore 'script' binary
47af000 make contours and references QObjects
ef63ea9 add type GlyphPointList and declare metatypes

Summary of changes:
 .gitignore                    |    1 +
 gui/glyphcell.cxx             |    2 +-
 gui/glyphgraphics.cxx         |   63 ++++++++++++++++--------------
 gui/glyphgraphics.h           |    4 +-
 gui/glyphitem.cxx             |   40 +++++++++++---------
 gui/glyphitem.h               |    4 +-
 gui/glyphsmodel.cxx           |   29 ++++++++------
 nongui/contour.h              |   38 ------------------
 nongui/fontdocument.h         |    6 ++-
 nongui/fontdocumentreader.cxx |   19 +++++----
 nongui/fontdocumentwriter.cxx |   37 ++++++++++--------
 nongui/fontdocumentwriter.h   |    3 +-
 nongui/glyph.cxx              |   63 ++++++++++++++++++------------
 nongui/glyph.h                |   14 +++----
 nongui/glyphcontentbase.h     |   40 +++++++++++++++++++
 nongui/glyphcontour.cxx       |   43 +++++++++++++++++++++
 nongui/glyphcontour.h         |   44 +++++++++++++++++++++
 nongui/glyphpoint.h           |   17 ++++++--
 nongui/glyphref.h             |   38 ------------------
 nongui/glyphreference.cxx     |   62 ++++++++++++++++++++++++++++++
 nongui/glyphreference.h       |   48 +++++++++++++++++++++++
 nongui/nongui.rules           |   16 +++++--
 nongui/ttfwriter.cxx          |   34 ++++++++++-------
 qscript/constructors.cxx      |   85 +++++++++++++++++++++++++++++++++++++++--
 qscript/fontio.cxx            |    2 -
 25 files changed, 521 insertions(+), 231 deletions(-)
-----------------------------------------------------------------------
Details of changes:

commit fa7010f30f1b10e5e400fca09c676f75d93fa55b
Author: Eugeniy Meshcheryakov <eugen at debian.org>
Date:   Tue Dec 25 17:03:35 2007 +0100

    use Q_INVOKABLE instead of undocumented Q_SCRIPTABLE

diff --git a/nongui/glyph.h b/nongui/glyph.h
index a17c773..822e5a2 100644
--- a/nongui/glyph.h
+++ b/nongui/glyph.h
@@ -41,7 +41,7 @@ public:
 	FontDocument *document() const;
 
 	GlyphContentList content() const;
-	Q_SCRIPTABLE void appendContent(GlyphContentBase *item);
+	Q_INVOKABLE void appendContent(GlyphContentBase *item);
 
 	bool setGlyphName(const QString &name);
 	QString glyphName() const;
diff --git a/nongui/glyphcontour.h b/nongui/glyphcontour.h
index 5e3c79b..b708d19 100644
--- a/nongui/glyphcontour.h
+++ b/nongui/glyphcontour.h
@@ -32,8 +32,8 @@ public:
 
 	GlyphPointList points() const {return m_points;}
 
-	Q_SCRIPTABLE void appendPoint(const GlyphPoint &point);
-	Q_SCRIPTABLE void changePoint(int which, const GlyphPoint &newPoint);
+	Q_INVOKABLE void appendPoint(const GlyphPoint &point);
+	Q_INVOKABLE void changePoint(int which, const GlyphPoint &newPoint);
 private:
 	bool m_open;
 	GlyphPointList m_points;

commit c11abd3b74b58ab3ad587a0b3c54ab502ac211a7
Author: Eugeniy Meshcheryakov <eugen at debian.org>
Date:   Tue Dec 25 17:01:38 2007 +0100

    initialize m_on member og GlyphPoint using initializer list
    declare GlyphPoint as movable

diff --git a/nongui/glyphpoint.h b/nongui/glyphpoint.h
index f0da85a..a849b67 100644
--- a/nongui/glyphpoint.h
+++ b/nongui/glyphpoint.h
@@ -22,16 +22,18 @@
 
 class GlyphPoint: public QPointF {
 public:
-	GlyphPoint() : QPointF() {m_on = true;}
-	GlyphPoint(const QPointF &point, bool on = true) : QPointF(point) {m_on = on;}
-	GlyphPoint(const GlyphPoint &point) : QPointF(point) {m_on = point.m_on;}
-	GlyphPoint(qreal x, qreal y, bool on = true) : QPointF(x, y) {m_on = on;}
+	GlyphPoint() : QPointF(), m_on(true) {}
+	GlyphPoint(const QPointF &point, bool on = true) : QPointF(point), m_on(on) {}
+	GlyphPoint(const GlyphPoint &point) : QPointF(point), m_on(point.m_on) {}
+	GlyphPoint(qreal x, qreal y, bool on = true) : QPointF(x, y), m_on(on) {}
 	bool on() const {return m_on;}
 	void setOn(bool on = true) {m_on = on;}
 private:
 	bool m_on;
 };
 
+Q_DECLARE_TYPEINFO(GlyphPoint, Q_MOVABLE_TYPE);
+
 typedef QList<GlyphPoint> GlyphPointList;
 
 Q_DECLARE_METATYPE(GlyphPoint)

commit 9c827ffc8e17243c3096dade7b97bc8f1e0b7a58
Author: Eugeniy Meshcheryakov <eugen at debian.org>
Date:   Tue Dec 25 00:46:50 2007 +0100

    make GlyphContour's points list private

diff --git a/gui/glyphgraphics.cxx b/gui/glyphgraphics.cxx
index f577644..03ed8cd 100644
--- a/gui/glyphgraphics.cxx
+++ b/gui/glyphgraphics.cxx
@@ -41,8 +41,8 @@ GlyphGraphics::GlyphGraphics(GlyphCell *parent, Glyph *glyph) :
 			const GlyphContour *c = qobject_cast<const GlyphContour *>(v);
 			Q_ASSERT(c);
 
-			for (int j = 0; j < c->points.size(); j++) {
-				const GlyphPoint &pt = c->points.at(j);
+			for (int j = 0; j < c->points().size(); j++) {
+				const GlyphPoint pt = c->points().at(j);
 				ControlPoint *cp = new ControlPoint(this, PointIndex(i, j), item);
 				points.append(cp);
 				cp->setPos(pt.x(), -pt.y());
@@ -102,8 +102,8 @@ QPainterPath GlyphGraphics::contourToPath(const GlyphContour *contour)
 {
 	QPainterPath path;
 
-	for (int i = 0; i < contour->points.size(); i++) {
-		const GlyphPoint &pt = contour->points.at(i);
+	for (int i = 0; i < contour->points().size(); i++) {
+		const GlyphPoint pt = contour->points().at(i);
 
 		// TODO move away from the loop
 		if (i == 0) {
@@ -112,18 +112,18 @@ QPainterPath GlyphGraphics::contourToPath(const GlyphContour *contour)
 				continue;
 			}
 			else {
-				if (contour->points.last().on())
-					path.moveTo(contour->points.last());
+				if (contour->points().last().on())
+					path.moveTo(contour->points().last());
 				else
-					path.moveTo((pt + contour->points.last()) / 2);
+					path.moveTo((pt + contour->points().last()) / 2);
 			}
 		}
 
 		if (pt.on())
 			path.lineTo(pt);
 		else {
-			const GlyphPoint &next = (i < contour->points.size() - 1) ?
-				contour->points.at(i + 1) : contour->points.at(0);
+			const GlyphPoint next = (i < contour->points().size() - 1) ?
+				contour->points().at(i + 1) : contour->points().at(0);
 
 			if (next.on()) {
 				path.quadTo(pt, next);
diff --git a/nongui/fontdocumentreader.cxx b/nongui/fontdocumentreader.cxx
index 8246711..69dea13 100644
--- a/nongui/fontdocumentreader.cxx
+++ b/nongui/fontdocumentreader.cxx
@@ -314,7 +314,7 @@ void FontDocumentReader::readContour(Glyph *glyph)
 
 				bool on = (attributes().value("on") != "no");
 
-				contour->points.append(GlyphPoint(xVal, yVal, on));
+				contour->appendPoint(GlyphPoint(xVal, yVal, on));
 				readUnknownElement();
 			}
 			else
diff --git a/nongui/fontdocumentwriter.cxx b/nongui/fontdocumentwriter.cxx
index 6f63ffe..ae67c8c 100644
--- a/nongui/fontdocumentwriter.cxx
+++ b/nongui/fontdocumentwriter.cxx
@@ -149,7 +149,7 @@ bool FontDocumentWriter::writeGlyphContent(const GlyphContentList &content)
 			writeStartElement("contour");
 			if (contour->isOpen())
 				writeAttribute("open", "1");
-			foreach (const GlyphPoint &pt, contour->points) {
+			foreach (const GlyphPoint pt, contour->points()) {
 				writeEmptyElement("pt");
 				writeAttribute("x", QString::number(pt.x()));
 				writeAttribute("y", QString::number(pt.y()));
diff --git a/nongui/glyph.cxx b/nongui/glyph.cxx
index 78aa2e5..35f5490 100644
--- a/nongui/glyph.cxx
+++ b/nongui/glyph.cxx
@@ -266,17 +266,17 @@ bool Glyph::computeMetrics(qreal &xMin, qreal &xMax, qreal &yMin, qreal &yMax) c
 	return false;
 	}
 	const GlyphContour *c = qobject_cast<const GlyphContour *>(content().at(0));
-	if (c->points.isEmpty())
+	if (c->points().isEmpty())
 		return false; // empty contours are not allowed
-	xMin = xMax = c->points.at(0).x();
-	yMin = yMax = c->points.at(0).y();
+	xMin = xMax = c->points().at(0).x();
+	yMin = yMax = c->points().at(0).y();
 
 	int contNo = 0;
 	int pointNo = 1;
 
 	for (;;) {
-		while (pointNo < c->points.size()) {
-			const GlyphPoint &pt = c->points.at(pointNo);
+		while (pointNo < c->points().size()) {
+			const GlyphPoint pt = c->points().at(pointNo);
 			qreal x = pt.x();
 			qreal y = pt.y();
 			if (xMin > x) xMin = x;
@@ -293,7 +293,7 @@ bool Glyph::computeMetrics(qreal &xMin, qreal &xMax, qreal &yMin, qreal &yMax) c
 		}
 		else
 			break;
-		if (c->points.isEmpty())
+		if (c->points().isEmpty())
 			return false;
 	}
 	return true;
@@ -319,13 +319,13 @@ void Glyph::movePoint(int component, int pointNo, const QPointF &newPos)
 	Q_ASSERT(component < content().size());
 	GlyphContour *contour = qobject_cast<GlyphContour *>(content().at(component));
 	Q_ASSERT(contour);
-	Q_ASSERT(pointNo < contour->points.size());
+	Q_ASSERT(pointNo < contour->points().size());
 
-	GlyphPoint pt = contour->points.at(pointNo);
+	GlyphPoint pt = contour->points().at(pointNo);
 	if (pt.x() != newPos.x() || pt.y() != newPos.y()) {
 		pt.setX(newPos.x());
 		pt.setY(newPos.y());
-		contour->points[pointNo] = pt;
+		contour->changePoint(pointNo, pt);
 
 		emit pointMoved(component, pointNo, newPos);
 		emit outlineChanged();
diff --git a/nongui/glyphcontour.cxx b/nongui/glyphcontour.cxx
index beebcf7..814452a 100644
--- a/nongui/glyphcontour.cxx
+++ b/nongui/glyphcontour.cxx
@@ -30,3 +30,14 @@ void GlyphContour::setOpen(bool open)
 {
 	m_open = open;
 }
+
+void GlyphContour::appendPoint(const GlyphPoint &point)
+{
+	m_points << point;
+}
+
+void GlyphContour::changePoint(int which, const GlyphPoint &newPoint)
+{
+	Q_ASSERT(which < m_points.size()); // XXX scriptable!
+	m_points[which] = newPoint;
+}
diff --git a/nongui/glyphcontour.h b/nongui/glyphcontour.h
index 062f2c5..5e3c79b 100644
--- a/nongui/glyphcontour.h
+++ b/nongui/glyphcontour.h
@@ -18,21 +18,25 @@
 #define GLYPHCONTOUR_H
 #include "glyphcontentbase.h"
 #include "glyphpoint.h"
-#include <QList>
 
 class GlyphContour : public GlyphContentBase {
 	Q_OBJECT
 	Q_PROPERTY(bool open READ isOpen WRITE setOpen)
+	Q_PROPERTY(GlyphPointList points READ points)
 public:
 	GlyphContour(bool open = false);
 	ContentType type() const {return Contour;}
 
 	bool isOpen() const;
 	void setOpen(bool open = true);
-	// XXX TODO make it private
-	GlyphPointList points;
+
+	GlyphPointList points() const {return m_points;}
+
+	Q_SCRIPTABLE void appendPoint(const GlyphPoint &point);
+	Q_SCRIPTABLE void changePoint(int which, const GlyphPoint &newPoint);
 private:
 	bool m_open;
+	GlyphPointList m_points;
 };
 
 Q_DECLARE_METATYPE(GlyphContour *)
diff --git a/nongui/ttfwriter.cxx b/nongui/ttfwriter.cxx
index 95d3467..f96ac8e 100644
--- a/nongui/ttfwriter.cxx
+++ b/nongui/ttfwriter.cxx
@@ -339,7 +339,7 @@ bool TTFWriter::writeSimpleGlyph(QIODevice *dev, const Glyph *g)
 		const GlyphContour *c = qobject_cast<const GlyphContour *>(i);
 		Q_ASSERT(c);
 
-		nPoints += c->points.size();
+		nPoints += c->points().size();
 		if (!writeBigEndian(dev, (qint16)(nPoints - 1)))
 			return false;
 	}
@@ -366,7 +366,7 @@ bool TTFWriter::writeSimpleGlyph(QIODevice *dev, const Glyph *g)
 		const GlyphContour *c = qobject_cast<const GlyphContour*>(i);
 		Q_ASSERT(c);
 
-		foreach (const GlyphPoint &pt, c->points) {
+		foreach (const GlyphPoint pt, c->points()) {
 			char flags = 0;
 			if (pt.on())
 				flags |= TTFLAG_ON_CURVE;
@@ -382,7 +382,7 @@ bool TTFWriter::writeSimpleGlyph(QIODevice *dev, const Glyph *g)
 		const GlyphContour *c = qobject_cast<const GlyphContour*>(i);
 		Q_ASSERT(c);
 
-		foreach (const GlyphPoint &pt, c->points) {
+		foreach (const GlyphPoint pt, c->points()) {
 			qint16 thisPoint =  (qint16)pt.x();
 			if (!writeBigEndian<qint16>(dev, thisPoint - prev))
 				return false;
@@ -393,7 +393,7 @@ bool TTFWriter::writeSimpleGlyph(QIODevice *dev, const Glyph *g)
 	prev = 0;
 	foreach (const GlyphContentBase *i, g->content()) {
 		const GlyphContour *c = qobject_cast<const GlyphContour *>(i);
-		foreach (const GlyphPoint &pt, c->points) {
+		foreach (const GlyphPoint pt, c->points()) {
 			qint16 thisPoint =  (qint16)pt.y();
 			if (!writeBigEndian<qint16>(dev, thisPoint - prev))
 				return false;

commit 64713febaf6ec234e2f20102644319512cfb441a
Author: Eugeniy Meshcheryakov <eugen at debian.org>
Date:   Tue Dec 25 00:26:41 2007 +0100

    remove call to QScriptEngine::setDefaultPrototype()
    I do not remember what it was for...

diff --git a/qscript/constructors.cxx b/qscript/constructors.cxx
index b1ad50d..f44795f 100644
--- a/qscript/constructors.cxx
+++ b/qscript/constructors.cxx
@@ -132,7 +132,6 @@ void initScripting(QScriptEngine *engine)
 
 	global.setProperty("FontDocument", engine->scriptValueFromQMetaObject<FontDocument>());
 	global.setProperty("Glyph", engine->scriptValueFromQMetaObject<Glyph>());
-//	engine->setDefaultPrototype(qRegisterMetaType<Glyph*>(), engine->scriptValueFromQMetaObject<Glyph>());
 	global.setProperty("GlyphReference",
 			engine->newQMetaObject(&GlyphReference::staticMetaObject,
 				engine->newFunction(glyphReferenceConstructor)));

commit e33e30bfbeb024491c48ae7217d31575cb76d22d
Author: Eugeniy Meshcheryakov <eugen at debian.org>
Date:   Tue Dec 25 00:26:02 2007 +0100

    fix conversion function for CvtEntry

diff --git a/qscript/constructors.cxx b/qscript/constructors.cxx
index d1ceadc..b1ad50d 100644
--- a/qscript/constructors.cxx
+++ b/qscript/constructors.cxx
@@ -70,8 +70,16 @@ static QScriptValue cvtEntryToScriptValue(QScriptEngine *engine, const CVTEntry
 static void cvtEntryFromScriptValue(const QScriptValue &obj, CVTEntry &ent)
 {
 	ent.setValue(obj.property("value").toInt32());
-	ent.setVariableName(obj.property("variableName").toString());
-	ent.setComment(obj.property("comment").toString());
+	QScriptValue prop = obj.property("variableName");
+	if (prop.isValid())
+		ent.setVariableName(prop.toString());
+	else
+		ent.setVariableName(QString());
+	prop = obj.property("comment");
+	if (prop.isValid())
+		ent.setComment(prop.toString());
+	else
+		ent.setComment(QString());
 }
 
 static QScriptValue glyphToScriptValue(QScriptEngine *engine, Glyph * const &glyph)

commit 5f45471dca1a5762b894d4542efd7e63da45cb80
Author: Eugeniy Meshcheryakov <eugen at debian.org>
Date:   Tue Dec 25 00:22:27 2007 +0100

    make QPointF scriptable

diff --git a/qscript/constructors.cxx b/qscript/constructors.cxx
index 2acca27..d1ceadc 100644
--- a/qscript/constructors.cxx
+++ b/qscript/constructors.cxx
@@ -96,6 +96,20 @@ static void glyphContentFromScriptValue(const QScriptValue &obj, GlyphContentBas
 	item = qobject_cast<GlyphContentBase *>(qscriptvalue_cast<QObject *>(obj));
 }
 
+static QScriptValue pointToScriptValue(QScriptEngine *engine, const QPointF &point)
+{
+	QScriptValue obj = engine->newObject();
+	obj.setProperty("x", QScriptValue(engine, point.x()));
+	obj.setProperty("y", QScriptValue(engine, point.y()));
+	return obj;
+}
+
+static void pointFromScriptValue(const QScriptValue &obj, QPointF &point)
+{
+	point.setX(obj.property("x").toNumber());
+	point.setY(obj.property("y").toNumber());
+}
+
 void initScripting(QScriptEngine *engine)
 {
 	QScriptValue global = engine->globalObject();
@@ -126,4 +140,5 @@ void initScripting(QScriptEngine *engine)
 	qScriptRegisterSequenceMetaType<QVector<CVTEntry> >(engine);
 	qScriptRegisterMetaType<GlyphContentBase *>(engine, glyphContentToScriptValue, glyphContentFromScriptValue);
 	qScriptRegisterSequenceMetaType<GlyphContentList>(engine);
+	qScriptRegisterMetaType<QPointF>(engine, pointToScriptValue, pointFromScriptValue);
 }

commit 28b49ba4eff2da6571631bf7657b09977036f19d
Author: Eugeniy Meshcheryakov <eugen at debian.org>
Date:   Tue Dec 25 00:12:19 2007 +0100

    add change signals for GlyphReference

diff --git a/nongui/glyphreference.cxx b/nongui/glyphreference.cxx
index 2628551..2c5f6a1 100644
--- a/nongui/glyphreference.cxx
+++ b/nongui/glyphreference.cxx
@@ -19,11 +19,15 @@
 GlyphReference::GlyphReference(const QString &name, const QPointF &off) :
 	GlyphContentBase(), m_glyphName(name), m_offset(off)
 {
+	connect(this, SIGNAL(offsetChanged()), this, SIGNAL(referenceChanged()));
+	connect(this, SIGNAL(glyphNameChanged()), this, SIGNAL(referenceChanged()));
 }
 
 GlyphReference::GlyphReference(const GlyphReference &other) :
 	GlyphContentBase(), m_glyphName(other.m_glyphName), m_offset(other.m_offset)
 {
+	connect(this, SIGNAL(offsetChanged()), this, SIGNAL(referenceChanged()));
+	connect(this, SIGNAL(glyphNameChanged()), this, SIGNAL(referenceChanged()));
 }
 
 QPointF GlyphReference::offset() const
@@ -33,7 +37,10 @@ QPointF GlyphReference::offset() const
 
 void GlyphReference::setOffset(const QPointF &newOffset)
 {
-	m_offset = newOffset;
+	if (m_offset != newOffset) {
+		m_offset = newOffset;
+		emit offsetChanged();
+	}
 }
 
 QString GlyphReference::glyphName() const
@@ -43,5 +50,13 @@ QString GlyphReference::glyphName() const
 
 void GlyphReference::setGlyphName(const QString &newName)
 {
-	m_glyphName = newName;
+	QString str;
+
+	if (!newName.isEmpty())
+		str = newName;
+
+	if (m_glyphName != str) {
+		m_glyphName = str;
+		emit glyphNameChanged();
+	}
 }
diff --git a/nongui/glyphreference.h b/nongui/glyphreference.h
index 4095ec8..0e4e1b1 100644
--- a/nongui/glyphreference.h
+++ b/nongui/glyphreference.h
@@ -34,6 +34,10 @@ public:
 
 	QString glyphName() const;
 	void setGlyphName(const QString &newName);
+signals:
+	void offsetChanged();
+	void glyphNameChanged();
+	void referenceChanged(); // emitted on any change
 private:
 	QString m_glyphName;
 	QPointF m_offset;

commit ed733bb38346104276ac50ebe2953c9d60a90d57
Author: Eugeniy Meshcheryakov <eugen at debian.org>
Date:   Tue Dec 25 00:01:10 2007 +0100

    add constructors for GlyphReference and GlyphContour

diff --git a/qscript/constructors.cxx b/qscript/constructors.cxx
index 80260e2..2acca27 100644
--- a/qscript/constructors.cxx
+++ b/qscript/constructors.cxx
@@ -20,10 +20,44 @@
 #include <QtScript>
 #include "fontio.h"
 #include "glyphcontentbase.h"
+#include "glyphreference.h"
+#include "glyphcontour.h"
 
 Q_SCRIPT_DECLARE_QMETAOBJECT(FontDocument, QObject*)
+// FIXME undefined value converted to string "undefined"
 Q_SCRIPT_DECLARE_QMETAOBJECT(Glyph, QString)
 
+// new GlyphReference(GlyphReference)
+// new GlyphReference(String, Point)
+static QScriptValue glyphReferenceConstructor(QScriptContext *ctx, QScriptEngine *engine)
+{
+	GlyphReference *newRef = 0;
+
+	if (ctx->argumentCount() == 1) {
+		// maybe it is copy constructor?
+		GlyphReference *ref = qscriptvalue_cast<GlyphReference *>(ctx->argument(0));
+		if (ref) {
+			// yes, it is!
+			newRef = new GlyphReference(*ref);
+		}
+	}
+
+	if (!newRef) {
+		// that was not a copy constructor
+		QString name;
+		QPointF offset;
+		if (ctx->argumentCount() >= 1)
+			name = qscriptvalue_cast<QString>(ctx->argument(0));
+		if (ctx->argumentCount() >= 2)
+			offset = qscriptvalue_cast<QPointF>(ctx->argument(1));
+		newRef = new GlyphReference(name, offset);
+	}
+
+	return engine->newQObject(newRef, QScriptEngine::AutoOwnership);
+}
+
+Q_SCRIPT_DECLARE_QMETAOBJECT(GlyphContour, bool)
+
 static QScriptValue cvtEntryToScriptValue(QScriptEngine *engine, const CVTEntry &ent)
 {
 	QScriptValue obj = engine->newObject();
@@ -68,10 +102,19 @@ void initScripting(QScriptEngine *engine)
 
 	qRegisterMetaType<FontDocument*>();
 	qRegisterMetaType<Glyph*>();
+	qRegisterMetaType<QList<Glyph *> >();
+	qRegisterMetaType<GlyphContentBase*>();
+	qRegisterMetaType<GlyphContentList>();
+	qRegisterMetaType<GlyphReference*>();
+	qRegisterMetaType<GlyphContour*>();
 
 	global.setProperty("FontDocument", engine->scriptValueFromQMetaObject<FontDocument>());
 	global.setProperty("Glyph", engine->scriptValueFromQMetaObject<Glyph>());
-	engine->setDefaultPrototype(qRegisterMetaType<Glyph*>(), engine->scriptValueFromQMetaObject<Glyph>());
+//	engine->setDefaultPrototype(qRegisterMetaType<Glyph*>(), engine->scriptValueFromQMetaObject<Glyph>());
+	global.setProperty("GlyphReference",
+			engine->newQMetaObject(&GlyphReference::staticMetaObject,
+				engine->newFunction(glyphReferenceConstructor)));
+	global.setProperty("GlyphContour", engine->scriptValueFromQMetaObject<GlyphContour>());
 
 	global.setProperty("loadFont", engine->newFunction(loadFont, 1));
 	global.setProperty("saveFont", engine->newFunction(saveFont, 2));

commit 956195be1b5c8c243c7267353b3c1d71388844a6
Author: Eugeniy Meshcheryakov <eugen at debian.org>
Date:   Mon Dec 24 23:32:13 2007 +0100

    declare metat types for Glyph{Contour,Reference} *

diff --git a/nongui/glyphcontour.h b/nongui/glyphcontour.h
index 1ee3be1..062f2c5 100644
--- a/nongui/glyphcontour.h
+++ b/nongui/glyphcontour.h
@@ -35,4 +35,6 @@ private:
 	bool m_open;
 };
 
+Q_DECLARE_METATYPE(GlyphContour *)
+
 #endif
diff --git a/nongui/glyphreference.h b/nongui/glyphreference.h
index a6ee14d..4095ec8 100644
--- a/nongui/glyphreference.h
+++ b/nongui/glyphreference.h
@@ -39,4 +39,6 @@ private:
 	QPointF m_offset;
 };
 
+Q_DECLARE_METATYPE(GlyphReference *)
+
 #endif

commit 7f93fb4b48592a3fd98c6beca7e8ebe3d35cfc2a
Author: Eugeniy Meshcheryakov <eugen at debian.org>
Date:   Mon Dec 24 23:29:05 2007 +0100

    declare meta type for FontDocument* in fontdocument.h

diff --git a/nongui/fontdocument.h b/nongui/fontdocument.h
index 1bcfa88..bf6be5b 100644
--- a/nongui/fontdocument.h
+++ b/nongui/fontdocument.h
@@ -55,7 +55,7 @@ class FontDocument : public QObject {
 	Q_PROPERTY(QVector<CVTEntry> cvt READ cvt)
 public:
 	FontDocument(QObject *parent = 0);
-	
+
 	void setCopyright(const QString &copyright);
 	QString copyright() const;
 
@@ -89,7 +89,7 @@ public:
 
 	void setUnderlinePosition(qreal underlinePosition);
 	qreal underlinePosition() const;
-	
+
 	void setUnderlineThickness(qreal underlineThickness);
 	qreal underlineThickness() const;
 
@@ -189,4 +189,6 @@ private:
 	MAXPData maxp;
 };
 
+Q_DECLARE_METATYPE(FontDocument *)
+
 #endif
diff --git a/qscript/constructors.cxx b/qscript/constructors.cxx
index 27a5780..80260e2 100644
--- a/qscript/constructors.cxx
+++ b/qscript/constructors.cxx
@@ -24,8 +24,6 @@
 Q_SCRIPT_DECLARE_QMETAOBJECT(FontDocument, QObject*)
 Q_SCRIPT_DECLARE_QMETAOBJECT(Glyph, QString)
 
-Q_DECLARE_METATYPE(FontDocument *)
-
 static QScriptValue cvtEntryToScriptValue(QScriptEngine *engine, const CVTEntry &ent)
 {
 	QScriptValue obj = engine->newObject();
diff --git a/qscript/fontio.cxx b/qscript/fontio.cxx
index 3bde02c..0f5666f 100644
--- a/qscript/fontio.cxx
+++ b/qscript/fontio.cxx
@@ -20,8 +20,6 @@
 #include "fontdocumentwriter.h"
 #include "ttfwriter.h"
 
-Q_DECLARE_METATYPE(FontDocument*)
-
 QScriptValue loadFont(QScriptContext *context, QScriptEngine *engine)
 {
 	if (context->argumentCount() < 1)

commit 2ee935fd0c2843e759c76e1b81574cbf1ae6b52e
Author: Eugeniy Meshcheryakov <eugen at debian.org>
Date:   Mon Dec 24 23:20:20 2007 +0100

    Remove 'parent' argument from constructors of Glyph{ContentBase,Contour,Reference}.
    Those classes should usually be created without constructors

diff --git a/nongui/glyphcontentbase.h b/nongui/glyphcontentbase.h
index 8e8d628..0c9913c 100644
--- a/nongui/glyphcontentbase.h
+++ b/nongui/glyphcontentbase.h
@@ -27,8 +27,7 @@ class GlyphContentBase : public QObject {
 public:
 	enum ContentType {Reference, Contour};
 
-	// FIXME maybe use Glyph as parent
-	GlyphContentBase(QObject *parent = 0) : QObject(parent) {}
+	GlyphContentBase() : QObject() {}
 	virtual ContentType type() const = 0;
 };
 
diff --git a/nongui/glyphcontour.cxx b/nongui/glyphcontour.cxx
index 32112de..beebcf7 100644
--- a/nongui/glyphcontour.cxx
+++ b/nongui/glyphcontour.cxx
@@ -16,8 +16,8 @@
  */
 #include "glyphcontour.h"
 
-GlyphContour::GlyphContour(bool open, QObject *parent) :
-	GlyphContentBase(parent), m_open(open)
+GlyphContour::GlyphContour(bool open) :
+	GlyphContentBase(), m_open(open)
 {
 }
 
diff --git a/nongui/glyphcontour.h b/nongui/glyphcontour.h
index 597a495..1ee3be1 100644
--- a/nongui/glyphcontour.h
+++ b/nongui/glyphcontour.h
@@ -24,7 +24,7 @@ class GlyphContour : public GlyphContentBase {
 	Q_OBJECT
 	Q_PROPERTY(bool open READ isOpen WRITE setOpen)
 public:
-	GlyphContour(bool open = false, QObject *parent = 0);
+	GlyphContour(bool open = false);
 	ContentType type() const {return Contour;}
 
 	bool isOpen() const;
diff --git a/nongui/glyphreference.cxx b/nongui/glyphreference.cxx
index 0607f1b..2628551 100644
--- a/nongui/glyphreference.cxx
+++ b/nongui/glyphreference.cxx
@@ -16,8 +16,8 @@
  */
 #include "glyphreference.h"
 
-GlyphReference::GlyphReference(const QString &name, const QPointF &off, QObject *parent) :
-	GlyphContentBase(parent), m_glyphName(name), m_offset(off)
+GlyphReference::GlyphReference(const QString &name, const QPointF &off) :
+	GlyphContentBase(), m_glyphName(name), m_offset(off)
 {
 }
 
diff --git a/nongui/glyphreference.h b/nongui/glyphreference.h
index f340de6..a6ee14d 100644
--- a/nongui/glyphreference.h
+++ b/nongui/glyphreference.h
@@ -25,7 +25,7 @@ class GlyphReference : public GlyphContentBase {
 	Q_PROPERTY(QPointF offset READ offset WRITE setOffset)
 	Q_PROPERTY(QString glyphName READ glyphName WRITE setGlyphName)
 public:
-	GlyphReference(const QString &name = 0, const QPointF &off = QPointF(), QObject *parent = 0);
+	GlyphReference(const QString &name = 0, const QPointF &off = QPointF());
 	GlyphReference(const GlyphReference &other);
 	ContentType type() const {return Reference;}
 

commit c0d7c72caa5fecbe9f68914873a8cacc7b389a1a
Author: Eugeniy Meshcheryakov <eugen at debian.org>
Date:   Mon Dec 24 01:35:06 2007 +0100

    make GlyphContentList scriptable

diff --git a/nongui/glyphcontentbase.h b/nongui/glyphcontentbase.h
index 58f8dec..8e8d628 100644
--- a/nongui/glyphcontentbase.h
+++ b/nongui/glyphcontentbase.h
@@ -32,8 +32,10 @@ public:
 	virtual ContentType type() const = 0;
 };
 
-Q_DECLARE_METATYPE(GlyphContentBase*)
 
 typedef QList<GlyphContentBase*> GlyphContentList;
 
+Q_DECLARE_METATYPE(GlyphContentBase*)
+Q_DECLARE_METATYPE(GlyphContentList)
+
 #endif
diff --git a/qscript/constructors.cxx b/qscript/constructors.cxx
index 2aa19a2..27a5780 100644
--- a/qscript/constructors.cxx
+++ b/qscript/constructors.cxx
@@ -19,6 +19,7 @@
 #include "glyph.h"
 #include <QtScript>
 #include "fontio.h"
+#include "glyphcontentbase.h"
 
 Q_SCRIPT_DECLARE_QMETAOBJECT(FontDocument, QObject*)
 Q_SCRIPT_DECLARE_QMETAOBJECT(Glyph, QString)
@@ -52,6 +53,17 @@ static void glyphFromScriptValue(const QScriptValue &obj, Glyph *&glyph)
 	glyph = qobject_cast<Glyph *>(qscriptvalue_cast<QObject *>(obj));
 }
 
+static QScriptValue glyphContentToScriptValue(QScriptEngine *engine, GlyphContentBase *const &item)
+{
+	QScriptValue obj = engine->newQObject(item, QScriptEngine::AutoOwnership);
+	return obj;
+}
+
+static void glyphContentFromScriptValue(const QScriptValue &obj, GlyphContentBase *&item)
+{
+	item = qobject_cast<GlyphContentBase *>(qscriptvalue_cast<QObject *>(obj));
+}
+
 void initScripting(QScriptEngine *engine)
 {
 	QScriptValue global = engine->globalObject();
@@ -71,4 +83,6 @@ void initScripting(QScriptEngine *engine)
 	qScriptRegisterSequenceMetaType<QList<Glyph *> >(engine);
 	qScriptRegisterMetaType<CVTEntry>(engine, cvtEntryToScriptValue, cvtEntryFromScriptValue);
 	qScriptRegisterSequenceMetaType<QVector<CVTEntry> >(engine);
+	qScriptRegisterMetaType<GlyphContentBase *>(engine, glyphContentToScriptValue, glyphContentFromScriptValue);
+	qScriptRegisterSequenceMetaType<GlyphContentList>(engine);
 }

commit 9e47df9429e38ec0e353ea683e5583bdc7061806
Author: Eugeniy Meshcheryakov <eugen at debian.org>
Date:   Mon Dec 24 01:20:16 2007 +0100

    hide member variable Glyph::content

diff --git a/gui/glyphgraphics.cxx b/gui/glyphgraphics.cxx
index afb3a7d..f577644 100644
--- a/gui/glyphgraphics.cxx
+++ b/gui/glyphgraphics.cxx
@@ -26,7 +26,7 @@
 #include "glyphitem.h"
 #include "glyphreference.h"
 
-GlyphGraphics::GlyphGraphics(GlyphCell *parent, Glyph *glyph) : 
+GlyphGraphics::GlyphGraphics(GlyphCell *parent, Glyph *glyph) :
 	QObject(parent), p(parent), m_glyph(glyph)
 {
 	Q_ASSERT(p);
@@ -35,8 +35,8 @@ GlyphGraphics::GlyphGraphics(GlyphCell *parent, Glyph *glyph) :
 
 	item = new GlyphItemOutline(this);
 
-	for (int i = 0; i < m_glyph->content.size(); i++) {
-		const GlyphContentBase *v = m_glyph->content.at(i);
+	for (int i = 0; i < m_glyph->content().size(); i++) {
+		const GlyphContentBase *v = m_glyph->content().at(i);
 		if (v->type() == GlyphContentBase::Contour) {
 			const GlyphContour *c = qobject_cast<const GlyphContour *>(v);
 			Q_ASSERT(c);
@@ -77,8 +77,8 @@ GlyphGraphics::GlyphGraphics(GlyphGraphics *parent, Glyph *glyph, const QPointF
 	Q_ASSERT(m_glyph->parent());
 
 	item = new GlyphItemOutline(this, parent->item);
-	for (int i = 0; i < m_glyph->content.size(); i++) {
-		const GlyphContentBase *v = m_glyph->content.at(i);
+	for (int i = 0; i < m_glyph->content().size(); i++) {
+		const GlyphContentBase *v = m_glyph->content().at(i);
 		if (v->type() == GlyphContentBase::Reference) {
 			// TODO make it useable
 			const GlyphReference *ref = qobject_cast<const GlyphReference *>(v);
diff --git a/gui/glyphitem.cxx b/gui/glyphitem.cxx
index 6f28e49..c9843a7 100644
--- a/gui/glyphitem.cxx
+++ b/gui/glyphitem.cxx
@@ -19,17 +19,17 @@
 #include "glyph.h"
 #include <QPainter>
 
-GlyphItemBase::GlyphItemBase(GlyphGraphics *gfx, QGraphicsItem *parent) : 
+GlyphItemBase::GlyphItemBase(GlyphGraphics *gfx, QGraphicsItem *parent) :
 	QGraphicsItem(parent), m_gfx(gfx)
 {
 	Q_ASSERT(m_gfx);
-	m_content = m_gfx->m_glyph->content;
+	m_content = m_gfx->m_glyph->content();
 }
 
 void GlyphItemBase::update()
 {
 	prepareGeometryChange();
-	m_content = m_gfx->m_glyph->content;
+	m_content = m_gfx->m_glyph->content();
 }
 
 QRectF GlyphItemBase::boundingRect() const
diff --git a/gui/glyphsmodel.cxx b/gui/glyphsmodel.cxx
index da4582f..bb8b6e3 100644
--- a/gui/glyphsmodel.cxx
+++ b/gui/glyphsmodel.cxx
@@ -50,7 +50,7 @@ QVariant GlyphsModel::data(const QModelIndex &index, int role) const
 		}
 		else if (role == Qt::DecorationRole) {
 			QVariant var;
-			if (glyph->hasHorizAdvX() || glyph->content.size()) {
+			if (glyph->hasHorizAdvX() || glyph->content().size()) {
 				PathList paths;
 				drawGlyph(&paths, glyph);
 				var.setValue(paths);
@@ -218,7 +218,7 @@ void GlyphsModel::drawContours(PathList *paths, const Glyph *glyph, int order, Q
 	if (order > 10)
 		return;
 
-	foreach (const GlyphContentBase *i, glyph->content) {
+	foreach (const GlyphContentBase *i, glyph->content()) {
 		if (i->type() == GlyphContentBase::Contour) {
 			const GlyphContour *c = qobject_cast<const GlyphContour *>(i);
 			Q_ASSERT(c);
diff --git a/nongui/fontdocumentreader.cxx b/nongui/fontdocumentreader.cxx
index 428ab70..8246711 100644
--- a/nongui/fontdocumentreader.cxx
+++ b/nongui/fontdocumentreader.cxx
@@ -275,8 +275,8 @@ void FontDocumentReader::readContent(Glyph *glyph)
 				qreal yVal = readRealAttribute("y", true, 0, &ok);
 				if (!ok) return;
 
-				GlyphReference *ref = new GlyphReference(g.toString(), QPointF(xVal, yVal), glyph);
-				glyph->content << ref;
+				GlyphReference *ref = new GlyphReference(g.toString(), QPointF(xVal, yVal));
+				glyph->appendContent(ref);
 				readUnknownElement();
 			}
 			else
@@ -289,7 +289,7 @@ void FontDocumentReader::readContour(Glyph *glyph)
 {
 	Q_ASSERT(isStartElement() && name() == "contour");
 
-	GlyphContour *contour = new GlyphContour(false, glyph);
+	GlyphContour *contour = new GlyphContour;
 
 	const QStringRef isOpen = attributes().value("open");
 	if (isOpen == "1")
@@ -321,7 +321,7 @@ void FontDocumentReader::readContour(Glyph *glyph)
 				readUnknownElement();
 		}
 	}
-	glyph->content << contour;
+	glyph->appendContent(contour);
 }
 
 void FontDocumentReader::readCvt()
diff --git a/nongui/fontdocumentwriter.cxx b/nongui/fontdocumentwriter.cxx
index 202bf6a..6f63ffe 100644
--- a/nongui/fontdocumentwriter.cxx
+++ b/nongui/fontdocumentwriter.cxx
@@ -126,8 +126,8 @@ bool FontDocumentWriter::writeGlyphs()
 			writeAttribute("u", QString::number(g->unicode(), 16));
 		if (g->hasInstructions())
 			writeTextElement("tti", g->instructions()); // TODO validity
-		if (!g->content.isEmpty())
-			writeGlyphContent(g->content);
+		if (!g->content().isEmpty())
+			writeGlyphContent(g->content());
 		if (!g->comment().isEmpty())
 			writeTextElement("comment", g->comment());
 		writeEndElement(); // glyph
diff --git a/nongui/glyph.cxx b/nongui/glyph.cxx
index 7bb2190..78aa2e5 100644
--- a/nongui/glyph.cxx
+++ b/nongui/glyph.cxx
@@ -33,6 +33,20 @@ FontDocument *Glyph::document() const
 	return qobject_cast<FontDocument *>(parent());
 }
 
+GlyphContentList Glyph::content() const
+{
+	return m_content;
+}
+
+void Glyph::appendContent(GlyphContentBase *item)
+{
+	Q_ASSERT(item);
+	Q_ASSERT(!item->parent());
+
+	item->setParent(this);
+	m_content << item;
+}
+
 template <typename T>
 static inline bool setIfChanged(T &what, const T& to)
 {
@@ -247,11 +261,11 @@ bool Glyph::changed() const
 bool Glyph::computeMetrics(qreal &xMin, qreal &xMax, qreal &yMin, qreal &yMax) const
 {
 	// TODO do something with open contours
-	if (content.isEmpty()) {
+	if (content().isEmpty()) {
 		xMin = xMax = yMin = yMax = 0;
 	return false;
 	}
-	const GlyphContour *c = qobject_cast<const GlyphContour *>(content.at(0));
+	const GlyphContour *c = qobject_cast<const GlyphContour *>(content().at(0));
 	if (c->points.isEmpty())
 		return false; // empty contours are not allowed
 	xMin = xMax = c->points.at(0).x();
@@ -273,8 +287,8 @@ bool Glyph::computeMetrics(qreal &xMin, qreal &xMax, qreal &yMin, qreal &yMax) c
 		}
 		contNo++;
 		pointNo = 0;
-		if (contNo < content.size()) {
-			c = qobject_cast<const GlyphContour*>(content[contNo]);
+		if (contNo < content().size()) {
+			c = qobject_cast<const GlyphContour*>(content().at(contNo));
 			Q_ASSERT(c);
 		}
 		else
@@ -290,7 +304,7 @@ void Glyph::countParts(unsigned &nContours, unsigned &nRefs) const
 	nContours = 0;
 	nRefs = 0;
 
-	foreach (const GlyphContentBase *i, content) {
+	foreach (const GlyphContentBase *i, content()) {
 		if (i->type() == GlyphContentBase::Contour)
 			nContours++;
 		else {
@@ -302,8 +316,8 @@ void Glyph::countParts(unsigned &nContours, unsigned &nRefs) const
 
 void Glyph::movePoint(int component, int pointNo, const QPointF &newPos)
 {
-	Q_ASSERT(component < content.size());
-	GlyphContour *contour = qobject_cast<GlyphContour *>(content.at(component));
+	Q_ASSERT(component < content().size());
+	GlyphContour *contour = qobject_cast<GlyphContour *>(content().at(component));
 	Q_ASSERT(contour);
 	Q_ASSERT(pointNo < contour->points.size());
 
diff --git a/nongui/glyph.h b/nongui/glyph.h
index 3bf8854..a17c773 100644
--- a/nongui/glyph.h
+++ b/nongui/glyph.h
@@ -34,16 +34,14 @@ class Glyph : public QObject {
 	Q_PROPERTY(QString comment READ comment WRITE setComment)
 	Q_PROPERTY(int unicode READ unicode WRITE setUnicode)
 	Q_PROPERTY(bool changed READ changed WRITE setChanged)
+	Q_PROPERTY(GlyphContentList content READ content)
 public:
 	Glyph(const QString &name = QString());
 
 	FontDocument *document() const;
-	/** Glyph outlines.
-	 * This list holds all contours and references inside the glyph.
-	 * It can contain values of type \ref GlyphContour or \ref GlyphReference.
-	 * @sa GlyphContour and GlyphReference
-	 */
-	GlyphContentList content; // TODO hide it
+
+	GlyphContentList content() const;
+	Q_SCRIPTABLE void appendContent(GlyphContentBase *item);
 
 	bool setGlyphName(const QString &name);
 	QString glyphName() const;
@@ -92,6 +90,7 @@ private:
 	QString m_comment;
 	int m_unicode;
 	bool m_changed;
+	GlyphContentList m_content;
 };
 
 #endif
diff --git a/nongui/ttfwriter.cxx b/nongui/ttfwriter.cxx
index 7160a38..95d3467 100644
--- a/nongui/ttfwriter.cxx
+++ b/nongui/ttfwriter.cxx
@@ -320,7 +320,7 @@ bool TTFWriter::writeCompositeGlyph(QIODevice *dev, const Glyph *g)
 
 bool TTFWriter::writeSimpleGlyph(QIODevice *dev, const Glyph *g)
 {
-	qint16 nContours = g->content.size();
+	qint16 nContours = g->content().size();
 	qreal xMin, xMax, yMin, yMax;
 	if (!g->computeMetrics(xMin, xMax, yMin, yMax)) {
 		qDebug() << "computeMinMax failed:" << g->glyphName();
@@ -335,7 +335,7 @@ bool TTFWriter::writeSimpleGlyph(QIODevice *dev, const Glyph *g)
 		return false;
 	// write endpoints of contours
 	int nPoints = 0;
-	foreach (const GlyphContentBase *i, g->content) {
+	foreach (const GlyphContentBase *i, g->content()) {
 		const GlyphContour *c = qobject_cast<const GlyphContour *>(i);
 		Q_ASSERT(c);
 
@@ -362,7 +362,7 @@ bool TTFWriter::writeSimpleGlyph(QIODevice *dev, const Glyph *g)
 		return false;
 	// write flags
 	// TODO optimize those flags
-	foreach (const GlyphContentBase *i, g->content) {
+	foreach (const GlyphContentBase *i, g->content()) {
 		const GlyphContour *c = qobject_cast<const GlyphContour*>(i);
 		Q_ASSERT(c);
 
@@ -378,7 +378,7 @@ bool TTFWriter::writeSimpleGlyph(QIODevice *dev, const Glyph *g)
 	// all coordinates are 16-bit for now
 	// start with x-coordinates
 	qint16 prev = 0;
-	foreach (const GlyphContentBase *i, g->content) {
+	foreach (const GlyphContentBase *i, g->content()) {
 		const GlyphContour *c = qobject_cast<const GlyphContour*>(i);
 		Q_ASSERT(c);
 
@@ -391,7 +391,7 @@ bool TTFWriter::writeSimpleGlyph(QIODevice *dev, const Glyph *g)
 	}
 	// and y-coordinates
 	prev = 0;
-	foreach (const GlyphContentBase *i, g->content) {
+	foreach (const GlyphContentBase *i, g->content()) {
 		const GlyphContour *c = qobject_cast<const GlyphContour *>(i);
 		foreach (const GlyphPoint &pt, c->points) {
 			qint16 thisPoint =  (qint16)pt.y();

commit 95e23d582859c6492312b6b366b8b65bdd2e6baf
Author: Eugeniy Meshcheryakov <eugen at debian.org>
Date:   Sun Dec 23 14:14:43 2007 +0100

    ignore 'script' binary

diff --git a/.gitignore b/.gitignore
index 4b126f4..3c4587a 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,6 +1,7 @@
 # programs
 src/fondue
 src/ufondue
+src/script
 
 # objects and libraries
 *.[oa]

commit 47af000ae47825e25ebfc6e0f18db6a23e7ce337
Author: Eugeniy Meshcheryakov <eugen at debian.org>
Date:   Sun Dec 23 14:14:06 2007 +0100

    make contours and references QObjects

diff --git a/gui/glyphcell.cxx b/gui/glyphcell.cxx
index c9edf11..2ea017a 100644
--- a/gui/glyphcell.cxx
+++ b/gui/glyphcell.cxx
@@ -20,7 +20,7 @@
 #include <QWheelEvent>
 #include <QDebug>
 #include <cmath>
-#include "contour.h"
+#include "glyphcontour.h"
 #include "controlpoint.h"
 #include "glyphgraphics.h"
 #include "glyph.h"
diff --git a/gui/glyphgraphics.cxx b/gui/glyphgraphics.cxx
index dd13901..afb3a7d 100644
--- a/gui/glyphgraphics.cxx
+++ b/gui/glyphgraphics.cxx
@@ -16,7 +16,7 @@
  */
 #include "glyphgraphics.h"
 #include "glyphcell.h"
-#include "contour.h"
+#include "glyphcontour.h"
 #include "controlpoint.h"
 #include <QPainter>
 #include <QIcon>
@@ -24,7 +24,7 @@
 #include "fontdocument.h"
 #include "glyphsmodel.h"
 #include "glyphitem.h"
-#include "glyphref.h"
+#include "glyphreference.h"
 
 GlyphGraphics::GlyphGraphics(GlyphCell *parent, Glyph *glyph) : 
 	QObject(parent), p(parent), m_glyph(glyph)
@@ -36,11 +36,13 @@ GlyphGraphics::GlyphGraphics(GlyphCell *parent, Glyph *glyph) :
 	item = new GlyphItemOutline(this);
 
 	for (int i = 0; i < m_glyph->content.size(); i++) {
-		const QVariant &v = m_glyph->content.at(i);
-		if (v.canConvert<Contour>()) {
-			Contour c = v.value<Contour>();
-			for (int j = 0; j < c.size(); j++) {
-				const GlyphPoint &pt = c.at(j);
+		const GlyphContentBase *v = m_glyph->content.at(i);
+		if (v->type() == GlyphContentBase::Contour) {
+			const GlyphContour *c = qobject_cast<const GlyphContour *>(v);
+			Q_ASSERT(c);
+
+			for (int j = 0; j < c->points.size(); j++) {
+				const GlyphPoint &pt = c->points.at(j);
 				ControlPoint *cp = new ControlPoint(this, PointIndex(i, j), item);
 				points.append(cp);
 				cp->setPos(pt.x(), -pt.y());
@@ -48,13 +50,15 @@ GlyphGraphics::GlyphGraphics(GlyphCell *parent, Glyph *glyph) :
 		}
 		else {
 			// TODO make it useable
-			Q_ASSERT(v.canConvert<GlyphRef>());
-			GlyphRef ref = v.value<GlyphRef>();
+			Q_ASSERT(v->type() == GlyphContentBase::Reference);
+			const GlyphReference *ref = qobject_cast<const GlyphReference *>(v);
+			Q_ASSERT(ref);
+
 			FontDocument *doc = m_glyph->document();
 
-			Glyph *other = doc->getGlyph(ref.glyphName());
+			Glyph *other = doc->getGlyph(ref->glyphName());
 			if (other) {
-				new GlyphGraphics(this, other, ref.offset());
+				new GlyphGraphics(this, other, ref->offset());
 				// TODO account them
 			}
 		}
@@ -74,17 +78,17 @@ GlyphGraphics::GlyphGraphics(GlyphGraphics *parent, Glyph *glyph, const QPointF
 
 	item = new GlyphItemOutline(this, parent->item);
 	for (int i = 0; i < m_glyph->content.size(); i++) {
-		const QVariant &v = m_glyph->content.at(i);
-		if (v.canConvert<GlyphRef>()) {
+		const GlyphContentBase *v = m_glyph->content.at(i);
+		if (v->type() == GlyphContentBase::Reference) {
 			// TODO make it useable
-			Q_ASSERT(v.canConvert<GlyphRef>());
-			GlyphRef ref = v.value<GlyphRef>();
+			const GlyphReference *ref = qobject_cast<const GlyphReference *>(v);
+			Q_ASSERT(ref);
 
 			FontDocument *doc = m_glyph->document();
-			Glyph *other = doc->getGlyph(ref.glyphName());
+			Glyph *other = doc->getGlyph(ref->glyphName());
 
 			if (other) {
-				new GlyphGraphics(this, other, ref.offset());
+				new GlyphGraphics(this, other, ref->offset());
 				// TODO account them
 			}
 		}
@@ -94,13 +98,13 @@ GlyphGraphics::GlyphGraphics(GlyphGraphics *parent, Glyph *glyph, const QPointF
 	connect(m_glyph, SIGNAL(outlineChanged()), this, SLOT(glyphOutlineChanged()));
 }
 
-QPainterPath GlyphGraphics::contourToPath(const Contour &contour)
+QPainterPath GlyphGraphics::contourToPath(const GlyphContour *contour)
 {
 	QPainterPath path;
 
-	for (int i = 0; i < contour.size(); i++) {
-		const GlyphPoint &pt = contour.at(i);
-	
+	for (int i = 0; i < contour->points.size(); i++) {
+		const GlyphPoint &pt = contour->points.at(i);
+
 		// TODO move away from the loop
 		if (i == 0) {
 			if (pt.on()) {
@@ -108,17 +112,18 @@ QPainterPath GlyphGraphics::contourToPath(const Contour &contour)
 				continue;
 			}
 			else {
-				if (contour.last().on())
-					path.moveTo(contour.last());
+				if (contour->points.last().on())
+					path.moveTo(contour->points.last());
 				else
-					path.moveTo((pt + contour.last()) / 2);
+					path.moveTo((pt + contour->points.last()) / 2);
 			}
 		}
 
 		if (pt.on())
 			path.lineTo(pt);
 		else {
-			const GlyphPoint &next = (i < contour.size() - 1) ? contour.at(i + 1) : contour.at(0);
+			const GlyphPoint &next = (i < contour->points.size() - 1) ?
+				contour->points.at(i + 1) : contour->points.at(0);
 
 			if (next.on()) {
 				path.quadTo(pt, next);
@@ -130,7 +135,7 @@ QPainterPath GlyphGraphics::contourToPath(const Contour &contour)
 			}
 		}
 	}
-	if (!contour.isOpen())
+	if (!contour->isOpen())
 		path.closeSubpath();
 
 	return path;
diff --git a/gui/glyphgraphics.h b/gui/glyphgraphics.h
index 073bafe..ca95258 100644
--- a/gui/glyphgraphics.h
+++ b/gui/glyphgraphics.h
@@ -18,7 +18,7 @@
 #define GLYPHGRAPHICS_H
 #include <QObject>
 #include <QPainterPath>
-#include "contour.h"
+#include "glyphcontour.h"
 
 class GlyphCell;
 class ControlPoint;
@@ -53,7 +53,7 @@ private:
 	QList<ControlPoint *> points;
 	GlyphItemBase *item;
 public:
-	static QPainterPath contourToPath(const Contour &contour);
+	static QPainterPath contourToPath(const GlyphContour *contour);
 };
 
 #endif
diff --git a/gui/glyphitem.cxx b/gui/glyphitem.cxx
index 0da478a..6f28e49 100644
--- a/gui/glyphitem.cxx
+++ b/gui/glyphitem.cxx
@@ -37,9 +37,10 @@ QRectF GlyphItemBase::boundingRect() const
 	QPainterPath path;
 	bool hadContours = false;
 
-	foreach (const QVariant &v, m_content) {
-		if (v.canConvert<Contour>()) {
-			Contour c = v.value<Contour>();
+	foreach (const GlyphContentBase *i, m_content) {
+		if (i->type() == GlyphContentBase::Contour) {
+			const GlyphContour *c = qobject_cast<const GlyphContour *>(i);
+			Q_ASSERT(c);
 			path.addPath(GlyphGraphics::contourToPath(c));
 			hadContours = true;
 		}
@@ -57,10 +58,11 @@ void GlyphItemBase::paintOutline(QPainter *painter, bool paintOpen)
 {
 	QPainterPath path;
 
-	foreach (const QVariant &v, m_content) {
-		if (v.canConvert<Contour>()) {
-			Contour c = v.value<Contour>();
-			if (!c.isOpen())
+	foreach (const GlyphContentBase *i, m_content) {
+		if (i->type() == GlyphContentBase::Contour) {
+			const GlyphContour *c = qobject_cast<const GlyphContour *>(i);
+			Q_ASSERT(c);
+			if (!c->isOpen())
 				path.addPath(GlyphGraphics::contourToPath(c));
 		}
 	}
@@ -72,10 +74,11 @@ void GlyphItemBase::paintOutline(QPainter *painter, bool paintOpen)
 
 	if (paintOpen) {
 		// draw open contours
-		foreach (const QVariant &v, m_content) {
-			if (v.canConvert<Contour>()) {
-				Contour c = v.value<Contour>();
-				if (c.isOpen())
+		foreach (const GlyphContentBase *i, m_content) {
+			if (i->type() == GlyphContentBase::Contour) {
+				const GlyphContour *c = qobject_cast<const GlyphContour *>(i);
+				Q_ASSERT(c);
+				if (c->isOpen())
 					painter->drawPath(GlyphGraphics::contourToPath(c));
 			}
 		}
@@ -86,10 +89,11 @@ void GlyphItemBase::paintFill(QPainter *painter)
 {
 	QPainterPath path;
 
-	foreach (const QVariant &v, m_content) {
-		if (v.canConvert<Contour>()) {
-			Contour c = v.value<Contour>();
-			if (!c.isOpen())
+	foreach (const GlyphContentBase *i, m_content) {
+		if (i->type() == GlyphContentBase::Contour) {
+			const GlyphContour *c = qobject_cast<const GlyphContour *>(i);
+			Q_ASSERT(c);
+			if (!c->isOpen())
 				path.addPath(GlyphGraphics::contourToPath(c));
 		}
 	}
diff --git a/gui/glyphitem.h b/gui/glyphitem.h
index 7aea156..9eb45c9 100644
--- a/gui/glyphitem.h
+++ b/gui/glyphitem.h
@@ -18,7 +18,7 @@
 #define GLYPHITEM_H
 #include <QGraphicsItem>
 #include <QList>
-#include <QVariant>
+#include "glyphcontentbase.h"
 
 class GlyphGraphics;
 
@@ -32,7 +32,7 @@ protected:
 	void paintFill(QPainter *painter);
 
 	GlyphGraphics *m_gfx;
-	QList<QVariant> m_content;
+	GlyphContentList m_content;
 };
 
 class GlyphItemOutline : public GlyphItemBase {
diff --git a/gui/glyphsmodel.cxx b/gui/glyphsmodel.cxx
index 88e266c..da4582f 100644
--- a/gui/glyphsmodel.cxx
+++ b/gui/glyphsmodel.cxx
@@ -19,8 +19,8 @@
 #include "fontdocument.h"
 #include <QVariant>
 #include "glyphgraphics.h"
-#include "glyphref.h"
-#include "contour.h"
+#include "glyphreference.h"
+#include "glyphcontour.h"
 #include "glyphpoint.h"
 #include <QDebug>
 #include "unicodenameslist.h"
@@ -32,7 +32,7 @@ QVariant GlyphsModel::data(const QModelIndex &index, int role) const
 
 	if (!index.isValid())
 		return QVariant();
-	
+
 	if (index.row() >= doc->glyphs().size()) // should not happen?
 		return QVariant();
 
@@ -218,21 +218,24 @@ void GlyphsModel::drawContours(PathList *paths, const Glyph *glyph, int order, Q
 	if (order > 10)
 		return;
 
-	foreach (const QVariant &v, glyph->content) {
-		if (v.canConvert<Contour>()) {
-			Contour c = v.value<Contour>();
-			if (!c.isOpen())
+	foreach (const GlyphContentBase *i, glyph->content) {
+		if (i->type() == GlyphContentBase::Contour) {
+			const GlyphContour *c = qobject_cast<const GlyphContour *>(i);
+			Q_ASSERT(c);
+
+			if (!c->isOpen())
 				glyphPath.path.addPath(GlyphGraphics::contourToPath(c));
 		}
 		else {
-			Q_ASSERT(v.canConvert<GlyphRef>());
-			GlyphRef ref = v.value<GlyphRef>();
+			Q_ASSERT(i->type() == GlyphContentBase::Reference);
+			const GlyphReference *ref = qobject_cast<const GlyphReference *>(i);
+			Q_ASSERT(ref);
 
 			FontDocument *doc = glyph->document();
 			if (doc) {
-				const Glyph *otherGlyph = doc->getGlyph(ref.glyphName());
+				const Glyph *otherGlyph = doc->getGlyph(ref->glyphName());
 				if (otherGlyph) {
-					QPoint newOffset((int)ref.offset().x(), (int)ref.offset().y());
+					QPoint newOffset((int)ref->offset().x(), (int)ref->offset().y());
 					newOffset += off;
 					drawContours(paths, otherGlyph, order + 1, newOffset);
 				}
@@ -248,7 +251,7 @@ void GlyphsModel::drawGlyph(PathList *paths, const Glyph *glyph)
 	drawContours(paths, glyph, 0, QPoint(0, 0));
 
 	QRectF rect;
-	
+
 	foreach(const PathWithOffset &p, *paths) {
 		rect |= rect.united(p.path.boundingRect().translated(p.offset));
 	}
diff --git a/nongui/fontdocumentreader.cxx b/nongui/fontdocumentreader.cxx
index acb4a27..428ab70 100644
--- a/nongui/fontdocumentreader.cxx
+++ b/nongui/fontdocumentreader.cxx
@@ -17,9 +17,10 @@
 #include "fontdocumentreader.h"
 #include <QPointF>
 #include <QDebug>
-#include "glyphref.h"
-#include "contour.h"
+#include "glyphreference.h"
+#include "glyphcontour.h"
 #include "fontdocument.h"
+#include <QVariant>
 
 bool FontDocumentReader::read(QIODevice *device)
 {
@@ -90,7 +91,7 @@ void FontDocumentReader::readFont()
 				doc->setFontName(attributes().value("font-name").toString());
 				doc->setFontFamily(attributes().value("font-family").toString());
 				doc->setFontWeight(attributes().value("font-weight").toString());
-				
+
 				val = readRealAttribute("italic-angle", true, 0, &ok);
 				if (!ok) return;
 				doc->setItalicAngle(val);
@@ -274,8 +275,8 @@ void FontDocumentReader::readContent(Glyph *glyph)
 				qreal yVal = readRealAttribute("y", true, 0, &ok);
 				if (!ok) return;
 
-				GlyphRef ref(g.toString(), QPointF(xVal, yVal));
-				glyph->content << qVariantFromValue(ref);
+				GlyphReference *ref = new GlyphReference(g.toString(), QPointF(xVal, yVal), glyph);
+				glyph->content << ref;
 				readUnknownElement();
 			}
 			else
@@ -288,11 +289,11 @@ void FontDocumentReader::readContour(Glyph *glyph)
 {
 	Q_ASSERT(isStartElement() && name() == "contour");
 
-	Contour contour;
+	GlyphContour *contour = new GlyphContour(false, glyph);
 
 	const QStringRef isOpen = attributes().value("open");
 	if (isOpen == "1")
-		contour.setOpen();
+		contour->setOpen(true);
 
 	while (!atEnd()) {
 		readNext();
@@ -313,14 +314,14 @@ void FontDocumentReader::readContour(Glyph *glyph)
 
 				bool on = (attributes().value("on") != "no");
 
-				contour.append(GlyphPoint(xVal, yVal, on));
+				contour->points.append(GlyphPoint(xVal, yVal, on));
 				readUnknownElement();
 			}
 			else
 				readUnknownElement();
 		}
 	}
-	glyph->content << qVariantFromValue(contour);
+	glyph->content << contour;
 }
 
 void FontDocumentReader::readCvt()
diff --git a/nongui/fontdocumentwriter.cxx b/nongui/fontdocumentwriter.cxx
index 5a3fd1b..202bf6a 100644
--- a/nongui/fontdocumentwriter.cxx
+++ b/nongui/fontdocumentwriter.cxx
@@ -17,8 +17,8 @@
 #include "fontdocumentwriter.h"
 #include "fontdocument.h"
 #include "glyph.h"
-#include "contour.h"
-#include "glyphref.h"
+#include "glyphcontour.h"
+#include "glyphreference.h"
 
 FontDocumentWriter::FontDocumentWriter(const FontDocument *doc)
 {
@@ -68,7 +68,7 @@ bool FontDocumentWriter::writeHeaderData()
 	writeNonZeroRealAttribute("ascent", doc->ascent());
 	writeNonZeroRealAttribute("descent", doc->descent());
 	// TODO panose
-	
+
 	if (!doc->copyright().isEmpty())
 		writeTextElement("copyright", doc->copyright());
 
@@ -137,17 +137,19 @@ bool FontDocumentWriter::writeGlyphs()
 	return true;
 }
 
-bool FontDocumentWriter::writeGlyphContent(const QList<QVariant> &content)
+bool FontDocumentWriter::writeGlyphContent(const GlyphContentList &content)
 {
 	writeStartElement("content");
 
-	foreach (const QVariant &i, content) {
-		if (i.canConvert<Contour>()) {
-			const Contour &contour = i.value<Contour>();
+	foreach (const GlyphContentBase *i, content) {
+		if (i->type() == GlyphContentBase::Contour) {
+			const GlyphContour *contour = qobject_cast<const GlyphContour *>(i);
+			Q_ASSERT(contour);
+
 			writeStartElement("contour");
-			if (contour.isOpen())
+			if (contour->isOpen())
 				writeAttribute("open", "1");
-			foreach (const GlyphPoint &pt, contour) {
+			foreach (const GlyphPoint &pt, contour->points) {
 				writeEmptyElement("pt");
 				writeAttribute("x", QString::number(pt.x()));
 				writeAttribute("y", QString::number(pt.y()));
@@ -157,12 +159,15 @@ bool FontDocumentWriter::writeGlyphContent(const QList<QVariant> &content)
 			writeEndElement(); // contour
 		}
 		else {
-			Q_ASSERT(i.canConvert<GlyphRef>());
-			const GlyphRef &ref = i.value<GlyphRef>();
+			Q_ASSERT(i->type() == GlyphContentBase::Reference);
+
+			const GlyphReference *ref = qobject_cast<const GlyphReference *>(i);
+			Q_ASSERT(ref);
+
 			writeEmptyElement("ref");
-			writeAttribute("g", ref.glyphName());
-			writeNonZeroRealAttribute("x", ref.offset().x());
-			writeNonZeroRealAttribute("y", ref.offset().y());
+			writeAttribute("g", ref->glyphName());
+			writeNonZeroRealAttribute("x", ref->offset().x());
+			writeNonZeroRealAttribute("y", ref->offset().y());
 		}
 	}
 	writeEndElement(); // content
diff --git a/nongui/fontdocumentwriter.h b/nongui/fontdocumentwriter.h
index 94330db..8e0ac81 100644
--- a/nongui/fontdocumentwriter.h
+++ b/nongui/fontdocumentwriter.h
@@ -17,6 +17,7 @@
 #ifndef FONTDOCUMENTWRITER_H
 #define FONTDOCUMENTWRITER_H
 #include <QXmlStreamWriter>
+#include "glyphcontentbase.h"
 
 class FontDocument;
 class Glyph;
@@ -43,7 +44,7 @@ private:
 	bool writeHeaderData();
 	bool writeInstructionTables();
 	bool writeGlyphs();
-	bool writeGlyphContent(const QList<QVariant> &content);
+	bool writeGlyphContent(const GlyphContentList &content);
 };
 
 #endif
diff --git a/nongui/glyph.cxx b/nongui/glyph.cxx
index 904e3bb..7bb2190 100644
--- a/nongui/glyph.cxx
+++ b/nongui/glyph.cxx
@@ -15,8 +15,8 @@
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
  */
 #include "glyph.h"
-#include "contour.h"
-#include "glyphref.h"
+#include "glyphcontour.h"
+#include "glyphreference.h"
 #include "fontdocument.h"
 
 /** Construct an empty glyph with given name.
@@ -251,18 +251,18 @@ bool Glyph::computeMetrics(qreal &xMin, qreal &xMax, qreal &yMin, qreal &yMax) c
 		xMin = xMax = yMin = yMax = 0;
 	return false;
 	}
-	Contour c = content.at(0).value<Contour>();
-	if (c.isEmpty())
+	const GlyphContour *c = qobject_cast<const GlyphContour *>(content.at(0));
+	if (c->points.isEmpty())
 		return false; // empty contours are not allowed
-	xMin = xMax = c.at(0).x();
-	yMin = yMax = c.at(0).y();
-	
+	xMin = xMax = c->points.at(0).x();
+	yMin = yMax = c->points.at(0).y();
+
 	int contNo = 0;
 	int pointNo = 1;
 
 	for (;;) {
-		while (pointNo < c.size()) {
-			const GlyphPoint &pt = c.at(pointNo);
+		while (pointNo < c->points.size()) {
+			const GlyphPoint &pt = c->points.at(pointNo);
 			qreal x = pt.x();
 			qreal y = pt.y();
 			if (xMin > x) xMin = x;
@@ -273,11 +273,13 @@ bool Glyph::computeMetrics(qreal &xMin, qreal &xMax, qreal &yMin, qreal &yMax) c
 		}
 		contNo++;
 		pointNo = 0;
-		if (contNo < content.size())
-			c = content[contNo].value<Contour>();
+		if (contNo < content.size()) {
+			c = qobject_cast<const GlyphContour*>(content[contNo]);
+			Q_ASSERT(c);
+		}
 		else
 			break;
-		if (c.isEmpty())
+		if (c->points.isEmpty())
 			return false;
 	}
 	return true;
@@ -288,11 +290,11 @@ void Glyph::countParts(unsigned &nContours, unsigned &nRefs) const
 	nContours = 0;
 	nRefs = 0;
 
-	foreach (const QVariant &v, content) {
-		if (v.canConvert<Contour>())
+	foreach (const GlyphContentBase *i, content) {
+		if (i->type() == GlyphContentBase::Contour)
 			nContours++;
 		else {
-			Q_ASSERT(v.canConvert<GlyphRef>());
+			Q_ASSERT(i->type() == GlyphContentBase::Reference);
 			nRefs++;
 		}
 	}
@@ -301,18 +303,15 @@ void Glyph::countParts(unsigned &nContours, unsigned &nRefs) const
 void Glyph::movePoint(int component, int pointNo, const QPointF &newPos)
 {
 	Q_ASSERT(component < content.size());
-	QVariant v = content.at(component);
-	Q_ASSERT(v.canConvert<Contour>());
-
-	Contour contour = v.value<Contour>();
-	Q_ASSERT(pointNo < contour.size());
+	GlyphContour *contour = qobject_cast<GlyphContour *>(content.at(component));
+	Q_ASSERT(contour);
+	Q_ASSERT(pointNo < contour->points.size());
 
-	GlyphPoint pt = contour.at(pointNo);
+	GlyphPoint pt = contour->points.at(pointNo);
 	if (pt.x() != newPos.x() || pt.y() != newPos.y()) {
 		pt.setX(newPos.x());
 		pt.setY(newPos.y());
-		contour[pointNo] = pt;
-		content[component] = qVariantFromValue(contour);
+		contour->points[pointNo] = pt;
 
 		emit pointMoved(component, pointNo, newPos);
 		emit outlineChanged();
diff --git a/nongui/glyph.h b/nongui/glyph.h
index 566d72b..3bf8854 100644
--- a/nongui/glyph.h
+++ b/nongui/glyph.h
@@ -17,8 +17,7 @@
 #ifndef GLYPH_H
 #define GLYPH_H
 #include <QString>
-#include <QList>
-#include <QVariant>
+#include "glyphcontentbase.h"
 
 class FontDocument;
 
@@ -41,10 +40,10 @@ public:
 	FontDocument *document() const;
 	/** Glyph outlines.
 	 * This list holds all contours and references inside the glyph.
-	 * It can contain values of type \ref Contour or \ref GlyphRef.
-	 * @sa Contour and GlyphRef
+	 * It can contain values of type \ref GlyphContour or \ref GlyphReference.
+	 * @sa GlyphContour and GlyphReference
 	 */
-	QList<QVariant> content; // TODO hide it
+	GlyphContentList content; // TODO hide it
 
 	bool setGlyphName(const QString &name);
 	QString glyphName() const;
diff --git a/nongui/contour.h b/nongui/glyphcontentbase.h
similarity index 65%
copy from nongui/contour.h
copy to nongui/glyphcontentbase.h
index 5875acf..58f8dec 100644
--- a/nongui/contour.h
+++ b/nongui/glyphcontentbase.h
@@ -14,25 +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 CONTOUR_H
-#define CONTOUR_H
-
-#include <QList>
+#ifndef GLYPHCONTENTBASE_H
+#define GLYPHCONTENTBASE_H
+#include <QObject>
 #include <QMetaType>
-#include "glyphpoint.h"
+#include <QList>
 
-/** Type reperesenting a contour in a glyph.
- */
-class Contour : public QList<GlyphPoint>
-{
+class GlyphContentBase : public QObject {
+	Q_OBJECT
+	Q_ENUMS(ContentType)
+	Q_PROPERTY(ContentType type READ type)
 public:
-	Contour(bool open = false) : QList<GlyphPoint>(), m_isOpen(open) {}
-	bool isOpen() const {return m_isOpen;}
-	void setOpen(bool open = true) {m_isOpen = open;}
-private:
-	bool m_isOpen;
+	enum ContentType {Reference, Contour};
+
+	// FIXME maybe use Glyph as parent
+	GlyphContentBase(QObject *parent = 0) : QObject(parent) {}
+	virtual ContentType type() const = 0;
 };
 
-Q_DECLARE_METATYPE(Contour)
+Q_DECLARE_METATYPE(GlyphContentBase*)
+
+typedef QList<GlyphContentBase*> GlyphContentList;
 
 #endif
diff --git a/qscript/constructors.h b/nongui/glyphcontour.cxx
similarity index 77%
copy from qscript/constructors.h
copy to nongui/glyphcontour.cxx
index c17d992..32112de 100644
--- a/qscript/constructors.h
+++ b/nongui/glyphcontour.cxx
@@ -14,11 +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 CONSTRUCTORS_H
-#define CONSTRUCTORS_H
+#include "glyphcontour.h"
 
-class QScriptEngine;
+GlyphContour::GlyphContour(bool open, QObject *parent) :
+	GlyphContentBase(parent), m_open(open)
+{
+}
 
-void initScripting(QScriptEngine *engine);
+bool GlyphContour::isOpen() const
+{
+	return m_open;
+}
 
-#endif
+void GlyphContour::setOpen(bool open)
+{
+	m_open = open;
+}
diff --git a/nongui/contour.h b/nongui/glyphcontour.h
similarity index 68%
rename from nongui/contour.h
rename to nongui/glyphcontour.h
index 5875acf..597a495 100644
--- a/nongui/contour.h
+++ b/nongui/glyphcontour.h
@@ -14,25 +14,25 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
  */
-#ifndef CONTOUR_H
-#define CONTOUR_H
-
-#include <QList>
-#include <QMetaType>
+#ifndef GLYPHCONTOUR_H
+#define GLYPHCONTOUR_H
+#include "glyphcontentbase.h"
 #include "glyphpoint.h"
+#include <QList>
 
-/** Type reperesenting a contour in a glyph.
- */
-class Contour : public QList<GlyphPoint>
-{
+class GlyphContour : public GlyphContentBase {
+	Q_OBJECT
+	Q_PROPERTY(bool open READ isOpen WRITE setOpen)
 public:
-	Contour(bool open = false) : QList<GlyphPoint>(), m_isOpen(open) {}
-	bool isOpen() const {return m_isOpen;}
-	void setOpen(bool open = true) {m_isOpen = open;}
+	GlyphContour(bool open = false, QObject *parent = 0);
+	ContentType type() const {return Contour;}
+
+	bool isOpen() const;
+	void setOpen(bool open = true);
+	// XXX TODO make it private
+	GlyphPointList points;
 private:
-	bool m_isOpen;
+	bool m_open;
 };
 
-Q_DECLARE_METATYPE(Contour)
-
 #endif
diff --git a/src/script.cxx b/nongui/glyphreference.cxx
similarity index 56%
copy from src/script.cxx
copy to nongui/glyphreference.cxx
index 2ca51f0..0607f1b 100644
--- a/src/script.cxx
+++ b/nongui/glyphreference.cxx
@@ -14,20 +14,34 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
  */
-#include <QApplication>
-#include <QtScript>
-#include <QString>
-#include "scriptconsole.h"
+#include "glyphreference.h"
 
-int main(int  argc, char **argv)
+GlyphReference::GlyphReference(const QString &name, const QPointF &off, QObject *parent) :
+	GlyphContentBase(parent), m_glyphName(name), m_offset(off)
 {
-	QApplication app(argc, argv);
+}
+
+GlyphReference::GlyphReference(const GlyphReference &other) :
+	GlyphContentBase(), m_glyphName(other.m_glyphName), m_offset(other.m_offset)
+{
+}
+
+QPointF GlyphReference::offset() const
+{
+	return m_offset;
+}
 
-	ScriptConsole *con = new ScriptConsole;
+void GlyphReference::setOffset(const QPointF &newOffset)
+{
+	m_offset = newOffset;
+}
 
-	con->setWindowTitle("Script Console");
-	con->resize(640, 480);
-	con->show();
+QString GlyphReference::glyphName() const
+{
+	return m_glyphName;
+}
 
-	return app.exec();
+void GlyphReference::setGlyphName(const QString &newName)
+{
+	m_glyphName = newName;
 }
diff --git a/nongui/glyphref.h b/nongui/glyphreference.h
similarity index 58%
rename from nongui/glyphref.h
rename to nongui/glyphreference.h
index 7e76e3c..f340de6 100644
--- a/nongui/glyphref.h
+++ b/nongui/glyphreference.h
@@ -14,25 +14,29 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
  */
-#ifndef GLYPHREF_H
-#define GLYPHREF_H
+#ifndef GLYPHREFERENCE_H
+#define GLYPHREFERENCE_H
+#include "glyphcontentbase.h"
 #include <QString>
 #include <QPointF>
-#include <QMetaType>
 
-class GlyphRef {
+class GlyphReference : public GlyphContentBase {
+	Q_OBJECT
+	Q_PROPERTY(QPointF offset READ offset WRITE setOffset)
+	Q_PROPERTY(QString glyphName READ glyphName WRITE setGlyphName)
 public:
-	GlyphRef(const QString &name = 0, const QPointF &off = QPointF(0, 0)) : m_name(name), m_off(off) {}
-	GlyphRef(const GlyphRef &other) {m_name = other.m_name; m_off = other.m_off;}
-	const QPointF &offset() const {return m_off;}
-	void setOffset(const QPointF &off) {m_off = off;}
-	const QString &glyphName() const {return m_name;}
-	void setGlyphName(const QString &name) {m_name = name;}
+	GlyphReference(const QString &name = 0, const QPointF &off = QPointF(), QObject *parent = 0);
+	GlyphReference(const GlyphReference &other);
+	ContentType type() const {return Reference;}
+
+	QPointF offset() const;
+	void setOffset(const QPointF &newOffset);
+
+	QString glyphName() const;
+	void setGlyphName(const QString &newName);
 private:
-	QString m_name;
-	QPointF m_off;
+	QString m_glyphName;
+	QPointF m_offset;
 };
 
-Q_DECLARE_METATYPE(GlyphRef)
-
 #endif
diff --git a/nongui/nongui.rules b/nongui/nongui.rules
index 0da5196..925f560 100644
--- a/nongui/nongui.rules
+++ b/nongui/nongui.rules
@@ -10,7 +10,9 @@ libfonduenongui_a_SOURCES =		\
 	nongui/ttfwriter.cxx		\
 	nongui/glyph.cxx		\
 	nongui/unicodenameslist.cxx	\
-	nongui/documentinfomodel.cxx
+	nongui/documentinfomodel.cxx	\
+	nongui/glyphreference.cxx	\
+	nongui/glyphcontour.cxx
 
 nodist_libfonduenongui_a_SOURCES = 		\
 	nongui/decodertable.tbl.cxx		\
@@ -19,7 +21,10 @@ nodist_libfonduenongui_a_SOURCES = 		\
 	nongui/encodertable.tbl.cxx		\
 	nongui/unicodenameslist.awked.cxx	\
 	nongui/documentinfomodel.moc.cxx	\
-	nongui/cvtmodel.moc.cxx
+	nongui/cvtmodel.moc.cxx			\
+	nongui/glyphcontentbase.moc.cxx		\
+	nongui/glyphreference.moc.cxx		\
+	nongui/glyphcontour.moc.cxx
 
 nongui/decodertable.tbl.cxx: data/instructions.xml
 nongui/decodertable.tbl.cxx: DATAFILE=$(srcdir)/data/instructions.xml
@@ -38,8 +43,6 @@ CLEANFILES += nongui/*.tbl.cxx nongui/*.moc.cxx nongui/*.awked.cxx
 noinst_HEADERS +=			\
 	nongui/ttfdecode.h		\
 	nongui/glyphpoint.h		\
-	nongui/glyphref.h		\
-	nongui/contour.h		\
 	nongui/glyph.h			\
 	nongui/fontdocument.h		\
 	nongui/fontdocumentreader.h	\
@@ -49,7 +52,10 @@ noinst_HEADERS +=			\
 	nongui/cvtmodel.h		\
 	nongui/ttfwriter.h		\
 	nongui/unicodenameslist.h	\
-	nongui/documentinfomodel.h
+	nongui/documentinfomodel.h	\
+	nongui/glyphcontentbase.h	\
+	nongui/glyphreference.h		\
+	nongui/glyphcontour.h
 
 EXTRA_DIST +=				\
 	nongui/decodertable.xsl		\
diff --git a/nongui/ttfwriter.cxx b/nongui/ttfwriter.cxx
index a1f3775..7160a38 100644
--- a/nongui/ttfwriter.cxx
+++ b/nongui/ttfwriter.cxx
@@ -22,7 +22,7 @@
 #include "fontdocument.h"
 #include <QBuffer>
 #include "ttfencode.h"
-#include "contour.h"
+#include "glyphcontour.h"
 #include <QStringList>
 
 static inline quint32 makeTag(unsigned char a, unsigned char b,
@@ -335,9 +335,11 @@ bool TTFWriter::writeSimpleGlyph(QIODevice *dev, const Glyph *g)
 		return false;
 	// write endpoints of contours
 	int nPoints = 0;
-	foreach (QVariant v, g->content) {
-		Contour c = v.value<Contour>();
-		nPoints += c.size();
+	foreach (const GlyphContentBase *i, g->content) {
+		const GlyphContour *c = qobject_cast<const GlyphContour *>(i);
+		Q_ASSERT(c);
+
+		nPoints += c->points.size();
 		if (!writeBigEndian(dev, (qint16)(nPoints - 1)))
 			return false;
 	}
@@ -360,9 +362,11 @@ bool TTFWriter::writeSimpleGlyph(QIODevice *dev, const Glyph *g)
 		return false;
 	// write flags
 	// TODO optimize those flags
-	foreach (QVariant v, g->content) {
-		Contour c = v.value<Contour>();
-		foreach (const GlyphPoint &pt, c) {
+	foreach (const GlyphContentBase *i, g->content) {
+		const GlyphContour *c = qobject_cast<const GlyphContour*>(i);
+		Q_ASSERT(c);
+
+		foreach (const GlyphPoint &pt, c->points) {
 			char flags = 0;
 			if (pt.on())
 				flags |= TTFLAG_ON_CURVE;
@@ -374,9 +378,11 @@ bool TTFWriter::writeSimpleGlyph(QIODevice *dev, const Glyph *g)
 	// all coordinates are 16-bit for now
 	// start with x-coordinates
 	qint16 prev = 0;
-	foreach (QVariant v, g->content) {
-		Contour c = v.value<Contour>();
-		foreach (const GlyphPoint &pt, c) {
+	foreach (const GlyphContentBase *i, g->content) {
+		const GlyphContour *c = qobject_cast<const GlyphContour*>(i);
+		Q_ASSERT(c);
+
+		foreach (const GlyphPoint &pt, c->points) {
 			qint16 thisPoint =  (qint16)pt.x();
 			if (!writeBigEndian<qint16>(dev, thisPoint - prev))
 				return false;
@@ -385,9 +391,9 @@ bool TTFWriter::writeSimpleGlyph(QIODevice *dev, const Glyph *g)
 	}
 	// and y-coordinates
 	prev = 0;
-	foreach (QVariant v, g->content) {
-		Contour c = v.value<Contour>();
-		foreach (const GlyphPoint &pt, c) {
+	foreach (const GlyphContentBase *i, g->content) {
+		const GlyphContour *c = qobject_cast<const GlyphContour *>(i);
+		foreach (const GlyphPoint &pt, c->points) {
 			qint16 thisPoint =  (qint16)pt.y();
 			if (!writeBigEndian<qint16>(dev, thisPoint - prev))
 				return false;

commit ef63ea9d84d72740b0c2ebcab998e258a52e87a0
Author: Eugeniy Meshcheryakov <eugen at debian.org>
Date:   Sun Dec 23 00:59:32 2007 +0100

    add type GlyphPointList and declare metatypes

diff --git a/nongui/glyphpoint.h b/nongui/glyphpoint.h
index ac94cd4..f0da85a 100644
--- a/nongui/glyphpoint.h
+++ b/nongui/glyphpoint.h
@@ -17,6 +17,8 @@
 #ifndef GLYPHPOINT_H
 #define GLYPHPOINT_H
 #include <QPointF>
+#include <QList>
+#include <QMetaType>
 
 class GlyphPoint: public QPointF {
 public:
@@ -30,4 +32,9 @@ private:
 	bool m_on;
 };
 
+typedef QList<GlyphPoint> GlyphPointList;
+
+Q_DECLARE_METATYPE(GlyphPoint)
+Q_DECLARE_METATYPE(GlyphPointList)
+
 #endif

-- 
Fondue Font Editor



More information about the fondue-commits mailing list