pub struct SvgFonts { /* private fields */ }svg-text only.Expand description
The font faces an ingested SVG’s <text> may be set in.
Each face is registered under the family names its own name table
declares, which is how an SVG’s font-family finds it. Empty by default:
a session that registers nothing renders no text, and says so in the
report.
Cheap to clone — the registered faces are shared, not copied — so one set built at start-up serves every document.
use pdfrum::{Document, SvgFonts};
let mut fonts = SvgFonts::new();
fonts.register(std::fs::read("Inter.ttf")?);
assert_eq!(fonts.families(), ["Inter"]);
let doc = Document::open("in.pdf")?;
let mut edit = doc.edit();
edit.set_svg_fonts(fonts);Implementations§
Source§impl SvgFonts
impl SvgFonts
Sourcepub fn register(&mut self, program: impl Into<Vec<u8>>) -> bool
pub fn register(&mut self, program: impl Into<Vec<u8>>) -> bool
Register one font program — a TTF, OTF or TTC — under the families its own name table declares.
Returns whether the face was usable. A false is a font this build
cannot parse, not an error: registering a directory of faces should
not fail on the one that is a README, and a family that never arrives
shows up as a reported Unsupported::Text when
a document asks for it.
The first face registered also becomes the default family, so the
common case — one face, text with no font-family — needs no second
call.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for SvgFonts
impl !UnwindSafe for SvgFonts
impl Freeze for SvgFonts
impl Send for SvgFonts
impl Sync for SvgFonts
impl Unpin for SvgFonts
impl UnsafeUnpin for SvgFonts
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§impl<U, T> ToOwnedObj<U> for Twhere
U: FromObjRef<T>,
impl<U, T> ToOwnedObj<U> for Twhere
U: FromObjRef<T>,
Source§fn to_owned_obj(&self, data: FontData<'_>) -> U
fn to_owned_obj(&self, data: FontData<'_>) -> U
T, using the provided data to resolve any offsets.