pub struct Text { /* private fields */ }
Expand description
A text element.
text
element in SVG.
Implementations§
source§impl Text
impl Text
sourcepub fn id(&self) -> &str
pub fn id(&self) -> &str
Element’s ID.
Taken from the SVG itself. Isn’t automatically generated. Can be empty.
sourcepub fn rendering_mode(&self) -> TextRendering
pub fn rendering_mode(&self) -> TextRendering
Rendering mode.
text-rendering
in SVG.
sourcepub fn dx(&self) -> &[f32]
pub fn dx(&self) -> &[f32]
A relative X axis offsets.
One offset for each Unicode codepoint. Aka char
in Rust.
sourcepub fn dy(&self) -> &[f32]
pub fn dy(&self) -> &[f32]
A relative Y axis offsets.
One offset for each Unicode codepoint. Aka char
in Rust.
sourcepub fn rotate(&self) -> &[f32]
pub fn rotate(&self) -> &[f32]
A list of rotation angles.
One angle for each Unicode codepoint. Aka char
in Rust.
sourcepub fn writing_mode(&self) -> WritingMode
pub fn writing_mode(&self) -> WritingMode
A writing mode.
sourcepub fn abs_transform(&self) -> Transform
pub fn abs_transform(&self) -> Transform
Element’s absolute transform.
Contains all ancestors transforms including elements’s transform.
Note that this is not the relative transform present in SVG. The SVG one would be set only on groups.
sourcepub fn bounding_box(&self) -> Rect
pub fn bounding_box(&self) -> Rect
Element’s text bounding box.
Text bounding box is special in SVG and doesn’t represent tight bounds of the element’s content. You can find more about it here.
objectBoundingBox
in SVG terms. Meaning it doesn’t affected by parent transforms.
Returns None
when the text
build feature was disabled.
This is because we have to perform a text layout before calculating a bounding box.
sourcepub fn abs_bounding_box(&self) -> Rect
pub fn abs_bounding_box(&self) -> Rect
Element’s text bounding box in canvas coordinates.
userSpaceOnUse
in SVG terms.
sourcepub fn stroke_bounding_box(&self) -> Rect
pub fn stroke_bounding_box(&self) -> Rect
Element’s object bounding box including stroke.
Similar to bounding_box
, but includes stroke.
Will have the same value as bounding_box
when path has no stroke.
sourcepub fn abs_stroke_bounding_box(&self) -> Rect
pub fn abs_stroke_bounding_box(&self) -> Rect
Element’s bounding box including stroke in canvas coordinates.
sourcepub fn flattened(&self) -> &Group
pub fn flattened(&self) -> &Group
Text converted into paths, ready to render.
Note that this is only a “best-effort” attempt: The text will be converted into group/paths/image primitives, so that they can be rendered with the existing infrastructure. This process is in general lossless and should lead to correct output, with two notable exceptions:
- For glyphs based on the
SVG
table, only glyphs that are pure SVG 1.1/2.0 are supported. Glyphs that make use of features in the OpenType specification that are not part of the original SVG specification are not supported. - For glyphs based on the
COLR
table, there are a certain number of features that are not (correctly) supported, such as conical gradients, certain gradient transforms and some blend modes. But this shouldn’t cause any issues in 95% of the cases, as most of those are edge cases. If the two above are not acceptable, then you will need to implement your own glyph rendering logic based on the layouted glyphs (see thelayouted
method).
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Text
impl !RefUnwindSafe for Text
impl Send for Text
impl Sync for Text
impl Unpin for Text
impl !UnwindSafe for Text
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)