pub struct FontRegistry { /* private fields */ }Implementations§
Source§impl FontRegistry
impl FontRegistry
pub fn empty() -> Self
pub fn with_defaults() -> Result<Self, FontError>
Sourcepub fn with_fonts(
regular_bytes: &[u8],
bold_bytes: &[u8],
) -> Result<Self, FontError>
pub fn with_fonts( regular_bytes: &[u8], bold_bytes: &[u8], ) -> Result<Self, FontError>
Builds a registry from caller-supplied static TrueType glyf fonts
(ADR-012, same constraint as the bundled defaults) instead of Source
Sans 3 — always available, independent of the default-fonts
feature.
pub fn register(&mut self, key: FontKey, bytes: &[u8]) -> Result<(), FontError>
pub fn register_named( &mut self, key: FontKey, name: impl Into<String>, bytes: &[u8], ) -> Result<(), FontError>
Sourcepub fn font_entries(&self) -> Vec<(FontKey, &RegisteredFont)>
pub fn font_entries(&self) -> Vec<(FontKey, &RegisteredFont)>
Order matches how the facade registers PDF fonts — used to build
resource names (F1, F2, …) consistently between PDF font
registration and content-stream references.
Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
true if nothing was ever registered — checked by
render::render_document before layout starts, so an empty
registry becomes RenderError::NoFontsRegistered instead of
entry()’s fallback panicking with nothing to fall back to.
Sourcepub fn entry(&self, key: FontKey) -> &RegisteredFont
pub fn entry(&self, key: FontKey) -> &RegisteredFont
Panics if self is empty. Safe everywhere it’s actually called
(every width/wrap calculation during layout, via FontResolver
below) because render::render_document rejects an empty
registry up front with RenderError::NoFontsRegistered, before
layout — the only caller of entry() — ever runs.
Sourcepub fn get(&self, key: FontKey) -> Option<&RegisteredFont>
pub fn get(&self, key: FontKey) -> Option<&RegisteredFont>
The exact, unfallen-back-to entry for key — None if nothing was
ever registered under it. Used at embed time
(render::text::embed_fonts) to turn a missing weight/style into
RenderError::MissingFont instead of silently embedding whatever
entry()’s fallback resolved to under the requested key’s name.