[fondue-commits] [SCM] Fondue Font Editor branch, master, updated. 9b2b5f453f09271ecb794a8f736ae884eb3e3de4
Eugeniy Meshcheryakov
eugen at debian.org
Mon Aug 20 09:47:14 UTC 2007
The branch, master has been updated
via 9b2b5f453f09271ecb794a8f736ae884eb3e3de4 (commit)
via 577b5b2c288bb64a188d1301bb0bc4c11703bbc9 (commit)
via 62298574062d44f8bcb0215f5ef78d385a3e001b (commit)
via d246b573c3002222798d20598b010bba75f7f843 (commit)
from 294b41261f05045cfdab18112890770471b4784e (commit)
- Log -----------------------------------------------------------------
commit 9b2b5f453f09271ecb794a8f736ae884eb3e3de4
Author: Eugeniy Meshcheryakov <eugen at debian.org>
Date: Mon Aug 20 11:47:01 2007 +0200
correctly draw open contours in glyph view
commit 577b5b2c288bb64a188d1301bb0bc4c11703bbc9
Author: Eugeniy Meshcheryakov <eugen at debian.org>
Date: Mon Aug 20 11:39:40 2007 +0200
do not draw open contours on icons
commit 62298574062d44f8bcb0215f5ef78d385a3e001b
Author: Eugeniy Meshcheryakov <eugen at debian.org>
Date: Mon Aug 20 11:34:52 2007 +0200
save/restore open contours
commit d246b573c3002222798d20598b010bba75f7f843
Author: Eugeniy Meshcheryakov <eugen at debian.org>
Date: Mon Aug 20 11:33:38 2007 +0200
detect open contours and remove duplicate points
-----------------------------------------------------------------------
Summary of changes:
gui/glyphgraphics.cxx | 17 ++++++++++++++---
gui/glyphgraphics.h | 2 +-
gui/glyphsmodel.cxx | 4 +++-
nongui/contour.h | 10 +++++++++-
nongui/fontdocumentreader.cxx | 4 ++++
nongui/fontdocumentwriter.cxx | 2 ++
scripts/conv.rb | 32 ++++++++++++++++++++++++++++----
7 files changed, 61 insertions(+), 10 deletions(-)
diff --git a/gui/glyphgraphics.cxx b/gui/glyphgraphics.cxx
index c4d52f0..c49b62d 100644
--- a/gui/glyphgraphics.cxx
+++ b/gui/glyphgraphics.cxx
@@ -77,7 +77,8 @@ void GlyphGraphics::paint(QPainter *painter, const QStyleOptionGraphicsItem *opt
// TODO add refs
if (v.canConvert<Contour>()) {
Contour c = v.value<Contour>();
- path.addPath(contourToPath(c));
+ if (!c.isOpen())
+ path.addPath(contourToPath(c));
}
}
@@ -85,9 +86,18 @@ void GlyphGraphics::paint(QPainter *painter, const QStyleOptionGraphicsItem *opt
painter->setPen(Qt::black);
painter->setBrush(Qt::NoBrush); // filling should be moved to other place
painter->drawPath(path);
+
+ // draw open contours
+ foreach (const QVariant &v, content) {
+ if (v.canConvert<Contour>()) {
+ Contour c = v.value<Contour>();
+ if (c.isOpen())
+ painter->drawPath(contourToPath(c, true));
+ }
+ }
}
-QPainterPath GlyphGraphics::contourToPath(const Contour &contour)
+QPainterPath GlyphGraphics::contourToPath(const Contour &contour, bool open)
{
QPainterPath path;
@@ -126,7 +136,8 @@ QPainterPath GlyphGraphics::contourToPath(const Contour &contour)
}
}
}
- path.closeSubpath(); // TODO open paths
+ if (!open)
+ path.closeSubpath(); // TODO open paths
return path;
}
diff --git a/gui/glyphgraphics.h b/gui/glyphgraphics.h
index 472da3a..1a6f5f0 100644
--- a/gui/glyphgraphics.h
+++ b/gui/glyphgraphics.h
@@ -46,7 +46,7 @@ private:
QList<QVariant> content;
QList<ControlPoint *> points;
public:
- static QPainterPath contourToPath(const Contour &contour);
+ static QPainterPath contourToPath(const Contour &contour, bool open = false);
};
#endif
diff --git a/gui/glyphsmodel.cxx b/gui/glyphsmodel.cxx
index b7c6f3e..6eec886 100644
--- a/gui/glyphsmodel.cxx
+++ b/gui/glyphsmodel.cxx
@@ -214,7 +214,9 @@ void GlyphsModel::drawContours(PathList *paths, const Glyph *glyph, int order, Q
foreach (const QVariant &v, glyph->content) {
if (v.canConvert<Contour>()) {
- glyphPath.path.addPath(GlyphGraphics::contourToPath(v.value<Contour>()));
+ Contour c = v.value<Contour>();
+ if (!c.isOpen())
+ glyphPath.path.addPath(GlyphGraphics::contourToPath(c));
}
else {
Q_ASSERT(v.canConvert<GlyphRef>());
diff --git a/nongui/contour.h b/nongui/contour.h
index cec5059..5875acf 100644
--- a/nongui/contour.h
+++ b/nongui/contour.h
@@ -23,7 +23,15 @@
/** Type reperesenting a contour in a glyph.
*/
-class Contour : public QList<GlyphPoint> {};
+class Contour : public QList<GlyphPoint>
+{
+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;
+};
Q_DECLARE_METATYPE(Contour)
diff --git a/nongui/fontdocumentreader.cxx b/nongui/fontdocumentreader.cxx
index 38ba975..10f35c8 100644
--- a/nongui/fontdocumentreader.cxx
+++ b/nongui/fontdocumentreader.cxx
@@ -287,6 +287,10 @@ void FontDocumentReader::readContour(Glyph *glyph)
Contour contour;
+ const QStringRef isOpen = attributes().value("open");
+ if (isOpen == "1")
+ contour.setOpen();
+
while (!atEnd()) {
readNext();
diff --git a/nongui/fontdocumentwriter.cxx b/nongui/fontdocumentwriter.cxx
index 615204c..a8d727c 100644
--- a/nongui/fontdocumentwriter.cxx
+++ b/nongui/fontdocumentwriter.cxx
@@ -136,6 +136,8 @@ bool FontDocumentWriter::writeGlyphContent(const QList<QVariant> &content)
if (i.canConvert<Contour>()) {
const Contour &contour = i.value<Contour>();
writeStartElement("contour");
+ if (contour.isOpen())
+ writeAttribute("open", "1");
foreach (const GlyphPoint &pt, contour) {
writeEmptyElement("pt");
writeAttribute("x", QString::number(pt.x()));
diff --git a/scripts/conv.rb b/scripts/conv.rb
index 5952cf3..0533f8c 100755
--- a/scripts/conv.rb
+++ b/scripts/conv.rb
@@ -300,6 +300,7 @@ def contour_to_xml(s)
curcnt = nil
lastpt = nil
last_in = false
+ firstpt = nil
lines = s.split("\n")
lines.each do |l|
@@ -307,15 +308,25 @@ def contour_to_xml(s)
if a[2] == 'm'
# new contour
if curcnt
+ open = true
+ if lastpt == firstpt and curcnt.size > 1
+ #closed contour
+ open = false
+ end
if last_in
newcnt = [curcnt[-1]]
curcnt[1..-2].each do |e| newcnt << e end
curcnt = newcnt
end
- contours << curcnt
+ if !open and curcnt[0] == curcnt[-1]
+ # remove duplicate points
+ curcnt = curcnt[0..-2]
+ end
+ contours << [curcnt, open]
end
curcnt = [[a[0], a[1], true]]
- lastpt = [[a[0], a[1], true]]
+ lastpt = [a[0], a[1], true]
+ firstpt = [a[0], a[1], true]
last_in = false
elsif a[2] == 'l'
# lineto
@@ -338,16 +349,29 @@ def contour_to_xml(s)
end
end
if curcnt
+ open = true
+ if lastpt == firstpt and curcnt.size > 1
+ #closed contour
+ open = false
+ end
if last_in
newcnt = [curcnt[-1]]
curcnt[1..-2].each do |e| newcnt << e end
curcnt = newcnt
end
- contours << curcnt
+ if !open and curcnt[0] == curcnt[-1]
+ # remove duplicate points
+ curcnt = curcnt[0..-2]
+ end
+
+ contours << [curcnt, open]
end
contours.each do |c|
cont = XML::Node.new("contour")
- c.each do |p|
+ if c[1] then
+ cont["open"] = "1"
+ end
+ c[0].each do |p|
cont << pt = XML::Node.new("pt")
pt["x"] = p[0]
pt["y"] = p[1]
--
Fondue Font Editor
More information about the fondue-commits
mailing list