[fondue-commits] [SCM] Fondue Font Editor branch, master, updated. 90d2dc3a7c9f45e1bece97e642935801a27c1990
Eugeniy Meshcheryakov
eugen at debian.org
Mon Sep 17 12:41:01 UTC 2007
The branch, master has been updated
via 90d2dc3a7c9f45e1bece97e642935801a27c1990 (commit)
via 79b7057883d619287afb55d6a683b3cd919929a1 (commit)
from 11636224ec6634bccb6f75feaf7b514f43086580 (commit)
- Shortlog ------------------------------------------------------------
90d2dc3 forgot to add those two files
79b7057 rename s/glyphs-class/glyph-class/
Summary of changes:
gui/glyphitem.cxx | 109 +++++++++++++++++++++++++++++++++++++++++++++++++++++
gui/glyphitem.h | 44 +++++++++++++++++++++
scripts/conv.rb | 4 +-
3 files changed, 155 insertions(+), 2 deletions(-)
-----------------------------------------------------------------------
Details of changes:
commit 90d2dc3a7c9f45e1bece97e642935801a27c1990
Author: Eugeniy Meshcheryakov <eugen at debian.org>
Date: Mon Sep 17 14:40:43 2007 +0200
forgot to add those two files
diff --git a/gui/glyphitem.cxx b/gui/glyphitem.cxx
new file mode 100644
index 0000000..3cc59c8
--- /dev/null
+++ b/gui/glyphitem.cxx
@@ -0,0 +1,109 @@
+/* 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 "glyphitem.h"
+#include "glyphgraphics.h"
+#include "glyph.h"
+#include <QPainter>
+
+GlyphItemBase::GlyphItemBase(GlyphGraphics *gfx, QGraphicsItem *parent) :
+ QGraphicsItem(parent), m_gfx(gfx)
+{
+ Q_ASSERT(m_gfx);
+ m_content = m_gfx->glyph()->content;
+}
+
+void GlyphItemBase::update()
+{
+ prepareGeometryChange();
+ m_content = m_gfx->glyph()->content;
+}
+
+QRectF GlyphItemBase::boundingRect() const
+{
+ QPainterPath path;
+ bool hadContours = false;
+
+ foreach (const QVariant &v, m_content) {
+ if (v.canConvert<Contour>()) {
+ Contour c = v.value<Contour>();
+ path.addPath(GlyphGraphics::contourToPath(c));
+ hadContours = true;
+ }
+ }
+ if (hadContours) {
+ QRectF rect = path.boundingRect();
+ qreal top = rect.bottom(), left = rect.left();
+ QSizeF size = rect.size();
+ return QRectF(QPointF(left, -top), size);
+ }
+ return QRectF();
+}
+
+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())
+ path.addPath(GlyphGraphics::contourToPath(c));
+ }
+ }
+
+ painter->scale(1, -1);
+ painter->setPen(Qt::black);
+ painter->setBrush(Qt::NoBrush);
+ painter->drawPath(path);
+
+ if (paintOpen) {
+ // draw open contours
+ foreach (const QVariant &v, m_content) {
+ if (v.canConvert<Contour>()) {
+ Contour c = v.value<Contour>();
+ if (c.isOpen())
+ painter->drawPath(GlyphGraphics::contourToPath(c));
+ }
+ }
+ }
+}
+
+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())
+ path.addPath(GlyphGraphics::contourToPath(c));
+ }
+ }
+
+ painter->scale(1, -1);
+ painter->setPen(Qt::NoBrush);
+ painter->setBrush(Qt::gray); // filling should be moved to other place
+ painter->drawPath(path);
+}
+
+void GlyphItemOutline::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
+{
+ Q_UNUSED(option);
+ Q_UNUSED(widget);
+
+ paintOutline(painter);
+}
diff --git a/gui/controlpoint.h b/gui/glyphitem.h
similarity index 64%
copy from gui/controlpoint.h
copy to gui/glyphitem.h
index e30a7ef..7aea156 100644
--- a/gui/controlpoint.h
+++ b/gui/glyphitem.h
@@ -14,27 +14,31 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#ifndef CONTROLPOINT_H
-#define CONTROLPOINT_H
+#ifndef GLYPHITEM_H
+#define GLYPHITEM_H
#include <QGraphicsItem>
-#include "glyphgraphics.h"
+#include <QList>
+#include <QVariant>
-class GlyphPoint;
+class GlyphGraphics;
-class ControlPoint: public QGraphicsItem {
+class GlyphItemBase : public QGraphicsItem {
public:
- ControlPoint(GlyphGraphics *gfx, const GlyphGraphics::PointIndex &idx, QGraphicsItem *parent);
- enum {Type = UserType + 1};
- int type() const {return Type;}
+ GlyphItemBase(GlyphGraphics *gfx, QGraphicsItem *parent = 0);
+ void update();
QRectF boundingRect() const;
- QPainterPath shape() const;
- void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
- GlyphGraphics::PointIndex idx() const {return m_idx;}
protected:
- QVariant itemChange(GraphicsItemChange change, const QVariant &value);
-private:
+ void paintOutline(QPainter *painter, bool paintOpen = true);
+ void paintFill(QPainter *painter);
+
GlyphGraphics *m_gfx;
- GlyphGraphics::PointIndex m_idx;
+ QList<QVariant> m_content;
+};
+
+class GlyphItemOutline : public GlyphItemBase {
+public:
+ GlyphItemOutline(GlyphGraphics *gfx, QGraphicsItem *parent = 0) : GlyphItemBase(gfx, parent) {}
+ void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);
};
#endif
commit 79b7057883d619287afb55d6a683b3cd919929a1
Author: Eugeniy Meshcheryakov <eugen at debian.org>
Date: Thu Sep 13 13:57:31 2007 +0200
rename s/glyphs-class/glyph-class/
diff --git a/scripts/conv.rb b/scripts/conv.rb
index 2bbbcf2..b336e93 100755
--- a/scripts/conv.rb
+++ b/scripts/conv.rb
@@ -170,12 +170,12 @@ def decode_kernclass(value, f)
kern << char1 = XML::Node.new("char1")
raise "Not implemented: + after char1 in KernClass2" if first =~ /\+$/
(first.to_i - 1).times do
- char1 << klass = XML::Node.new("glyphs-class")
+ char1 << klass = XML::Node.new("glyph-class")
decode_glyphslist(f.readline.strip) {|e| klass << e}
end
kern << char2 = XML::Node.new("char2")
(second.to_i - 1).times do
- char2 << klass = XML::Node.new("glyphs-class")
+ char2 << klass = XML::Node.new("glyph-class")
decode_glyphslist(f.readline.strip) {|e| klass << e}
end
# read the data
--
Fondue Font Editor
More information about the fondue-commits
mailing list