pub struct GeneratedFontSystemAdapter<F> { /* private fields */ }Expand description
Adapter that resolves XeTeX native font requests through a FontSystem.
Implementations§
Source§impl<F> GeneratedFontSystemAdapter<F>
impl<F> GeneratedFontSystemAdapter<F>
Sourcepub fn new(fonts: F) -> Self
pub fn new(fonts: F) -> Self
Constructs the adapter wrapping fonts.
Examples found in repository?
examples/pack_native_format.rs (lines 101-103)
72fn main() -> ExitCode {
73 let Some(output) = output_path() else {
74 eprintln!("usage: pack_native_format <output path>");
75 return ExitCode::FAILURE;
76 };
77 let Some(texmf_root) = find_texmf_root() else {
78 eprintln!("cannot find a texmf-dist ls-R index");
79 return ExitCode::FAILURE;
80 };
81 let Some(texmf) = TexmfResources::from_root(texmf_root) else {
82 eprintln!("cannot load the texmf-dist ls-R index");
83 return ExitCode::FAILURE;
84 };
85 let texmf = Arc::new(texmf);
86
87 let latex = match texmf.read("latex.ltx", ResourceKind::TexInput) {
88 Ok(resource) => resource.bytes,
89 Err(error) => {
90 eprintln!("cannot read latex.ltx: {error:?}");
91 return ExitCode::FAILURE;
92 }
93 };
94
95 let cache = GeneratedFormatCache::initialized(pe::EngineProfile::xetex());
96 let mut engine = cache
97 .instantiate(
98 pe::EngineProfile::xetex(),
99 GeneratedResourceProvider::new(&*texmf),
100 )
101 .with_font_platform(GeneratedFontSystemAdapter::new(NativeFontSystem::new(
102 texmf.clone(),
103 )));
104
105 if !engine.begin_primary_input("latex.ltx", latex) {
106 eprintln!("failed to begin latex.ltx");
107 return ExitCode::FAILURE;
108 }
109 engine.run_format_initialization();
110 if !engine.begin_primary_input("preamble.tex", PREAMBLE.to_vec()) {
111 eprintln!("failed to begin preamble");
112 return ExitCode::FAILURE;
113 }
114 engine.run_format_initialization();
115
116 engine.finalize_trie();
117 let format_bytes = GeneratedFormatCache::from_engine(&engine).to_bytes();
118 let font_table = engine.native_font_table();
119 let packaged = mathtex_engine::generated::pack_packaged_format(&format_bytes, &font_table);
120 if let Err(error) = std::fs::write(&output, packaged) {
121 eprintln!("cannot write {}: {error}", output.display());
122 return ExitCode::FAILURE;
123 }
124 ExitCode::SUCCESS
125}Sourcepub fn font_system(&self) -> &F
pub fn font_system(&self) -> &F
Returns a reference to the wrapped font system.
Sourcepub fn into_font_system(self) -> F
pub fn into_font_system(self) -> F
Unwraps and returns the inner font system.
Sourcepub fn loaded_font(&self, handle: GeneratedFontHandle) -> Option<&FontData>
pub fn loaded_font(&self, handle: GeneratedFontHandle) -> Option<&FontData>
Returns the font data for a loaded handle, or None if not found.
Trait Implementations§
Source§impl<F: Clone> Clone for GeneratedFontSystemAdapter<F>
impl<F: Clone> Clone for GeneratedFontSystemAdapter<F>
Source§impl<F: Debug> Debug for GeneratedFontSystemAdapter<F>
impl<F: Debug> Debug for GeneratedFontSystemAdapter<F>
Source§impl<F> FontPlatform for GeneratedFontSystemAdapter<F>where
F: FontSystem,
impl<F> FontPlatform for GeneratedFontSystemAdapter<F>where
F: FontSystem,
fn resolve_font_handle( &mut self, name: &[i32], size: i32, ) -> Option<GeneratedFontHandle>
fn release_font_handle(&mut self, font: GeneratedFontHandle, _type_flag: i32)
Source§fn font_table(&self) -> Vec<(GeneratedFontHandle, String, i32)>
fn font_table(&self) -> Vec<(GeneratedFontHandle, String, i32)>
Snapshot the platform’s native-font table as
(handle, spec, size)
tuples. A serialized format image keeps integer font handles in
fontlayoutengine, but those handles only mean something to the platform
that minted them; capturing the table lets a cold load rebind them.Source§fn restore_font_table(
&mut self,
table: &[(GeneratedFontHandle, String, i32)],
) -> bool
fn restore_font_table( &mut self, table: &[(GeneratedFontHandle, String, i32)], ) -> bool
Rebuild the native-font table from a
Self::font_table snapshot,
(re)loading each font at its original handle so the fontlayoutengine
handles preserved in a reloaded format image resolve again. Returns
false if any font failed to load.fn font_metrics(&mut self, font: GeneratedFontHandle) -> GeneratedFontMetrics
fn opentype_font_metrics( &mut self, font: GeneratedFontHandle, ) -> GeneratedFontMetrics
fn is_opentype_math_font(&mut self, font: GeneratedFontHandle) -> bool
Source§fn using_opentype(&mut self, font: GeneratedFontHandle) -> bool
fn using_opentype(&mut self, font: GeneratedFontHandle) -> bool
Whether
font is shaped through the OpenType (HarfBuzz/rustybuzz) shaper.
Mirrors XeTeX’s usingOpenType, which is true for the "ot" shaper (the
default). This engine always shapes native fonts with rustybuzz, so any
loaded native font handle returns true.fn math_symbol_parameter( &mut self, font: GeneratedFontHandle, parameter: i32, ) -> i32
fn math_extension_parameter( &mut self, font: GeneratedFontHandle, parameter: i32, ) -> i32
fn opentype_math_constant( &mut self, font: GeneratedFontHandle, constant: i32, ) -> i32
fn opentype_math_accent_position( &mut self, font: GeneratedFontHandle, glyph: i32, ) -> i32
Source§fn math_glyph_italic_correction(
&mut self,
font: GeneratedFontHandle,
glyph: i32,
) -> i32
fn math_glyph_italic_correction( &mut self, font: GeneratedFontHandle, glyph: i32, ) -> i32
OpenType MATH italic correction for a glyph, in scaled points.
Source§fn math_glyph_variant(
&mut self,
font: GeneratedFontHandle,
glyph: i32,
index: u16,
horizontal: bool,
) -> Option<GeneratedMathVariant>
fn math_glyph_variant( &mut self, font: GeneratedFontHandle, glyph: i32, index: u16, horizontal: bool, ) -> Option<GeneratedMathVariant>
The
index-th larger MATH glyph variant of glyph (horizontal or
vertical), or None when there is no such variant. The advance is in
scaled points.Source§fn math_glyph_assembly(
&mut self,
font: GeneratedFontHandle,
glyph: i32,
horizontal: bool,
) -> Vec<GeneratedMathAssemblyPart> ⓘ
fn math_glyph_assembly( &mut self, font: GeneratedFontHandle, glyph: i32, horizontal: bool, ) -> Vec<GeneratedMathAssemblyPart> ⓘ
The MATH glyph-assembly parts for
glyph (horizontal or vertical), each
metric in scaled points. Empty when the glyph has no assembly.Source§fn math_min_connector_overlap(&mut self, font: GeneratedFontHandle) -> i32
fn math_min_connector_overlap(&mut self, font: GeneratedFontHandle) -> i32
The MATH minimum connector overlap for assembly parts, in scaled points.
Source§fn math_kern_at(
&mut self,
font: GeneratedFontHandle,
glyph: i32,
corner: GeneratedMathKernCorner,
correction_height: i32,
) -> i32
fn math_kern_at( &mut self, font: GeneratedFontHandle, glyph: i32, corner: GeneratedMathKernCorner, correction_height: i32, ) -> i32
One MATH
MathKernInfo corner evaluated at correction_height (font
design units), returned in raw font design units (NOT scaled).Source§fn math_points_to_units(
&mut self,
font: GeneratedFontHandle,
points: f32,
) -> f32
fn math_points_to_units( &mut self, font: GeneratedFontHandle, points: f32, ) -> f32
Convert a measurement in points to font design units for
font
(pointsToUnits).Source§fn math_units_to_scaled(&mut self, font: GeneratedFontHandle, units: i32) -> i32
fn math_units_to_scaled(&mut self, font: GeneratedFontHandle, units: i32) -> i32
Convert a measurement in font design units to scaled points for
font
(D2Fix(unitsToPoints(...))).Source§fn math_point_size(&mut self, font: GeneratedFontHandle) -> f32
fn math_point_size(&mut self, font: GeneratedFontHandle) -> f32
The point size at which
font was loaded (getPointSize).fn map_char_to_glyph( &mut self, font: GeneratedFontHandle, codepoint: i32, ) -> i32
fn map_glyph_to_index(&mut self, font: GeneratedFontHandle, name: &str) -> i32
Source§fn ot_font_get(
&mut self,
font: GeneratedFontHandle,
what: i32,
param1: i32,
param2: i32,
param3: i32,
) -> i32
fn ot_font_get( &mut self, font: GeneratedFontHandle, what: i32, param1: i32, param2: i32, param3: i32, ) -> i32
OpenType layout enumeration backing the
\XeTeXOT* / \XeTeXcountglyphs
last_item primitives (XeTeX ot_font_get/_1/_2/_3). what is the
XeTeX_ext code (1 = count glyphs, 16 = count scripts, 17 = count
languages, 18 = count features, 19 = script tag, 20 = language tag,
21 = feature tag); unused params are 0.Source§fn font_spec(&self, font: GeneratedFontHandle) -> Option<String>
fn font_spec(&self, font: GeneratedFontHandle) -> Option<String>
The
\font spec string a loaded handle was created from (e.g.
[latinmodern-math.otf]:script=math;ssty=1). Immutable so the read-only
IR-building path can recover the originating font file for a glyph run.fn shape_native_text( &mut self, font: GeneratedFontHandle, text: &[u16], _use_glyph_metrics: bool, ) -> GeneratedNativeTextMetrics
fn measure_native_glyph( &mut self, font: GeneratedFontHandle, glyph: u16, _use_glyph_metrics: bool, ) -> GeneratedNativeGlyphMetrics
Auto Trait Implementations§
impl<F> !RefUnwindSafe for GeneratedFontSystemAdapter<F>
impl<F> !UnwindSafe for GeneratedFontSystemAdapter<F>
impl<F> Freeze for GeneratedFontSystemAdapter<F>where
F: Freeze,
impl<F> Send for GeneratedFontSystemAdapter<F>where
F: Send,
impl<F> Sync for GeneratedFontSystemAdapter<F>where
F: Sync,
impl<F> Unpin for GeneratedFontSystemAdapter<F>where
F: Unpin,
impl<F> UnsafeUnpin for GeneratedFontSystemAdapter<F>where
F: UnsafeUnpin,
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