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

Eugeniy Meshcheryakov eugen at debian.org
Sun Nov 9 21:03:30 UTC 2008


The following commit has been merged in the master branch:
commit 33c9a840c9ebf61c1df9c9a5e38f747150673f92
Author: Eugeniy Meshcheryakov <eugen at debian.org>
Date:   Fri Oct 10 16:03:25 2008 +0300

    make it possible  to join contours (buggy)

diff --git a/gui/glyphcell.cxx b/gui/glyphcell.cxx
index 7b0f6d9..ab20412 100644
--- a/gui/glyphcell.cxx
+++ b/gui/glyphcell.cxx
@@ -259,10 +259,51 @@ void GlyphCell::mousePressEvent(QMouseEvent *event)
 						}
 					}
 				}
+				else {
+					// Points belong to different contours...
+					// Maybe user wants to join contours?
+					// First check if both contours are open (or are one-point contours)
+					GlyphContour *contour1 = pt->contour();
+					GlyphContour *contour2 = oldPt->contour();
+					Q_ASSERT(contour1 && contour2);
+
+					int nPoints1 = contour1->points().size();
+					int nPoints2 = contour2->points().size();
+					Q_ASSERT(nPoints1 && nPoints2);
+
+					if (((nPoints1 == 1) || contour1->isOpen()) &&
+							((nPoints2 == 1) || contour2->isOpen())) {
+						// They are both open, or look so...
+						// Check if selected points are terminal points...
+						int num1 = pt->pointNumber();
+						int num2 = oldPt->pointNumber();
+						if (((num1 == 0) || (num1 == nPoints1 - 1)) &&
+									((num2 == 1) || (num2 = nPoints2 - 1))) {
+							// ok, they are terminal. Try to join the contours...
+							GlyphContour *newContour = new GlyphContour(true);
+							// TODO make this a separate function and optimize
+							GlyphPointList points = contour2->points();
+							qDebug() << num1 << num2;
+							while (!points.isEmpty())
+								newContour->appendPoint(num2 ? points.takeFirst() : points.takeLast());
+							points = contour1->points();
+							while (!points.isEmpty())
+								newContour->appendPoint(num1 ? points.takeLast() : points.takeFirst());
+							// Now remove the old contours ...
+							m_glyph->removeContour(contour1);
+							m_glyph->removeContour(contour2);
+							// ... and insert the new contour instead
+							m_glyph->appendContour(newContour);
+
+							pt = 0; // it belongs to a deleted contour
+						}
+					}
+				}
 			}
-			// in any case select the point user clicked on
+			// in any case select the point user clicked on, if it still exists
 			scene()->clearSelection();
-			pt->setSelected(true);
+			if (pt)
+				pt->setSelected(true);
 		}
 		else {
 			// User clicked on empty space

-- 
Fondue Font Editor



More information about the fondue-commits mailing list