Match XDV PDF text cursor and Type 1 descriptor metrics

This commit is contained in:
gloamxun committed 2026-11-26 13:49:41 +08:00
1 parent eb0afccc03
commit bd840df538
7 files changed
+144 -19

No files matched your search

+12 -2
View File
@@ -31,6 +31,7 @@ impl NativeText {
paint: &crate::native_font::NativeFontPaint,
slot: u8,
height: i64,
xdv_origin: Option<i64>,
digits: u8,
space: Option<SpaceUse>,
dedicated: Option<&ResolvedSpaceFont>,
@@ -38,12 +39,19 @@ impl NativeText {
let first = text.is_none();
let state = text.get_or_insert_with(|| {
out.push_str("BT\n");
if let Some(origin) = xdv_origin {
out.push_str(&format!(
"1 0 0 1 {} {} Tm\n",
print_sp(origin, digits),
print_sp(height - origin, digits),
));
}
Self {
font: None,
effective_size: 0,
expansion: 0,
v: height,
start_h: 0,
v: xdv_origin.unwrap_or(height),
start_h: xdv_origin.unwrap_or(0),
delta_h: 0,
opened: false,
}
@@ -187,6 +195,7 @@ impl NativeText {
&dedicated.paint,
b' ',
height,
None,
digits,
None,
None,
@@ -375,6 +384,7 @@ pub(crate) fn plan_spaces(
paint,
*slot,
page.height,
None,
digits,
space,
plan.dedicated.as_ref(),