Advance native LaTeX execution and preview
This commit is contained in:
1 parent
91f9d76b16
commit
2741546ca8
414 files changed
+99872
-933
No files matched your search
@@ -274,6 +274,25 @@ impl Cmr10Metrics {
|
||||
metrics_for(self)
|
||||
}
|
||||
|
||||
/// Exact embedded TFM metrics for native text. No missing-glyph fallback.
|
||||
pub fn native_text_metrics(self, character: char) -> Option<(i64, i64, i64, i64)> {
|
||||
let slot = match character {
|
||||
'Γ' => '\0',
|
||||
'ff' => '\u{b}',
|
||||
'fi' => '\u{c}',
|
||||
'fl' => '\u{d}',
|
||||
'ffi' => '\u{e}',
|
||||
'ffl' => '\u{f}',
|
||||
c if c.is_ascii() => c,
|
||||
_ => return None,
|
||||
};
|
||||
let f = self.metrics();
|
||||
if f.char_info(slot)?.width_index == 0 {
|
||||
return None;
|
||||
}
|
||||
Some((f.width(slot), f.height(slot), f.depth(slot), f.italic(slot)))
|
||||
}
|
||||
|
||||
pub fn width(&self, character: char) -> i64 {
|
||||
if matches!(
|
||||
*self,
|
||||
@@ -309,6 +328,11 @@ impl Cmr10Metrics {
|
||||
if width > 0 { width } else { 327_680 }
|
||||
}
|
||||
|
||||
/// TeX's ex unit is fontdimen5, which can differ from the ink height of x.
|
||||
pub fn x_height(&self) -> i64 {
|
||||
self.metrics().x_height()
|
||||
}
|
||||
|
||||
pub fn height(&self, character: char) -> i64 {
|
||||
if matches!(
|
||||
*self,
|
||||
@@ -391,7 +415,16 @@ impl Cmr10Metrics {
|
||||
}
|
||||
|
||||
pub fn ligature(&self, left: char, right: char) -> Option<(char, char)> {
|
||||
self.metrics().ligature(left, right)
|
||||
let slot = self.metrics().ligature_slot(left, right)?;
|
||||
let unicode = match slot {
|
||||
11 => 'ff',
|
||||
12 => 'fi',
|
||||
13 => 'fl',
|
||||
14 => 'ffi',
|
||||
15 => 'ffl',
|
||||
_ => return None,
|
||||
};
|
||||
Some((unicode, char::from(slot)))
|
||||
}
|
||||
|
||||
pub fn kern(&self, left: char, right: char) -> i64 {
|
||||
|
||||
Reference in new issue
Block a user