pub struct Font {
pub name: String,
pub data: Vec<u8>,
pub format: FontFormat,
pub metrics: FontMetrics,
pub descriptor: FontDescriptor,
pub glyph_mapping: GlyphMapping,
}Expand description
Represents a loaded font ready for embedding
Fields§
§name: StringFont name as it will appear in the PDF
data: Vec<u8>Raw font data
format: FontFormatFont format (TTF or OTF)
metrics: FontMetricsFont metrics
descriptor: FontDescriptorFont descriptor
glyph_mapping: GlyphMappingCharacter to glyph mapping
Implementations§
Source§impl Font
impl Font
Sourcepub fn from_file(
name: impl Into<String>,
path: impl AsRef<Path>,
) -> Result<Self>
pub fn from_file( name: impl Into<String>, path: impl AsRef<Path>, ) -> Result<Self>
Load a font from file path
Sourcepub fn from_bytes(name: impl Into<String>, data: Vec<u8>) -> Result<Self>
pub fn from_bytes(name: impl Into<String>, data: Vec<u8>) -> Result<Self>
Load a font from byte data
Sourcepub fn postscript_name(&self) -> &str
pub fn postscript_name(&self) -> &str
Get the PostScript name of the font
Sourcepub fn measure_text(&self, text: &str, font_size: f32) -> TextMeasurement
pub fn measure_text(&self, text: &str, font_size: f32) -> TextMeasurement
Measure text using this font at a specific size
Sourcepub fn line_height(&self, font_size: f32) -> f32
pub fn line_height(&self, font_size: f32) -> f32
Get the recommended line height for this font at a specific size
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Font
impl RefUnwindSafe for Font
impl Send for Font
impl Sync for Font
impl Unpin for Font
impl UnsafeUnpin for Font
impl UnwindSafe for Font
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,
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