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.