29#include <glibmm/i18n.h>
30#include <glibmm/regex.h>
137 this->
requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG | SP_TEXT_CONTENT_MODIFIED_FLAG | SP_TEXT_LAYOUT_MODIFIED_FLAG);
143 this->
requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG | SP_TEXT_CONTENT_MODIFIED_FLAG | SP_TEXT_LAYOUT_MODIFIED_FLAG);
149 unsigned childflags = (flags & SP_OBJECT_MODIFIED_CASCADE);
150 if (flags & SP_OBJECT_MODIFIED_FLAG) {
151 childflags |= SP_OBJECT_PARENT_MODIFIED_FLAG;
155 std::vector<SPObject *> l;
162 if (childflags || (
child->uflags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_CHILD_MODIFIED_FLAG))) {
164 child->updateDisplay(ctx, childflags);
172 if (flags & ( SP_OBJECT_STYLE_MODIFIED_FLAG |
173 SP_OBJECT_CHILD_MODIFIED_FLAG |
174 SP_TEXT_LAYOUT_MODIFIED_FLAG ) )
182 double const ex = 0.5 * em;
204 for (
auto &v :
views) {
207 auto g = cast<Inkscape::DrawingGroup>(v.drawingitem.get());
219 guint cflags = (flags & SP_OBJECT_MODIFIED_CASCADE);
221 if (flags & SP_OBJECT_MODIFIED_FLAG) {
222 cflags |= SP_OBJECT_PARENT_MODIFIED_FLAG;
229 if (flags & ( SP_OBJECT_STYLE_MODIFIED_FLAG )) {
232 for (
auto &v :
views) {
235 auto g = cast<Inkscape::DrawingGroup>(v.drawingitem.get());
243 std::vector<SPObject *> l;
250 if (cflags || (
child->mflags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_CHILD_MODIFIED_FLAG))) {
251 child->emitModified(cflags);
258 if (flags & SP_OBJECT_WRITE_BUILD) {
265 std::vector<Inkscape::XML::Node *> l;
268 if (is<SPTitle>(&
child) || is<SPDesc>(&
child)) {
274 if (is<SPString>(&
child)) {
277 crepr =
child.updateRepr(xml_doc,
nullptr, flags);
285 for (
auto i=l.rbegin();i!=l.rend();++i) {
291 if (is<SPTitle>(&
child) || is<SPDesc>(&
child)) {
295 if (is<SPString>(&
child)) {
296 child.getRepr()->setContent(cast<SPString>(&
child)->string.c_str());
298 child.updateRepr(flags);
330 for (
auto &v :
views) {
332 auto g = cast<Inkscape::DrawingGroup>(v.drawingitem.get());
346 return _(
"Auto-wrapped text");
348 return _(
"Text in-a-shape");
366 char const *trunc =
"";
370 trunc = _(
" [truncated]");
374 ? g_strdup_printf(_(
"on path%s (%s, %s)"), trunc, n, xs.c_str())
375 : g_strdup_printf(_(
"%s (%s, %s)"), trunc, n, xs.c_str()) );
399 if (item_style && text && item_style->
shape_inside.set) {
420 if (prefs->
getBool(
"/tools/text/use_svg2",
true)) {
451 double const ex = xform.
descrim();
549 auto uncross = std::make_unique<Shape>();
550 uncross->ConvertToShape(&shape);
564 unsigned child_attrs_offset = 0;
572 auto text_object = cast<SPText>(
object);
573 auto tspan_object = cast<SPTSpan>(
object);
574 auto tref_object = cast<SPTRef>(
object);
575 auto textpath_object = cast<SPTextPath>(
object);
580 bool use_dxdyrotate =
true;
586 use_dxdyrotate =
false;
589 text_object->attributes.mergeInto(&optional_attrs, parent_optional_attrs, parent_attrs_offset, use_xy, use_dxdyrotate);
610 optional_attrs.
y.push_back(*y);
612 std::cerr <<
"SPText::_buildLayoutInput: No 'y' attribute value with horizontal 'inline-size'!" << std::endl;
618 optional_attrs.
x.push_back(*x);
620 std::cerr <<
"SPText::_buildLayoutInput: No 'x' attribute value with vertical 'inline-size'!" << std::endl;
626 if (text_object->attributes.getTextLength()->_set) {
635 else if (tspan_object) {
639 bool use_xy = !in_textpath &&
641 bool use_dxdyrotate =
true;
647 use_dxdyrotate =
false;
650 tspan_object->attributes.mergeInto(&optional_attrs, parent_optional_attrs, parent_attrs_offset, use_xy, use_dxdyrotate);
657 if (prev_object && cast<SPTSpan>(prev_object)) {
676 child_attrs_offset--;
680 else if (tref_object) {
681 tref_object->attributes.mergeInto(&optional_attrs, parent_optional_attrs, parent_attrs_offset,
true,
true);
684 else if (textpath_object) {
686 textpath_object->attributes.mergeInto(&optional_attrs, parent_optional_attrs, parent_attrs_offset,
false,
true);
687 optional_attrs.
x.clear();
688 optional_attrs.
y.clear();
692 optional_attrs = parent_optional_attrs;
693 child_attrs_offset = parent_attrs_offset;
697 for (
auto&
child:
object->children) {
698 auto str = cast<SPString>(&
child);
700 Glib::ustring
const &
string = str->string;
703 length +=
string.length();
715 auto result = std::make_unique<Shape>();
718 auto shape = href->getObject();
722 if (!shape->curve()) {
730 auto temp = std::make_unique<Path>();
731 temp->LoadPathVector(
curve->get_pathvector(), shape->getRelativeTransform(
this),
true);
733 auto margin = std::make_unique<Path>();
734 if (shape->style->shape_margin.set) {
741 auto livarot_shape = std::make_unique<Shape>();
742 margin->Fill(livarot_shape.get(), 0);
744 auto uncrossed = std::make_unique<Shape>();
745 uncrossed->ConvertToShape(livarot_shape.get());
748 auto shape_temp = std::make_unique<Shape>();
750 std::swap(
result, shape_temp);
752 result->Copy(uncrossed.get());
764 if (!shape->
curve()) {
773 double padding_amount = 0.0;
776 if (padding_amount < 1e-12) {
781 auto pathvector =
curve->get_pathvector();
784 auto temp_path = std::make_unique<Path>();
785 temp_path->LoadPathVector(pathvector, shape->
transform,
true);
787 auto const make_nice_shape = [](std::unique_ptr<Path>
const &contour) -> std::unique_ptr<Shape> {
788 auto temp = std::make_unique<Shape>();
789 contour->ConvertWithBackData(1.0);
790 contour->Fill(temp.get(), 0);
791 auto result = std::make_unique<Shape>();
792 result->ConvertToShape(temp.get());
797 auto outline = std::make_unique<Path>();
800 auto inclusion_shape = make_nice_shape(temp_path);
801 auto thickened_border = make_nice_shape(outline);
803 auto result = std::make_unique<Shape>();
807 return make_nice_shape(temp_path);
813 std::unique_ptr<Shape> exclusion_shape;
817 bool const has_exclusion = exclusion_shape && exclusion_shape->hasEdges();
819 std::vector<std::unique_ptr<Shape>>
result;
822 auto obj = href->getObject();
826 auto copy = std::make_unique<Shape>();
827 copy->Booleen(textarea_shape.get(), exclusion_shape.get(),
bool_op_diff);
828 textarea_shape = std::move(copy);
830 result.push_back(std::move(textarea_shape));
832 std::cerr << __FUNCTION__ <<
": Failed to get curve." << std::endl;
848 if (is<SPTSpan>(&
child)) {
849 auto tspan = cast<SPTSpan>(&
child);
850 x = tspan->attributes.getFirstXLength();
867 if (is<SPTSpan>(&
child)) {
868 auto tspan = cast<SPTSpan>(&
child);
869 y = tspan->attributes.getFirstYLength();
894 if (is<SPTextPath>(&
child)) {
897#if DEBUG_TEXTLAYOUT_DUMPASTEXT
904#if DEBUG_TEXTLAYOUT_DUMPASTEXT
910 if (is<SPTSpan>(&
child)) {
911 auto tspan = cast<SPTSpan>(&
child);
913 && tspan->attributes.singleXYCoordinates() ) {
916 tspan->attributes.setFirstXY(anchor_point);
960 return std::optional<Geom::Point>();
967 auto string = cast<SPString>(
object);
969 static Glib::RefPtr<Glib::Regex> r = Glib::Regex::create(
"\n+");
970 string->string = r->replace(string->string, 0,
" ", (Glib::Regex::MatchFlags)0);
971 string->getRepr()->setContent(string->string.c_str());
974 for (
auto child :
object->childList(
false)) {
979 auto tspan = cast<SPTSpan>(
object);
982 tspan->getNext() !=
nullptr &&
985 std::vector<SPObject *> children = tspan->childList(
false);
988 for (
auto it = children.rbegin(); it != children.rend(); ++it) {
989 auto string = cast<SPString>(*it);
991 string->string +=
' ';
992 string->getRepr()->setContent(string->string.c_str());
1011 if (is<SPTSpan>(
item))
1012 cast<SPTSpan>(
item)->attributes.transform(m, ex, ex, is_root);
1014 else if (is<SPText>(
item))
1015 cast<SPText>(
item)->attributes.transform(m, ex, ex, is_root);
1016 else if (is<SPTextPath>(
item))
1017 cast<SPTextPath>(
item)->attributes.transform(m, ex, ex, is_root);
1018 else if (is<SPTRef>(
item)) {
1019 cast<SPTRef>(
item)->attributes.transform(m, ex, ex, is_root);
1021 g_warning(
"element is not text");
1043 child.removeAttribute(
"x");
1044 child.removeAttribute(
"y");
1081 auto tspan = cast<SPTSpan>(
child);
1085 tspan->removeAttribute(
"sodipodi:role");
1086 tspan->updateRepr();
1092 auto last_child = tspan->lastChild();
1093 auto last_string = cast<SPString>(last_child);
1096 last_string->string +=
"\n";
1097 last_string->updateRepr();
1100 auto tspan_node = tspan->getRepr();
1101 auto xml_doc = tspan_node->document();
1102 tspan_node->appendChild(xml_doc->createTextNode(
"\n"));
1182 auto *shape = href->getObject();
1183 if (is<SPRect>(shape)) {
1185 g_return_val_if_fail(
item,
nullptr);
1186 assert(strncmp(
"svg:rect",
item->name(), 8) == 0);
1199 objects.push_back(
item);
1220 std::vector<SPItem *> ret;
1223 ret.push_back(href->getObject());
1225 }
else if (
auto textpath = cast<SPTextPath>(
firstChild())) {
1240 g_assert(layer !=
nullptr);
1242 auto text_object = cast<SPText>(layer->appendChildRepr(text_repr));
1243 g_assert(text_object !=
nullptr);
1250 p0 *= layer->i2doc_affine().inverse();
1251 p1 *= layer->i2doc_affine().inverse();
1258 text_object->style->inline_size.setDouble( inline_size );
1259 text_object->style->inline_size.set =
true;
1265 text_object->updateRepr();
1284 auto text_object = cast<SPText>(
parent->appendChildRepr(text_repr));
1285 g_assert(text_object !=
nullptr);
1301 if (defs_repr ==
nullptr) {
1308 defs_repr->
addChild(rect_repr,
nullptr);
1316 std::string value(
"url(#");
1360 std::vector<SVGLength> *attr_vector;
1361 bool update_x =
false;
1362 bool update_y =
false;
1379 default:
return false;
1385 if( (update_x || update_y) && style !=
nullptr && viewport !=
nullptr ) {
1386 double const w = viewport->
width();
1387 double const h = viewport->
height();
1388 double const em = style->
font_size.computed;
1389 double const ex = em * 0.5;
1390 for(
auto & it : *attr_vector) {
1392 it.update( em, ex,
w );
1394 it.update( em, ex, h );
1422 it.update( em, ex,
w );
1425 it.update( em, ex, h );
1428 it.update( em, ex,
w );
1431 it.update( em, ex, h );
1445 if (attr_vector.empty())
1448 Glib::ustring string;
1451 for (
auto it : attr_vector) {
1452 if (!
string.empty())
string +=
' ';
1453 string += it.write();
1534 output_list->clear();
1535 if (overlay_list ==
nullptr) {
1536 if (parent_list.size() > parent_offset)
1538 output_list->reserve(parent_list.size() - parent_offset);
1539 std::copy(parent_list.begin() + parent_offset, parent_list.end(), std::back_inserter(*output_list));
1542 output_list->reserve(std::max((
int)parent_list.size() - (
int)parent_offset, (
int)overlay_list->size()));
1543 unsigned overlay_offset = 0;
1544 while (parent_offset < parent_list.size() || overlay_offset < overlay_list->
size()) {
1546 if (overlay_offset < overlay_list->
size()) {
1547 this_item = &(*overlay_list)[overlay_offset];
1551 this_item = &parent_list[parent_offset];
1554 output_list->push_back(*this_item);
1573 if (attr_vector->size() <= start_index)
return;
1574 if (attr_vector->size() <= start_index + n)
1575 attr_vector->erase(attr_vector->begin() + start_index, attr_vector->end());
1577 attr_vector->erase(attr_vector->begin() + start_index, attr_vector->begin() + start_index + n);
1594 if (attr_vector->size() <= start_index)
return;
1597 attr_vector->insert(attr_vector->begin() + start_index, n, zero_length);
1599 double begin = start_index == 0 ? (*attr_vector)[start_index + n].
computed : (*attr_vector)[start_index - 1].computed;
1600 double diff = ((*attr_vector)[start_index + n].computed - begin) / n;
1601 for (
unsigned i = 0 ; i < n ; i++)
1602 (*attr_vector)[start_index + i] = begin + diff * i;
1619 second_vector->clear();
1620 if (first_vector->size() <=
index)
return;
1621 second_vector->resize(first_vector->size() -
index);
1622 std::copy(first_vector->begin() +
index, first_vector->end(), second_vector->begin());
1623 first_vector->resize(
index);
1625 while (!first_vector->empty() && (!first_vector->back()._set || first_vector->back().value == 0.0))
1626 first_vector->resize(first_vector->size() - 1);
1645 if (second_vector.empty())
1646 *dest_vector = first_vector;
1648 dest_vector->resize(second_index + second_vector.size());
1649 if (first_vector.size() < second_index) {
1650 std::copy(first_vector.begin(), first_vector.end(), dest_vector->begin());
1653 std::fill(dest_vector->begin() + first_vector.size(), dest_vector->begin() + second_index, zero_length);
1655 std::copy(first_vector.begin(), first_vector.begin() + second_index, dest_vector->begin());
1656 std::copy(second_vector.begin(), second_vector.end(), dest_vector->begin() + second_index);
1670 if (extend_zero_length && points_count < 1)
1672 for (
unsigned i = 0 ; i < points_count ; i++) {
1681 else if (point[
Geom::X] != 0.0 && extend_zero_length) {
1687 else if (point[
Geom::Y] != 0.0 && extend_zero_length) {
1693 it = it.computed * scale_x;
1695 it = it.computed * scale_y;
TODO: insert short description here.
TODO: insert short description here.
3x3 affine transformation matrix.
Lookup dictionary for attributes/properties.
std::shared_ptr< FontInstance > FaceFromStyle(SPStyle const *style)
Retrieve a FontInstance from a style object, first trying to use the font-specification,...
3x3 matrix representing an affine transformation.
Coord descrim() const
Calculate the descriminant.
Affine inverse() const
Compute the inverse matrix.
static CRect from_xywh(Coord x, Coord y, Coord w, Coord h)
Create rectangle from origin and dimensions.
C height() const
Get the vertical extent of the rectangle.
C width() const
Get the horizontal extent of the rectangle.
CPoint corner(unsigned i) const
Return the n-th corner of the rectangle.
Axis-aligned rectangle that can be empty.
Two-dimensional point that doubles as a vector.
Axis aligned, non-empty rectangle.
void setPickChildren(bool)
Set whether the group returns children from pick calls.
SVG drawing item for display.
virtual void setStyle(SPStyle const *style, SPStyle const *context_style=nullptr)
Process information related to the new style.
SPGroup * currentLayer() const
Returns current top layer.
Preference storage class.
bool getBool(Glib::ustring const &pref_path, bool def=false)
Retrieve a Boolean value.
static Preferences * get()
Access the singleton Preferences object.
int getInt(Glib::ustring const &pref_path, int def=0)
Retrieve an integer.
Storing of snapping preferences.
bool isTargetSnappable(Inkscape::SnapTargetType const target) const
void computeEffective(const double &line_height)
Calculate the effective ascent and descent including half "leading".
Holds a position within the glyph output of Layout.
Generates the layout for either wrapped or non-wrapped text and stores the result.
void clear()
Empties everything stored in this class and resets it to its original state, like when it was created...
LengthAdjust lengthAdjust
How do we meet textLength if specified: by letterspacing or by scaling horizontally.
Geom::OptRect bounds(Geom::Affine const &transform, bool with_stroke=false, int start=-1, int length=-1) const
Calculates the smallest rectangle completely enclosing all the glyphs.
bool inputTruncated() const
void validateIterator(iterator *it) const
Checks the validity of the given iterator over the current layout.
static const double LINE_HEIGHT_NORMAL
The CSS spec allows line-height:normal to be whatever the user agent thinks will look good.
void appendControlCode(TextControlCode code, SPObject *source, double width=0.0, double ascent=0.0, double descent=0.0)
Control codes are metadata in the text stream to signify items that occupy real space (unlike style c...
iterator sourceToIterator(SPObject *source) const
Returns an iterator pointing to the first character in the output which was created from the given so...
bool inputExists() const
Queries whether any calls have been made to appendText() or appendControlCode() since the object was ...
Glib::ustring dumpAsText() const
debug and unit test method.
std::optional< Geom::Point > baselineAnchorPoint() const
For left aligned text, the leftmost end of the baseline For rightmost text, the rightmost....
SPCurve convertToCurves(iterator const &from_glyph, iterator const &to_glyph) const
Convert the specified range of characters into their bezier outlines.
void show(DrawingGroup *in_arena, StyleAttachments &style_attachments, Geom::OptRect const &paintbox) const
Adds all the output glyphs to in_arena using the given paintbox.
void fitToPathAlign(SVGLength const &startOffset, Path const &path)
Moves all the glyphs in the structure so that the baseline of all the characters sits neatly along th...
gunichar characterAt(iterator const &it) const
Returns character pointed to by it.
Geom::Point chunkAnchorPoint(iterator const &it) const
This is that value to apply to the x,y attributes of tspan role=line elements, and hence it takes ali...
iterator end() const
Returns an iterator pointing just past the end of the last glyph, which is also just past the end of ...
void appendWrapShape(std::unique_ptr< Shape > shape, DisplayAlign display_align=DISPLAY_ALIGN_BEFORE)
Stores another shape inside which to flow the text.
enum Inkscape::Text::Layout::WrapMode wrap_mode
bool outputExists() const
Returns true if there are some glyphs in this object, ie whether computeFlow() has been called on a n...
void appendText(Glib::ustring const &text, SPStyle *style, SPObject *source, OptionalTextTagAttrs const *optional_attributes, unsigned optional_attributes_offset, Glib::ustring::const_iterator text_begin, Glib::ustring::const_iterator text_end)
adds a new piece of text to the end of the current list of text to be processed.
FontMetrics strut
The strut is the minimum value used in calculating line height.
SVGLength textLength
Gives the length target of this layout, as given by textLength attribute.
void print(SPPrintContext *ctx, Geom::OptRect const &pbox, Geom::OptRect const &dbox, Geom::OptRect const &bbox, Geom::Affine const &ctm) const
Sends all the glyphs to the given print context.
bool calculateFlow()
Takes all the stuff you set with the members above here and creates a load of glyphs for use with the...
LengthAdjust
lengthAdjust values
@ LENGTHADJUST_SPACINGANDGLYPHS
iterator begin() const
Returns an iterator pointing at the first glyph of the flowed output.
static FontFactory & get(Args &&... args)
Glib::ustring string(Unit const *u) const
Return a printable string of the value in the specified unit.
Interface for refcounted XML nodes.
virtual void addChild(Node *child, Node *after)=0
Insert another node as a child of this node.
virtual void appendChild(Node *child)=0
Append a node as the last child of this node.
double getAttributeDouble(Util::const_char_ptr key, double default_value=0.0) const
void setAttributeOrRemoveIfEmpty(Inkscape::Util::const_char_ptr key, Inkscape::Util::const_char_ptr value)
Change an attribute of this node.
void setAttribute(Util::const_char_ptr key, Util::const_char_ptr value)
Change an attribute of this node.
virtual char const * attribute(char const *key) const =0
Get the string representation of a node's attribute.
void removeAttribute(Inkscape::Util::const_char_ptr key)
Remove an attribute of this node.
bool setAttributeSvgDouble(Util::const_char_ptr key, double val)
For attributes where an exponent is allowed.
virtual Node * root()=0
Get the root node of this node's document.
Wrapper around a Geom::PathVector object.
To do: update description of desktop.
SPDocument * getDocument() const
Geom::Affine const & dt2doc() const
Inkscape::LayerManager & layerManager()
Typed SVG document implementation.
Geom::Point getDimensions() const
Inkscape::XML::Document * getReprDoc()
Our Inkscape::XML::Document.
Base class for visual SVG elements.
Geom::Affine i2dt_affine() const
Returns the transformation from item to desktop coords.
void update(SPCtx *ctx, unsigned int flags) override
Inkscape::XML::Node * write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, unsigned int flags) override
void set(SPAttr key, char const *value) override
void adjust_gradient(Geom::Affine const &postmul, bool set=false)
void adjust_stroke_width_recursive(double ex)
Recursively scale stroke width in item and its children by expansion.
Geom::OptRect desktopVisualBounds() const
Get item's visual bbox in desktop coordinate system.
void adjust_pattern(Geom::Affine const &postmul, bool set=false, PaintServerTransform=TRANSFORM_BOTH)
Geom::OptRect geometricBounds(Geom::Affine const &transform=Geom::identity()) const
Get item's geometric bounding box in this item's coordinate system.
Geom::Affine i2doc_affine() const
Returns the accumulated transformation of the item and all its ancestors, including root's viewport.
void build(SPDocument *document, Inkscape::XML::Node *repr) override
std::vector< SPItemView > views
SPObject is an abstract base class of all of the document nodes at the SVG document level.
Inkscape::XML::Node * repr
void removeAttribute(char const *key)
std::vector< SPObject * > childList(bool add_ref, Action action=ActionGeneral)
Retrieves the children as a std vector object, optionally ref'ing the children in the process,...
virtual void remove_child(Inkscape::XML::Node *child)
void changeCSS(SPCSSAttr *css, char const *attr)
SPStyle * style
Represents the style properties, whether from presentation attributes, the style attribute,...
SPObject * getPrev()
Returns previous object in sibling list or NULL.
Inkscape::XML::Node * updateRepr(unsigned int flags=SP_OBJECT_WRITE_EXT)
Updates the object's repr based on the object's state.
void readAttr(char const *key)
Read value of key attribute from XML node into object.
Inkscape::XML::Node * getRepr()
Returns the XML representation of tree.
virtual void child_added(Inkscape::XML::Node *child, Inkscape::XML::Node *ref)
virtual void getLinked(std::vector< SPObject * > &objects, LinkedObjectNature direction=LinkedObjectNature::ANY) const
Get objects which are linked to this object as either a source or a target.
void requestDisplayUpdate(unsigned int flags)
Queues an deferred update of this object's display.
Base class for shapes, including <path> element.
SPCurve const * curve() const
Return a borrowed pointer to the curve (if any exists) or NULL if there is no curve.
T< SPAttr::SHAPE_PADDING, SPILength > shape_padding
T< SPAttr::LINE_HEIGHT, SPILengthOrNormal > line_height
Line height (css2 10.8.1)
T< SPAttr::LETTER_SPACING, SPILengthOrNormal > letter_spacing
letter spacing (css2 16.4)
T< SPAttr::FONT_FAMILY, SPIString > font_family
Font family.
T< SPAttr::DIRECTION, SPIEnum< SPCSSDirection > > direction
text direction (svg1.1)
T< SPAttr::WHITE_SPACE, SPIEnum< SPWhiteSpace > > white_space
white space (svg2)
T< SPAttr::WORD_SPACING, SPILengthOrNormal > word_spacing
word spacing (also css2 16.4)
T< SPAttr::INLINE_SIZE, SPILength > inline_size
T< SPAttr::TEXT_ANCHOR, SPIEnum< SPTextAnchor > > text_anchor
Anchor of the text (svg1.1 10.9.1)
T< SPAttr::DISPLAY, SPIEnum< SPCSSDisplay > > display
display
T< SPAttr::SHAPE_INSIDE, SPIShapes > shape_inside
SVG2 Text Wrapping.
T< SPAttr::WRITING_MODE, SPIEnum< SPCSSWritingMode > > writing_mode
Writing mode (svg1.1 10.7.2, CSS Writing Modes 3)
T< SPAttr::SHAPE_SUBTRACT, SPIShapes > shape_subtract
T< SPAttr::FONT_SIZE, SPIFontSize > font_size
Size of the font.
void getLinked(std::vector< SPObject * > &objects, LinkedObjectNature direction=LinkedObjectNature::ANY) const override
Get objects which are linked to this object as either a source or a target.
bool has_inline_size() const
void child_added(Inkscape::XML::Node *child, Inkscape::XML::Node *ref) override
std::unique_ptr< Shape > getInclusionShape(SPShape *shape) const
Add a single inclusion shape with padding.
void newline_to_sodipodi()
Convert new lines in 'inline-size' text to tspans with sodipodi:role="tspan".
void sodipodi_to_newline()
Convert tspans with sodipodi:role="tspans" to ' '.
void print(SPPrintContext *ctx) override
SVGLength * _getFirstYLength()
SPItem * get_first_shape_dependency()
Get the first shape reference which affects the position and layout of this text item.
void build(SPDocument *doc, Inkscape::XML::Node *repr) override
Inkscape::XML::Node * write(Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, unsigned int flags) override
std::unique_ptr< Shape > getExclusionShape() const
Union all exclusion shapes.
static void _adjustCoordsRecursive(SPItem *item, Geom::Affine const &m, double ex, bool is_root=true)
when the object is transformed it's nicer to change the font size and coordinates when we can,...
void _buildLayoutInit()
Initializes layout from <text> (i.e.
std::optional< Geom::Point > getBaselinePoint() const
Get the position of the baseline point for this text object.
SPCurve getNormalizedBpath() const
Converts the text object to its component curves.
void _clearFlow(Inkscape::DrawingGroup *in_arena)
discards the drawing objects representing this text.
void set(SPAttr key, const char *value) override
bool has_shape_inside() const
std::unordered_map< unsigned, Inkscape::Text::StyleAttachments > view_style_attachments
void update(SPCtx *ctx, unsigned int flags) override
std::vector< std::unique_ptr< Shape > > makeEffectiveShapes() const
Compute the final effective shapes: All inclusion shapes shrunk by the padding, from which we subtrac...
static void _adjustFontsizeRecursive(SPItem *item, double ex, bool is_root=true)
Inkscape::DrawingItem * show(Inkscape::Drawing &drawing, unsigned int key, unsigned int flags) override
void remove_child(Inkscape::XML::Node *child) override
void show_shape_inside()
This two functions are useful because layout calculations need text visible for example Calculating a...
Geom::Affine set_transform(Geom::Affine const &transform) override
Geom::OptRect get_frame()
const char * displayName() const override
The item's type name as a translated human string.
Geom::OptRect bbox(Geom::Affine const &transform, SPItem::BBoxType type) const override
void rebuildLayout()
Completely recalculates the layout.
SVGLength * _getFirstXLength()
Find first x/y values which may be in a descendent element.
Inkscape::Text::Layout layout
bool is_horizontal() const
void modified(unsigned int flags) override
void snappoints(std::vector< Inkscape::SnapCandidatePoint > &p, Inkscape::SnapPreferences const *snapprefs) const override
const char * typeName() const override
The item's type name, not node tag name.
TextTagAttributes attributes
bool _optimizeTextpathText
Inkscape::XML::Node * get_first_rectangle()
void hide(unsigned int key) override
void remove_svg11_fallback()
Remove 'x' and 'y' values on children (lines) or they will be interpreted as absolute positions when ...
unsigned _buildLayoutInput(SPObject *object, Inkscape::Text::Layout::OptionalTextTagAttrs const &parent_optional_attrs, unsigned parent_attrs_offset, bool in_textpath)
Recursively walks the xml tree adding tags and their contents.
const std::vector< SPItem * > get_all_shape_dependencies() const
char * description() const override
void readOrUnset(char const *str, Unit u=NONE, float v=0, float c=0)
A class to store/manipulate directed graphs.
int AddEdge(int st, int en)
int AddPoint(const Geom::Point x)
void split(unsigned index, TextTagAttributes *second)
Divides the stored attributes into two, at the given index.
static void insertSingleAttribute(std::vector< SVGLength > *attr_vector, unsigned start_index, unsigned n, bool is_xy)
Does the work for insert().
static void writeSingleAttributeLength(Inkscape::XML::Node *node, gchar const *key, const SVGLength &length)
Writes a single length value to node.
static void splitSingleAttribute(std::vector< SVGLength > *first_vector, unsigned index, std::vector< SVGLength > *second_vector, bool trimZeros)
Does the work for split().
Geom::Point firstXY() const
Returns the first coordinates in the x and y vectors.
void mergeInto(Inkscape::Text::Layout::OptionalTextTagAttrs *output, Inkscape::Text::Layout::OptionalTextTagAttrs const &parent_attrs, unsigned parent_attrs_offset, bool copy_xy, bool copy_dxdyrotate) const
Implements the rules for overlaying the contents of the class (treated as the child object) on top of...
SVGLength * getTextLength()
SVGLength * getFirstXLength()
Gets first value in the x vector as an SVGLength.
void setRotate(unsigned index, double angle)
Sets rotate vector at the given index.
bool readSingleAttribute(SPAttr key, gchar const *value, SPStyle const *style, Geom::Rect const *viewport)
Process the parameters from the set() function of SPObject.
bool singleXYCoordinates() const
For tspan role=line elements we should not use the set x,y coordinates since that would overrule the ...
double getDx(unsigned index)
Gets current value of dx vector at index.
SVGLength * getFirstYLength()
Gets first value in the y vector as an SVGLength.
void addToDy(unsigned index, double delta)
Adds the given value to the dy vector at the given index.
void addToDxDy(unsigned index, Geom::Point const &adjust)
Adds the given values to the dx and dy vectors at the given index.
void addToRotate(unsigned index, double delta)
Adds the given value to the rotate vector at the given index.
void setFirstXY(Geom::Point &point)
Sets the first coordinates in the x and y vectors.
void transform(Geom::Affine const &matrix, double scale_x, double scale_y, bool extend_zero_length=false)
Applies the given transformation to the stored coordinates.
void erase(unsigned start_index, unsigned n)
Deletes all the values from all the vectors beginning at start_index and extending for n fields.
static void mergeSingleAttribute(std::vector< SVGLength > *output_list, std::vector< SVGLength > const &parent_list, unsigned parent_offset, std::vector< SVGLength > const *overlay_list=nullptr)
Does mergeInto() for one member of attributes.
bool anyAttributesSet() const
Returns false if all of the vectors are zero length.
static void writeSingleAttributeVector(Inkscape::XML::Node *node, gchar const *key, std::vector< SVGLength > const &attr_vector)
Does the reverse of readSingleAttribute(), converting a vector<> to its SVG string representation and...
void writeTo(Inkscape::XML::Node *node) const
Write out all the contents of attributes to the given node.
Inkscape::Text::Layout::OptionalTextTagAttrs attributes
This holds the actual values.
void insert(unsigned start_index, unsigned n)
Inserts n new values in all the stored vectors at start_index.
void addToDx(unsigned index, double delta)
Adds the given value to the dx vector at the given index.
double getRotate(unsigned index)
Gets current value of rotate vector at index.
void update(double em, double ex, double w, double h)
Update relative values.
static void joinSingleAttribute(std::vector< SVGLength > *dest_vector, std::vector< SVGLength > const &first_vector, std::vector< SVGLength > const &second_vector, unsigned second_index)
Does the work for join().
double getDy(unsigned index)
Gets current value of dy vector at index.
static void eraseSingleAttribute(std::vector< SVGLength > *attr_vector, unsigned start_index, unsigned n)
Does the work for erase().
void join(TextTagAttributes const &first, TextTagAttributes const &second, unsigned second_index)
Overwrites all the attributes contained in this object with the given parameters by putting first at ...
std::shared_ptr< Css const > css
void sp_desktop_apply_style_tool(SPDesktop *desktop, Inkscape::XML::Node *repr, Glib::ustring const &tool_path, bool with_text)
Apply the desktop's current style or the tool style to repr.
Editable view implementation.
static char const *const parent
Group belonging to an SVG drawing element.
TODO: insert short description here.
The data describing a single loaded font.
Inkscape::XML::Node * node
double mod360(double const x)
Returns x wrapped around to between 0 and less than 360, or 0 if x isn't finite.
TODO: insert short description here.
bool are_near(Affine const &a1, Affine const &a2, Coord eps=EPSILON)
static R & anchor(R &r)
Increments the reference count of a anchored object.
static R & release(R &r)
Decrements the reference count of a anchored object.
@ SNAPTARGET_TEXT_BASELINE
static cairo_user_data_key_t key
void flatten(Geom::PathVector &pathv, FillRule fill_rule)
Singleton class to access the preferences file in a convenient way.
char * xml_quote_strdup(char const *src)
TODO: insert short description here.
void uncross(std::list< Point > &loop)
void sp_repr_css_set(Node *repr, SPCSSAttr *css, gchar const *attr)
Sets an attribute (e.g.
void sp_repr_css_attr_unref(SPCSSAttr *css)
Unreferences an SPCSSAttr (will be garbage collected if no references remain).
SPCSSAttr * sp_repr_css_attr(Node const *repr, gchar const *attr)
Creates a new SPCSSAttr with one attribute (i.e.
void sp_repr_css_unset_property(SPCSSAttr *css, gchar const *name)
Set a style property to "inkscape:unset".
void sp_repr_css_set_property(SPCSSAttr *css, gchar const *name, gchar const *value)
Set a style property to a new value (e.g.
bool sp_repr_is_meta_element(const Inkscape::XML::Node *node)
Determine if the node is a 'title', 'desc' or 'metadata' element.
Inkscape::XML::Node const * sp_repr_lookup_name(Inkscape::XML::Node const *repr, gchar const *name, gint maxdepth)
Some utility classes to store various kinds of snap candidates.
TODO: insert short description here.
SPObject * sp_object_unref(SPObject *object, SPObject *owner)
Decrease reference count of object, with possible debugging and finalization.
SPObject * sp_object_ref(SPObject *object, SPObject *owner)
Increase reference count of object, with possible debugging.
SPItem * create_text_with_rectangle(SPDesktop *desktop, Geom::Point p0, Geom::Point p1)
SPItem * create_text_with_inline_size(SPDesktop *desktop, Geom::Point p0, Geom::Point p1)
void remove_newlines_recursive(SPObject *object, bool is_svg2)
TODO: insert short description here.
bool SP_IS_TEXT_TEXTPATH(SPObject const *obj)
SPItem * sp_textpath_get_path_item(SPTextPath const *tp)
SVG <tref> implementation, see sp-tref.cpp.
TODO: insert short description here.
@ SP_TSPAN_ROLE_UNSPECIFIED
The optional attributes which can be applied to a SVG text or related tag.
std::vector< SVGLength > y
std::vector< SVGLength > rotate
std::vector< SVGLength > x
std::vector< SVGLength > dy
std::vector< SVGLength > dx
LengthAdjust lengthAdjust
Interface for XML documents.
virtual Node * createTextNode(char const *content)=0
virtual Node * createElement(char const *name)=0
Contains transformations to document/viewport and the viewport size.
Geom::Rect viewport
Viewport size.
@ SP_CSS_TEXT_ANCHOR_MIDDLE
@ SP_CSS_TEXT_ANCHOR_START
@ SP_CSS_WRITING_MODE_LR_TB
@ SP_CSS_WRITING_MODE_RL_TB
@ SP_CSS_WHITE_SPACE_PRELINE
@ SP_CSS_WHITE_SPACE_PREWRAP
static const unsigned SP_STYLE_FLAG_IFSET(1<< 0)
SPCSSAttr * sp_css_attr_from_style(SPStyle const *const style, guint const flags)
gchar const * sp_style_get_css_unit_string(int unit)
std::string sp_svg_transform_write(Geom::Affine const &transform)
std::vector< SVGLength > sp_svg_length_list_read(gchar const *str)
double sp_svg_read_percentage(char const *str, double def)
Inkscape::Text::Layout::iterator sp_te_insert_line(SPItem *item, Inkscape::Text::Layout::iterator &position)
inserts a new line break at the given position in a text or flowtext object.
Inkscape::Text::Layout const * te_get_layout(SPItem const *item)
bool sp_te_delete(SPItem *item, Inkscape::Text::Layout::iterator const &start, Inkscape::Text::Layout::iterator const &end, iterator_pair &iter_pair)
std::pair< Inkscape::Text::Layout::iterator, Inkscape::Text::Layout::iterator > iterator_pair