Allocate native automatic font expansion instances
This commit is contained in:
1 parent
2d036b807e
commit
9b80a782cf
11 files changed
+288
-107
No files matched your search
@@ -68,6 +68,10 @@ pub struct NativeFont {
|
||||
/// outline program are the original font at the original point size.
|
||||
#[serde(default, skip_serializing_if = "unexpanded")]
|
||||
pub expansion: i32,
|
||||
/// Metrics from a TFM loaded before it joined an automatic expansion
|
||||
/// family. The device embeds the base program but moves by these widths.
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
pub(crate) layout_metrics: Option<Arc<TfmMetrics>>,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
pub letter_spacing: Option<LetterspaceProgram>,
|
||||
#[serde(default, skip_serializing_if = "std::ops::Not::not")]
|
||||
@@ -91,12 +95,23 @@ impl NativeFont {
|
||||
pub fn size_sp(&self) -> i64 {
|
||||
self.metrics.size_sp()
|
||||
}
|
||||
pub(crate) fn layout_metrics(&self) -> &TfmMetrics {
|
||||
self.layout_metrics.as_deref().unwrap_or(&self.metrics)
|
||||
}
|
||||
pub fn advance(&self, slot: u8) -> i64 {
|
||||
let width = self.metrics.width(char::from(slot));
|
||||
let width = self.layout_metrics().width(char::from(slot));
|
||||
if self.layout_metrics.is_some() {
|
||||
width
|
||||
} else {
|
||||
self.horizontal(width)
|
||||
}
|
||||
}
|
||||
pub(crate) fn horizontal(&self, value: i64) -> i64 {
|
||||
if self.expansion == 0 {
|
||||
return width;
|
||||
value
|
||||
} else {
|
||||
crate::pdf_device::magnify(value, 1000 + self.expansion)
|
||||
}
|
||||
crate::pdf_device::magnify(width, 1000 + self.expansion)
|
||||
}
|
||||
pub(crate) fn same_base(&self, other: &Self) -> bool {
|
||||
std::ptr::eq(self, other)
|
||||
|
||||
Reference in new issue
Block a user