From c7205e6390eae17c8ddc684f8a5600c15f206fe4 Mon Sep 17 00:00:00 2001 From: Diederik van Lierop Date: Sat, 5 Dec 2009 22:53:52 +0100 Subject: Text alignment is now taken into account when snapping a text object Fixed bugs: - https://launchpad.net/bugs/412746 (bzr r8867) --- src/sp-text.cpp | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) (limited to 'src/sp-text.cpp') diff --git a/src/sp-text.cpp b/src/sp-text.cpp index 0d3fd791b..87c67c646 100644 --- a/src/sp-text.cpp +++ b/src/sp-text.cpp @@ -430,11 +430,32 @@ sp_text_description(SPItem *item) static void sp_text_snappoints(SPItem const *item, bool const target, SnapPointsWithType &p, Inkscape::SnapPreferences const */*snapprefs*/) { - // the baseline anchor of the first char + // Choose a point on the baseline for snapping from or to, with the horizontal position + // of this point depending on the text alignment (left vs. right) Inkscape::Text::Layout const *layout = te_get_layout((SPItem *) item); if(layout != NULL) { int type = target ? int(Inkscape::SNAPTARGET_TEXT_BASELINE) : int(Inkscape::SNAPSOURCE_TEXT_BASELINE); - p.push_back(std::make_pair(layout->characterAnchorPoint(layout->begin()) * sp_item_i2d_affine(item), type)); + + Inkscape::Text::Layout::iterator pos = layout->begin(); + Inkscape::Text::Layout::Alignment text_alignment = layout->paragraphAlignment(pos); + + Geom::Point left_pt = layout->characterAnchorPoint(pos) * sp_item_i2d_affine(item); + pos.thisEndOfLine(); + Geom::Point right_pt = layout->characterAnchorPoint(pos) * sp_item_i2d_affine(item); + Geom::Point mid_pt = (left_pt + right_pt)/2; + + switch (text_alignment) { + case Inkscape::Text::Layout::LEFT: + case Inkscape::Text::Layout::FULL: + p.push_back(std::make_pair(left_pt, type)); + break; + case Inkscape::Text::Layout::CENTER: + p.push_back(std::make_pair(mid_pt, type)); + break; + default: //RIGHT + p.push_back(std::make_pair(right_pt, type)); + break; + } } } -- cgit v1.2.3 From da49b977d3a7e002c88780c24d9c4020cbe80b0e Mon Sep 17 00:00:00 2001 From: Diederik van Lierop Date: Sun, 13 Dec 2009 14:00:22 +0100 Subject: Position of baseline anchor is now dependent of the text alignment Fixed bugs: - https://launchpad.net/bugs/168329 (bzr r8887) --- src/sp-text.cpp | 29 ++++++----------------------- 1 file changed, 6 insertions(+), 23 deletions(-) (limited to 'src/sp-text.cpp') diff --git a/src/sp-text.cpp b/src/sp-text.cpp index 87c67c646..423922b80 100644 --- a/src/sp-text.cpp +++ b/src/sp-text.cpp @@ -431,30 +431,13 @@ sp_text_description(SPItem *item) static void sp_text_snappoints(SPItem const *item, bool const target, SnapPointsWithType &p, Inkscape::SnapPreferences const */*snapprefs*/) { // Choose a point on the baseline for snapping from or to, with the horizontal position - // of this point depending on the text alignment (left vs. right) + // of this point depending on the text alignment (left vs. right) Inkscape::Text::Layout const *layout = te_get_layout((SPItem *) item); - if(layout != NULL) { - int type = target ? int(Inkscape::SNAPTARGET_TEXT_BASELINE) : int(Inkscape::SNAPSOURCE_TEXT_BASELINE); - - Inkscape::Text::Layout::iterator pos = layout->begin(); - Inkscape::Text::Layout::Alignment text_alignment = layout->paragraphAlignment(pos); - - Geom::Point left_pt = layout->characterAnchorPoint(pos) * sp_item_i2d_affine(item); - pos.thisEndOfLine(); - Geom::Point right_pt = layout->characterAnchorPoint(pos) * sp_item_i2d_affine(item); - Geom::Point mid_pt = (left_pt + right_pt)/2; - - switch (text_alignment) { - case Inkscape::Text::Layout::LEFT: - case Inkscape::Text::Layout::FULL: - p.push_back(std::make_pair(left_pt, type)); - break; - case Inkscape::Text::Layout::CENTER: - p.push_back(std::make_pair(mid_pt, type)); - break; - default: //RIGHT - p.push_back(std::make_pair(right_pt, type)); - break; + if (layout != NULL && layout->outputExists()) { + boost::optional pt = layout->baselineAnchorPoint(); + if (pt) { + int type = target ? int(Inkscape::SNAPTARGET_TEXT_BASELINE) : int(Inkscape::SNAPSOURCE_TEXT_BASELINE); + p.push_back(std::make_pair((*pt) * sp_item_i2d_affine(item), type)); } } } -- cgit v1.2.3 From 4cc7eb64107fc32a7c364545acc635e504736cf6 Mon Sep 17 00:00:00 2001 From: buliabyak <> Date: Mon, 21 Dec 2009 01:23:37 -0400 Subject: utilities and UI support for identifying truncated flowtext and text-on-path (bzr r8898) --- src/sp-text.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'src/sp-text.cpp') diff --git a/src/sp-text.cpp b/src/sp-text.cpp index 423922b80..b45f8cbb6 100644 --- a/src/sp-text.cpp +++ b/src/sp-text.cpp @@ -421,9 +421,15 @@ sp_text_description(SPItem *item) GString *xs = SP_PX_TO_METRIC_STRING(style->font_size.computed, sp_desktop_namedview(SP_ACTIVE_DESKTOP)->getDefaultMetric()); + char *trunc = ""; + Inkscape::Text::Layout const *layout = te_get_layout((SPItem *) item); + if (layout && layout->inputTruncated()) { + trunc = _(" [truncated]"); + } + char *ret = ( SP_IS_TEXT_TEXTPATH(item) - ? g_strdup_printf(_("Text on path (%s, %s)"), n, xs->str) - : g_strdup_printf(_("Text (%s, %s)"), n, xs->str) ); + ? g_strdup_printf(_("Text on path%s (%s, %s)"), trunc, n, xs->str) + : g_strdup_printf(_("Text%s (%s, %s)"), trunc, n, xs->str) ); g_free(n); return ret; } -- cgit v1.2.3