pub struct SvgRenderer { /* private fields */ }Expand description
A struct holding everything necessary to render SVGs.
Implementations§
Source§impl SvgRenderer
impl SvgRenderer
Sourcepub fn new(asset_source: Arc<dyn AssetSource>) -> Self
pub fn new(asset_source: Arc<dyn AssetSource>) -> Self
Creates a new SVG renderer with the provided asset source.
Sourcepub fn parse_svg(&self, bytes: &[u8]) -> Result<ParsedSvg, Error>
pub fn parse_svg(&self, bytes: &[u8]) -> Result<ParsedSvg, Error>
Parses SVG data into a ParsedSvg that can be rasterized at any scale.
Sourcepub fn measure_text_width(
&self,
text: &str,
font: &SvgTextFont<'_>,
) -> Result<f32, Error>
pub fn measure_text_width( &self, text: &str, font: &SvgTextFont<'_>, ) -> Result<f32, Error>
Returns the advance of text drawn by this renderer as a single line of SVG <text>.
Sourcepub fn render_parsed(
&self,
svg: &ParsedSvg,
size: impl Into<SvgSize>,
) -> Result<Arc<RenderImage>, Error>
pub fn render_parsed( &self, svg: &ParsedSvg, size: impl Into<SvgSize>, ) -> Result<Arc<RenderImage>, Error>
Rasterizes a previously parsed SVG into an image buffer.
Sourcepub fn render_single_frame(
&self,
bytes: &[u8],
scale_factor: f32,
) -> Result<Arc<RenderImage>, Error>
pub fn render_single_frame( &self, bytes: &[u8], scale_factor: f32, ) -> Result<Arc<RenderImage>, Error>
Renders the given bytes into an image buffer.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for SvgRenderer
impl !UnwindSafe for SvgRenderer
impl Forget for SvgRenderer
impl Freeze for SvgRendererwhere
*const ArcInner<dyn AssetSource> is !null: Freeze,
PhantomData<ArcInner<dyn AssetSource>>: Freeze,
*const ArcInner<Options<'static>> is !null: Freeze,
PhantomData<ArcInner<Options<'static>>>: Freeze,
impl Move for SvgRenderer
impl Send for SvgRenderer
impl Sync for SvgRenderer
impl Unpin for SvgRenderer
impl UnsafeUnpin for SvgRendererwhere
*const ArcInner<dyn AssetSource> is !null: UnsafeUnpin,
PhantomData<ArcInner<dyn AssetSource>>: UnsafeUnpin,
*const ArcInner<Options<'static>> is !null: UnsafeUnpin,
PhantomData<ArcInner<Options<'static>>>: UnsafeUnpin,
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more