pub struct GenerateWebfontsResult { /* private fields */ }Expand description
Result of a successful generateWebfonts call. Exposes the generated
font bytes (or null for formats that were not requested) and methods to
render the CSS and HTML preview.
Implementations§
Source§impl GenerateWebfontsResult
impl GenerateWebfontsResult
Sourcepub fn regenerate(
&mut self,
ordered_paths: &[String],
changes: &[(String, GlyphChange)],
) -> Result<()>
pub fn regenerate( &mut self, ordered_paths: &[String], changes: &[(String, GlyphChange)], ) -> Result<()>
Rebuild after a batch of file changes, reusing cached glyph geometry for files whose
contents are unchanged. Requires the result to have been generated with incremental
enabled. ordered_paths is the complete file set after the changes, in the order a fresh
build would use (e.g. the glob result); the rebuilt glyphs are ordered to match it, so
auto-assigned codepoints and glyph order — and therefore the output bytes — are identical
to a fresh generate of that set, including for additions that sort before existing
glyphs. changes describes what to do per affected file: added/changed files are read from
disk and re-parsed; any file absent from ordered_paths is dropped (an explicit Removed
is optional but harmless). Every requested format is rebuilt in memory, and — matching
generate — when the result was built with write_files enabled the refreshed fonts are
written to disk too, while CSS/HTML companion files are skipped if their rendered bytes are
unchanged from the previous write. Rendered CSS/HTML is reused when the glyph names and
codepoints the templates read are unchanged (a content edit), and re-rendered otherwise.
use webfont_generator::{
generate_sync, FontType, GenerateWebfontsOptions, GlyphChange,
};
let files = vec![
"icons/add.svg".to_owned(),
"icons/remove.svg".to_owned(),
];
let mut result = generate_sync(
GenerateWebfontsOptions {
dest: "dist".to_owned(),
files: files.clone(),
incremental: Some(true),
types: Some(vec![FontType::Woff2]),
write_files: Some(false),
..Default::default()
},
None,
)?;
result.regenerate(
&files,
&[(
"icons/add.svg".to_owned(),
GlyphChange::Changed { name: None },
)],
)?;Sourcepub fn regenerate_all(&mut self, ordered_paths: &[String]) -> Result<()>
pub fn regenerate_all(&mut self, ordered_paths: &[String]) -> Result<()>
Rebuild after re-diffing the complete ordered file set against the retained incremental cache. This is useful when the caller has a fresh file list but not a reliable watcher change batch: every current path is re-read and hashed, missing prior paths are treated as removed, new paths as added, and paths whose content hash changed as changed. Existing glyph names are preserved; added paths derive their glyph name from the file stem.
Source§impl GenerateWebfontsResult
impl GenerateWebfontsResult
Sourcepub fn svg_string(&self) -> Option<&str>
pub fn svg_string(&self) -> Option<&str>
Returns the SVG font string, if generated.
Sourcepub fn woff_bytes(&self) -> Option<&[u8]>
pub fn woff_bytes(&self) -> Option<&[u8]>
Returns the WOFF font bytes, if generated.
Sourcepub fn woff2_bytes(&self) -> Option<&[u8]>
pub fn woff2_bytes(&self) -> Option<&[u8]>
Returns the WOFF2 font bytes, if generated.
Auto Trait Implementations§
impl !Freeze for GenerateWebfontsResult
impl !RefUnwindSafe for GenerateWebfontsResult
impl !UnwindSafe for GenerateWebfontsResult
impl Send for GenerateWebfontsResult
impl Sync for GenerateWebfontsResult
impl Unpin for GenerateWebfontsResult
impl UnsafeUnpin for GenerateWebfontsResult
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> 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>
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>
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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
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.