Enum Base14Font
pub enum Base14Font {
Show 14 variants
Helvetica,
HelveticaBold,
HelveticaOblique,
HelveticaBoldOblique,
TimesRoman,
TimesBold,
TimesItalic,
TimesBoldItalic,
Courier,
CourierBold,
CourierOblique,
CourierBoldOblique,
Symbol,
ZapfDingbats,
}Expand description
One of the 14 standard PDF fonts every conformant PDF reader ships built in (PDF 1.7 §9.6.2.2).
Variants are listed in the canonical PDF order: the four
Helvetica weights, four Times weights, four Courier weights,
then Symbol and ZapfDingbats. Self::ALL iterates them in
this order.
§Examples
use pdf_base14_metrics::Base14Font;
assert_eq!(Base14Font::ALL.len(), 14);
assert_eq!(Base14Font::Helvetica.pdf_base_name(), "Helvetica");Variants§
Helvetica
Helvetica (regular).
HelveticaBold
Helvetica Bold.
HelveticaOblique
Helvetica Oblique (regular weight, slanted).
HelveticaBoldOblique
Helvetica Bold Oblique.
TimesRoman
Times Roman (regular).
TimesBold
Times Bold.
TimesItalic
Times Italic.
TimesBoldItalic
Times Bold Italic.
Courier
Courier (regular, monospace).
CourierBold
Courier Bold (monospace).
CourierOblique
Courier Oblique (monospace, slanted).
CourierBoldOblique
Courier Bold Oblique (monospace).
Symbol
Adobe Symbol (Greek letters, math operators).
ZapfDingbats
ITC Zapf Dingbats (decorative glyphs).
Implementations§
§impl Base14Font
impl Base14Font
pub const ALL: [Base14Font; 14]
pub const ALL: [Base14Font; 14]
Every Core 14 face in stable PDF order.
pub fn metrics(self) -> &'static FontMetrics<'static>
pub fn metrics(self) -> &'static FontMetrics<'static>
Borrows the pre-parsed Adobe AFM metrics for this face.
§Examples
use pdf_base14_metrics::Base14Font;
let metrics = Base14Font::Helvetica.metrics();
assert_eq!(metrics.font_name, "Helvetica");pub fn pdf_base_name(self) -> &'static str
pub fn pdf_base_name(self) -> &'static str
PDF /BaseFont name per PDF 1.7 §9.6.2.2. These are the
exact bytes a conformant PDF writer puts after /BaseFont
in a font resource dictionary.
§Examples
use pdf_base14_metrics::Base14Font;
assert_eq!(Base14Font::TimesBoldItalic.pdf_base_name(), "Times-BoldItalic");pub fn glyph_width(self, name: &str) -> Option<f32>
pub fn glyph_width(self, name: &str) -> Option<f32>
Width of the glyph with the given PostScript name, in 1/1000
em. Returns None if no such glyph exists in this font.
This is an O(n) linear scan over the font’s character metrics
(~315 entries for the Latin faces). Prefer
Self::winansi_width when querying by byte; that path
goes through a pre-baked O(1) table. For the Latin Core 12
faces, Self::glyph_width_by_name goes through a baked
sorted index instead and is O(log n).
§Examples
use pdf_base14_metrics::Base14Font;
assert_eq!(Base14Font::Helvetica.glyph_width("A"), Some(667.0));pub fn glyph_width_by_name(self, name: &str) -> Option<f32>
pub fn glyph_width_by_name(self, name: &str) -> Option<f32>
Width of the glyph with the given PostScript name, looked up through a baked sorted index. O(log n), allocation-free, safe to call once per character per PDF page in tight loops.
Returns None for Self::Symbol and Self::ZapfDingbats
: their AFMs are intentionally unindexed because those faces
don’t participate in /Differences-style remapping. Callers
that need Symbol/Dingbat widths must use Self::glyph_width.
§Examples
use pdf_base14_metrics::Base14Font;
assert_eq!(Base14Font::Helvetica.glyph_width_by_name("A"), Some(667.0));
assert_eq!(Base14Font::Symbol.glyph_width_by_name("Alpha"), None);pub fn winansi_width(self, code: u8) -> Option<f32>
pub fn winansi_width(self, code: u8) -> Option<f32>
Width of the glyph at PDF WinAnsiEncoding byte code, in
1/1000 em. Returns None when:
codeis unmapped by PDFWinAnsi(control characters0x00..=0x1F, the gaps0x7F/0x81/0x8D/0x8F/0x90/0x9D); orselfisSelf::SymbolorSelf::ZapfDingbats. those fonts do not useWinAnsi(see the crate-level docs).
Implemented as a single [Option<f32>; 256] indexed load
per call: the table is baked at build time alongside the
font metrics. Hot enough for mos-fonts::text_width to
call once per character per typeset paragraph.
§Examples
use pdf_base14_metrics::Base14Font;
assert_eq!(Base14Font::Helvetica.winansi_width(b'A'), Some(667.0));
assert_eq!(Base14Font::Symbol.winansi_width(b'A'), None);Trait Implementations§
§impl Clone for Base14Font
impl Clone for Base14Font
§fn clone(&self) -> Base14Font
fn clone(&self) -> Base14Font
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more§impl Debug for Base14Font
impl Debug for Base14Font
Source§impl From<Base14Font> for Font
impl From<Base14Font> for Font
Source§fn from(f: Base14Font) -> Font
fn from(f: Base14Font) -> Font
§impl Hash for Base14Font
impl Hash for Base14Font
§impl PartialEq for Base14Font
impl PartialEq for Base14Font
impl Copy for Base14Font
impl Eq for Base14Font
impl StructuralPartialEq for Base14Font
Auto Trait Implementations§
impl Freeze for Base14Font
impl RefUnwindSafe for Base14Font
impl Send for Base14Font
impl Sync for Base14Font
impl Unpin for Base14Font
impl UnsafeUnpin for Base14Font
impl UnwindSafe for Base14Font
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,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.§impl<U, T> ToOwnedObj<U> for Twhere
U: FromObjRef<T>,
impl<U, T> ToOwnedObj<U> for Twhere
U: FromObjRef<T>,
§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.