74
74
static NRArenaItem *sp_text_show (SPItem *item, NRArena *arena, unsigned key, unsigned flags);
75
75
static void sp_text_hide (SPItem *item, unsigned key);
76
76
static char *sp_text_description (SPItem *item);
77
static void sp_text_snappoints(SPItem const *item, bool const target, SnapPointsWithType &p, Inkscape::SnapPreferences const *snapprefs);
77
static void sp_text_snappoints(SPItem const *item, std::vector<Inkscape::SnapCandidatePoint> &p, Inkscape::SnapPreferences const *snapprefs);
78
78
static Geom::Matrix sp_text_set_transform(SPItem *item, Geom::Matrix const &xform);
79
79
static void sp_text_print (SPItem *item, SPPrintContext *gpc);
422
422
GString *xs = SP_PX_TO_METRIC_STRING(style->font_size.computed, sp_desktop_namedview(SP_ACTIVE_DESKTOP)->getDefaultMetric());
424
char const *trunc = "";
425
Inkscape::Text::Layout const *layout = te_get_layout((SPItem *) item);
426
if (layout && layout->inputTruncated()) {
427
trunc = _(" [truncated]");
424
430
char *ret = ( SP_IS_TEXT_TEXTPATH(item)
425
? g_strdup_printf(_("<b>Text on path</b> (%s, %s)"), n, xs->str)
426
: g_strdup_printf(_("<b>Text</b> (%s, %s)"), n, xs->str) );
431
? g_strdup_printf(_("<b>Text on path</b>%s (%s, %s)"), trunc, n, xs->str)
432
: g_strdup_printf(_("<b>Text</b>%s (%s, %s)"), trunc, n, xs->str) );
431
static void sp_text_snappoints(SPItem const *item, bool const target, SnapPointsWithType &p, Inkscape::SnapPreferences const */*snapprefs*/)
437
static void sp_text_snappoints(SPItem const *item, std::vector<Inkscape::SnapCandidatePoint> &p, Inkscape::SnapPreferences const */*snapprefs*/)
433
// the baseline anchor of the first char
439
// Choose a point on the baseline for snapping from or to, with the horizontal position
440
// of this point depending on the text alignment (left vs. right)
434
441
Inkscape::Text::Layout const *layout = te_get_layout((SPItem *) item);
436
int type = target ? int(Inkscape::SNAPTARGET_TEXT_BASELINE) : int(Inkscape::SNAPSOURCE_TEXT_BASELINE);
437
p.push_back(std::make_pair(layout->characterAnchorPoint(layout->begin()) * sp_item_i2d_affine(item), type));
442
if (layout != NULL && layout->outputExists()) {
443
boost::optional<Geom::Point> pt = layout->baselineAnchorPoint();
445
p.push_back(Inkscape::SnapCandidatePoint((*pt) * sp_item_i2d_affine(item), Inkscape::SNAPSOURCE_TEXT_BASELINE, Inkscape::SNAPTARGET_TEXT_BASELINE));
520
529
else if (SP_IS_TSPAN(root)) {
521
530
SPTSpan *tspan = SP_TSPAN(root);
531
// x, y attributes are stripped from some tspans marked with role="line" as we do our own line layout.
532
// This should be checked carefully, as it can undo line layout in imported SVG files.
522
533
bool use_xy = !in_textpath && (tspan->role == SP_TSPAN_ROLE_UNSPECIFIED || !tspan->attributes.singleXYCoordinates());
523
534
tspan->attributes.mergeInto(&optional_attrs, parent_optional_attrs, parent_attrs_offset, use_xy, true);
917
928
*it = it->computed * scale_y;
931
double TextTagAttributes::getDx(unsigned index)
933
if( attributes.dx.size() == 0 ) {
936
if( index < attributes.dx.size() ) {
937
return attributes.dx[index].computed;
939
return 0.0; // attributes.dx.back().computed;
944
double TextTagAttributes::getDy(unsigned index)
946
if( attributes.dy.size() == 0 ) {
949
if( index < attributes.dy.size() ) {
950
return attributes.dy[index].computed;
952
return 0.0; // attributes.dy.back().computed;
957
void TextTagAttributes::addToDx(unsigned index, double delta)
959
SVGLength zero_length;
962
if (attributes.dx.size() < index + 1) attributes.dx.resize(index + 1, zero_length);
963
attributes.dx[index] = attributes.dx[index].computed + delta;
966
void TextTagAttributes::addToDy(unsigned index, double delta)
968
SVGLength zero_length;
971
if (attributes.dy.size() < index + 1) attributes.dy.resize(index + 1, zero_length);
972
attributes.dy[index] = attributes.dy[index].computed + delta;
920
975
void TextTagAttributes::addToDxDy(unsigned index, Geom::Point const &adjust)
922
977
SVGLength zero_length;
990
double TextTagAttributes::getRotate(unsigned index)
992
if( attributes.rotate.size() == 0 ) {
995
if( index < attributes.rotate.size() ) {
996
return attributes.rotate[index].computed;
998
return attributes.rotate.back().computed;
935
1003
void TextTagAttributes::addToRotate(unsigned index, double delta)
937
1005
SVGLength zero_length;
1018
void TextTagAttributes::setRotate(unsigned index, double angle)
1020
SVGLength zero_length;
1023
if (attributes.rotate.size() < index + 2) {
1024
if (attributes.rotate.empty())
1025
attributes.rotate.resize(index + 2, zero_length);
1027
attributes.rotate.resize(index + 2, attributes.rotate.back());
1029
attributes.rotate[index] = mod360(angle);
951
1034
Local Variables: