|
|
Donner 0.8.0-pre
Embeddable browser-grade SVG2 engine
|
DOM object for a "<text>" element. More...
#include "donner/svg/SVGTextElement.h"
Public Member Functions | |
| std::vector< Path > | convertToPath () const |
| Convert this text element to positioned glyph outlines, one donner::Path per glyph. | |
| Box2d | inkBoundingBox () const |
| Return the tight bounding box of the actual rendered glyphs (ink extents). | |
| Box2d | objectBoundingBox () const |
| Return the object bounding box as defined by SVG2. | |
| Public Member Functions inherited from donner::svg::SVGTextPositioningElement | |
| void | setX (std::optional< Lengthd > value) |
| Sets the x attribute list to a single value (absolute x-position). | |
| std::optional< Lengthd > | x () const |
| Gets the first x attribute value (absolute x-position) from the list. | |
| void | setXList (SmallVector< Lengthd, 1 > &&value) |
| Sets the x attribute list (absolute x-position for each character). | |
| const SmallVector< Lengthd, 1 > & | xList () const |
| Gets the x attribute list (absolute x-position for each character). | |
| void | setY (std::optional< Lengthd > value) |
| Sets the y attribute list to a single value (absolute y-position). | |
| std::optional< Lengthd > | y () const |
| Gets the first y attribute value (absolute y-position) from the list. | |
| void | setYList (SmallVector< Lengthd, 1 > &&value) |
| Sets the y attribute list (absolute y-position for each character). | |
| const SmallVector< Lengthd, 1 > & | yList () const |
| Gets the y attribute list (absolute y-position for each character). | |
| void | setDx (std::optional< Lengthd > value) |
| Sets the dx attribute list to a single value (relative shift in x). | |
| std::optional< Lengthd > | dx () const |
| Gets the first dx attribute value (relative shift in x) from the list. | |
| void | setDxList (SmallVector< Lengthd, 1 > &&value) |
| Sets the dx attribute list (relative shift in x for each character). | |
| const SmallVector< Lengthd, 1 > & | dxList () const |
| Gets the dx attribute list (relative shift in x for each character). | |
| void | setDy (std::optional< Lengthd > value) |
| Sets the dy attribute list to a single value (relative shift in y). | |
| std::optional< Lengthd > | dy () const |
| Gets the first dy attribute value (relative shift in y) from the list. | |
| void | setDyList (SmallVector< Lengthd, 1 > &&value) |
| Sets the dy attribute list (relative shift in y for each character). | |
| const SmallVector< Lengthd, 1 > & | dyList () const |
| Gets the dy attribute list (relative shift in y for each character). | |
| void | setRotate (std::optional< double > degrees) |
| Sets the rotate attribute list to a single value (rotation in degrees). | |
| std::optional< double > | rotate () const |
| Gets the first rotate attribute value from the list. | |
| void | setRotateList (SmallVector< double, 1 > &&value) |
| Sets the rotate attribute list (rotation in degrees for each character). | |
| const SmallVector< double, 1 > & | rotateList () const |
| Gets the rotate attribute list (rotation in degrees for each character). | |
| Public Member Functions inherited from donner::svg::SVGTextContentElement | |
| std::optional< Lengthd > | textLength () const |
| Returns the textLength attribute (the author's intended length for the text). | |
| void | setTextLength (std::optional< Lengthd > value) |
| Sets the textLength attribute, which indicates the author-computed total length for the text layout. | |
| LengthAdjust | lengthAdjust () const |
| Returns the lengthAdjust attribute, which controls how the text is stretched or spaced to fit the textLength. | |
| void | setLengthAdjust (LengthAdjust value) |
| Controls how the text is stretched or spaced to fit the textLength. | |
| long | getNumberOfChars () const |
| Returns the total number of addressable characters in the element. | |
| double | getComputedTextLength () const |
| Computes the total advance distance for all glyphs. | |
| double | getSubStringLength (std::size_t charnum, std::size_t nchars) const |
| Computes the advance distance for a substring of text. | |
| Vector2d | getStartPositionOfChar (std::size_t charnum) const |
| Returns the start position (in user space) of the glyphs corresponding to the given character index. | |
| Vector2d | getEndPositionOfChar (std::size_t charnum) const |
| Returns the end position (in user space) of the glyphs corresponding to the given character index. | |
| Box2d | getExtentOfChar (std::size_t charnum) const |
| Returns the bounding box of the glyph cell for the specified character, in the element's coordinate space. | |
| double | getRotationOfChar (std::size_t charnum) const |
| Returns the rotation applied to the glyphs corresponding to the given character index, in degrees. | |
| long | getCharNumAtPosition (const Vector2d &point) const |
| Given a point in the element's coordinate space, returns which character is rendered at that point. | |
| void | selectSubString (std::size_t charnum, std::size_t nchars) |
| Select a substring of characters for user operations (e.g. | |
| void | invalidateTextGeometry () |
| Invalidate cached text layout for the text root containing this element. | |
| void | appendText (std::string_view text) |
| Append text content from text or CDATA nodes. | |
| void | advanceTextChunk () |
| Start a new direct-text chunk after an intervening child element. | |
| RcString | textContent () const |
| Get the raw text content concatenated from all child text nodes. | |
| Public Member Functions inherited from donner::svg::SVGGraphicsElement | |
| Transform2d | transform () const |
| Get the 2d transformation for this element, element-from-parent. | |
| void | setTransform (const Transform2d &transform) |
| Set the 2d transformation for this element, element-from-parent. This is a no-op if the transform is identity. | |
| Transform2d | elementFromWorld () const |
| Get the absolute element-from-world transform for this element. | |
| Public Member Functions inherited from donner::svg::SVGElement | |
| SVGElement (const SVGElement &other) | |
| Create another reference to the same SVGElement. | |
| SVGElement (SVGElement &&other) noexcept | |
| Move constructor. | |
| ~SVGElement () noexcept | |
| Destructor. | |
| SVGElement & | operator= (const SVGElement &other) |
| Create another reference to the same SVGElement. | |
| SVGElement & | operator= (SVGElement &&other) noexcept |
| Move assignment operator. | |
| ElementType | type () const |
| Get the ElementType for known XML element types. | |
| std::optional< ElementType > | tryType () const |
| Get the ElementType if this handle still has SVG element identity. | |
| xml::XMLQualifiedNameRef | tagName () const |
| Get the XML tag name string for this element. | |
| std::optional< xml::XMLQualifiedNameRef > | tryTagName () const |
| Get the XML tag name if this handle still has XML tree identity. | |
| bool | isKnownType () const |
| Returns true if this is a known element type, returns false if this is an donner::svg::SVGUnknownElement. | |
| EntityHandle | unsafeEntityHandle () const |
| Get the underlying donner::EntityHandle. | |
| EntityHandle | entityHandle () const |
| Get the underlying donner::EntityHandle, for advanced use-cases that require direct access to the ECS. | |
| template<typename Callback> | |
| decltype(auto) | withReadAccess (Callback &&callback) const |
| Run a callback with scoped read access to this element's document and resolved entity handle. | |
| template<typename Callback> | |
| decltype(auto) | withWriteAccess (Callback &&callback) const |
| Run a callback with scoped write access to this element's document and resolved entity handle. | |
| RcString | id () const |
| Get the element id, the value of the "id" attribute. | |
| void | setId (std::string_view id) |
| Set the element id, the value of the "id" attribute. | |
| RcString | className () const |
| Get the element class name, the value of the "class" attribute. | |
| void | setClassName (std::string_view name) |
| Set the element class name, the value of the "class" attribute. | |
| void | setStyle (std::string_view style) |
| Set the element style, the value of the "style" attribute. | |
| void | updateStyle (std::string_view style) |
| Update the element style, adding new attributes or overridding existing ones (without removing them). | |
| ParseResult< bool > | trySetPresentationAttribute (std::string_view name, std::string_view value) |
| Set the value of a presentation attribute, such as "fill" or "stroke". | |
| bool | hasAttribute (const xml::XMLQualifiedNameRef &name) const |
| Returns true if the element has an attribute with the given name. | |
| std::optional< RcString > | getAttribute (const xml::XMLQualifiedNameRef &name) const |
| Get the value of an attribute, if it exists. | |
| SmallVector< xml::XMLQualifiedNameRef, 1 > | findMatchingAttributes (const xml::XMLQualifiedNameRef &matcher) const |
| Find attributes matching the given name matcher. | |
| SmallVector< xml::XMLQualifiedNameRef, 10 > | attributes () const |
| Get the list of attributes for this element. | |
| void | setAttribute (const xml::XMLQualifiedNameRef &name, std::string_view value) |
| Set the value of a generic XML attribute, which may be either a presentation attribute or custom user-provided attribute. | |
| void | removeAttribute (const xml::XMLQualifiedNameRef &name) |
| Remove an attribute, which may be either a presentation attribute or custom user-provided attribute. | |
| SVGDocument | ownerDocument () |
| Get an owning reference to the SVGDocument containing this element. | |
| std::optional< SVGElement > | parentElement () const |
| Get this element's parent, if it exists. | |
| std::optional< SVGElement > | firstChild () const |
| Get the first child of this element, if it exists. | |
| std::optional< SVGElement > | lastChild () const |
| Get the last child of this element, if it exists. | |
| std::optional< SVGElement > | previousSibling () const |
| Get the previous sibling of this element, if it exists. | |
| std::optional< SVGElement > | nextSibling () const |
| Get the next sibling of this element, if it exists. | |
| void | insertBefore (const SVGElement &newNode, std::optional< SVGElement > referenceNode) |
Insert newNode as a child, before referenceNode. | |
| void | appendChild (const SVGElement &child) |
Append child as a child of the current node. | |
| void | replaceChild (const SVGElement &newChild, const SVGElement &oldChild) |
Replace oldChild with newChild in the tree, removing oldChild and inserting newChild in its place. | |
| void | removeChild (const SVGElement &child) |
Remove child from this node. | |
| void | remove () |
| Remove this node from its parent, if it has one. | |
| bool | operator== (const SVGElement &other) const |
| Returns true if the two SVGElement handles reference the same underlying document. | |
| bool | operator!= (const SVGElement &other) const |
| Returns true if the two SVGElement handles reference the same underlying document. | |
| template<typename Derived> | |
| bool | isa () const |
| Return true if this element "is a" instance of type, if it be cast to a specific type with cast. | |
| template<typename Derived> | |
| Derived | cast () |
| Cast this element to its derived type. | |
| template<typename Derived> | |
| Derived | cast () const |
| Cast this element to its derived type (const version). | |
| template<typename Derived> | |
| std::optional< Derived > | tryCast () |
| Cast this element to its derived type, if possible. | |
| template<typename Derived> | |
| std::optional< const Derived > | tryCast () const |
| Cast this element to its derived type, if possible. | |
| std::optional< SVGElement > | querySelector (std::string_view selector) |
| Find the first element in the tree that matches the given CSS selector. | |
| const PropertyRegistry & | getComputedStyle () const |
| Get the computed CSS style of this element, after the CSS cascade has been applied. | |
Static Public Member Functions | |
| static SVGTextElement | Create (SVGDocument &document) |
| Create a new "<text>" element within the specified document. | |
| Static Public Member Functions inherited from donner::svg::SVGTextPositioningElement | |
| static constexpr bool | IsBaseOf (ElementType type) |
| Returns true if the given element type can be cast to SVGTextPositioningElement. | |
| Static Public Member Functions inherited from donner::svg::SVGTextContentElement | |
| static constexpr bool | IsBaseOf (ElementType type) |
| Returns true if the given element type can be cast to SVGTextContentElement. | |
| Static Public Member Functions inherited from donner::svg::SVGGraphicsElement | |
| static constexpr bool | IsBaseOf (ElementType type) |
| Returns true if the given element type can be cast to SVGTextContentElement. | |
Static Public Attributes | |
| static constexpr ElementType | Type = ElementType::Text |
| Element type. | |
| static constexpr std::string_view | Tag {"text"} |
| XML tag name, "<text>". | |
Friends | |
| class | parser::SVGParserImpl |
Additional Inherited Members | |
| Protected Member Functions inherited from donner::svg::SVGTextPositioningElement | |
| SVGTextPositioningElement (EntityHandle handle) | |
| Inheriting constructor to be called by derived classes. | |
| Protected Member Functions inherited from donner::svg::SVGTextContentElement | |
| SVGTextContentElement (EntityHandle handle) | |
| Inheriting constructor to be called by derived classes. | |
| std::vector< Path > | computedGlyphPaths () const |
| Return glyph outlines for this text subtree, in local coordinates. | |
| Box2d | computedInkBounds () const |
| Return the ink bounds for this text subtree, in local coordinates. | |
| Box2d | computedObjectBoundingBox () const |
| Return the text object bounding box for this text subtree, in local coordinates. | |
| Protected Member Functions inherited from donner::svg::SVGGraphicsElement | |
| SVGGraphicsElement (EntityHandle handle) | |
| Inheriting constructor to be called by derived classes. SVGGraphicsElement cannot be instantiated directly. | |
| Protected Member Functions inherited from donner::svg::SVGElement | |
| SVGElement (EntityHandle handle) | |
| Internal constructor to create an SVGElement from an donner::EntityHandle. | |
| template<typename InvalidateCallback> | |
| ScopedMutation< std::decay_t< InvalidateCallback > > | mutationScope (InvalidateCallback &&invalidateOnScopeExit) const |
Create a scoped mutation that runs invalidateOnScopeExit before the revision commit. | |
| std::optional< ParseDiagnostic > | setAttributeFromXMLMutation (const xml::XMLQualifiedNameRef &name, std::string_view value) |
| Set an attribute from an XML mutation and return any SVG semantic parse diagnostic. | |
| void | removeAttributeFromXMLMutation (const xml::XMLQualifiedNameRef &name) |
| Remove an attribute from an XML mutation without writing back to XML source. | |
| Registry & | unsafeRegistry () const |
| Get the underlying ECS Registry, which holds all data for the document, for advanced use. | |
| Registry & | registry () const |
| Get the underlying ECS Registry, which holds all data for the document, for advanced use. | |
| EntityHandle | toHandle (Entity entity) const |
| Convert an Entity to an EntityHandle, for advanced use. | |
| Static Protected Member Functions inherited from donner::svg::SVGElement | |
| static DocumentWriteAccess | CreateElementWriteAccess (SVGDocument &document) |
| Acquire write access for creating an element in a document. | |
| static DocumentMutationBatch | CreateElementMutationBatch (SVGDocument &document) |
| Acquire a mutation scope for creating an element in a document. | |
| static EntityHandle | CreateEmptyEntity (SVGDocument &document) |
| Create a new Entity within the document ECS, and return a handle to it. | |
| static EntityHandle | CreateEmptyEntity (DocumentWriteAccess &access) |
| Create a new Entity within a guarded document ECS, and return a handle to it. | |
| static void | CreateEntityOn (EntityHandle handle, const xml::XMLQualifiedNameRef &tagName, ElementType Type) |
| Create a new SVG element instance on a given donner::Entity. | |
| Protected Attributes inherited from donner::svg::SVGElement | |
| ElementAnchor | handle_ |
| The lifetime-aware ECS entity anchor for this element. | |
DOM object for a "<text>" element.
Text rendering supports <text>, "<tspan>" for sub-spans, and "<textPath>" for text along a path. Fonts are loaded from @font-face rules (TTF, OTF, WOFF, WOFF2) or a built-in fallback. With the text_full build config, HarfBuzz provides complex script shaping.
| std::vector< Path > donner::svg::SVGTextElement::convertToPath | ( | ) | const |
Convert this text element to positioned glyph outlines, one donner::Path per glyph.
Useful for custom rendering, export to path-only formats, or computing text geometry without the full rendering pipeline.
|
inlinestatic |
Create a new "<text>" element within the specified document.
| document | Containing document. |
| Box2d donner::svg::SVGTextElement::inkBoundingBox | ( | ) | const |
Return the tight bounding box of the actual rendered glyphs (ink extents).
This is the smallest rectangle that encloses all painted pixels.
| Box2d donner::svg::SVGTextElement::objectBoundingBox | ( | ) | const |
Return the object bounding box as defined by SVG2.
This is used for resolving objectBoundingBox units in gradients, patterns, and clip paths applied to this text. It may differ from inkBoundingBox() due to line-height and baseline positioning.