[fondue-commits] [SCM] Fondue Font Editor branch, master, updated. b5056198e5469181556c59ce0c6911699b8fddcc
Eugeniy Meshcheryakov
eugen at debian.org
Wed Feb 6 20:23:36 UTC 2008
The following commit has been merged in the master branch:
commit b5056198e5469181556c59ce0c6911699b8fddcc
Author: Eugeniy Meshcheryakov <eugen at debian.org>
Date: Wed Feb 6 21:23:11 2008 +0100
remove empty contours from glyphs
diff --git a/gui/glyphitem.cxx b/gui/glyphitem.cxx
index c9843a7..8c7f15a 100644
--- a/gui/glyphitem.cxx
+++ b/gui/glyphitem.cxx
@@ -23,13 +23,13 @@ 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
@@ -37,7 +37,7 @@ QRectF GlyphItemBase::boundingRect() const
QPainterPath path;
bool hadContours = false;
- foreach (const GlyphContentBase *i, m_content) {
+ foreach (const GlyphContentBase *i, m_gfx->m_glyph->content()) {
if (i->type() == GlyphContentBase::Contour) {
const GlyphContour *c = qobject_cast<const GlyphContour *>(i);
Q_ASSERT(c);
@@ -58,7 +58,7 @@ void GlyphItemBase::paintOutline(QPainter *painter, bool paintOpen)
{
QPainterPath path;
- foreach (const GlyphContentBase *i, m_content) {
+ foreach (const GlyphContentBase *i, m_gfx->m_glyph->content()) {
if (i->type() == GlyphContentBase::Contour) {
const GlyphContour *c = qobject_cast<const GlyphContour *>(i);
Q_ASSERT(c);
@@ -74,7 +74,7 @@ void GlyphItemBase::paintOutline(QPainter *painter, bool paintOpen)
if (paintOpen) {
// draw open contours
- foreach (const GlyphContentBase *i, m_content) {
+ foreach (const GlyphContentBase *i, m_gfx->m_glyph->content()) {
if (i->type() == GlyphContentBase::Contour) {
const GlyphContour *c = qobject_cast<const GlyphContour *>(i);
Q_ASSERT(c);
@@ -89,7 +89,7 @@ void GlyphItemBase::paintFill(QPainter *painter)
{
QPainterPath path;
- foreach (const GlyphContentBase *i, m_content) {
+ foreach (const GlyphContentBase *i, m_gfx->m_glyph->content()) {
if (i->type() == GlyphContentBase::Contour) {
const GlyphContour *c = qobject_cast<const GlyphContour *>(i);
Q_ASSERT(c);
diff --git a/gui/glyphitem.h b/gui/glyphitem.h
index 9eb45c9..aa38ae5 100644
--- a/gui/glyphitem.h
+++ b/gui/glyphitem.h
@@ -32,7 +32,8 @@ protected:
void paintFill(QPainter *painter);
GlyphGraphics *m_gfx;
- GlyphContentList m_content;
+ // XXX does not work for now
+// GlyphContentList m_content;
};
class GlyphItemOutline : public GlyphItemBase {
diff --git a/nongui/glyph.cxx b/nongui/glyph.cxx
index 3573f90..a89892b 100644
--- a/nongui/glyph.cxx
+++ b/nongui/glyph.cxx
@@ -18,6 +18,7 @@
#include "glyphcontour.h"
#include "glyphreference.h"
#include "fontdocument.h"
+#include <QtDebug>
/** Construct an empty glyph with given name.
* @param name a name for the new glyph.
@@ -63,6 +64,7 @@ void Glyph::appendContour(GlyphContour *contour)
m_content << contour;
connect(contour, SIGNAL(pointChanged(int)), this, SLOT(contourPointChanged()));
+ connect(contour, SIGNAL(contourBecomeEmpty()), this, SLOT(contourBecomeEmpty()));
emit outlineChanged();
setChanged();
}
@@ -346,3 +348,19 @@ void Glyph::contourPointChanged()
emit outlineChanged();
}
+
+void Glyph::contourBecomeEmpty()
+{
+ GlyphContour *contour = qobject_cast<GlyphContour *>(sender());
+ Q_ASSERT(contour);
+ Q_ASSERT(contour->isEmpty());
+ int id = m_content.indexOf(contour);
+ Q_ASSERT(id != -1);
+
+ qDebug() << "Removing empty contour from glyph:" << glyphName() << id;
+
+ emit contentAboutToBeRemoved(id);
+ m_content.removeAt(id);
+ contour->deleteLater();
+ emit contentRemoved(id);
+}
diff --git a/nongui/glyph.h b/nongui/glyph.h
index 8948821..ba306a4 100644
--- a/nongui/glyph.h
+++ b/nongui/glyph.h
@@ -83,8 +83,13 @@ signals:
void unicodeChanged(int oldUnicode, int newUnicode);
void outlineChanged();
+
+ // XXX also emit signals when content added
+ void contentAboutToBeRemoved(int id);
+ void contentRemoved(int id);
private slots:
void contourPointChanged();
+ void contourBecomeEmpty();
private:
QString m_glyphName;
qreal horiz_adv_x;
--
Fondue Font Editor
More information about the fondue-commits
mailing list