Implement XeTeX OpenType slant and transformed PDF text positioning

This commit is contained in:
gloamxun committed 2026-11-26 10:43:04 +08:00
1 parent 330ecdd03c
commit 45ea5d4297
6 files changed
+152 -44

No files matched your search

+7 -2
View File
@@ -409,9 +409,14 @@ impl SourceMap {
let scale = |value: i64| value * size / font.size;
let ascent = scale(font.ascent);
let descent = scale(font.descent);
let [_, slant] = font.paint_transform();
let top_offset = slant * ascent as f64;
let bottom_offset = -slant * descent as f64;
let left = top_offset.min(bottom_offset).floor() as i64;
let right = top_offset.max(bottom_offset).ceil() as i64;
Some((PaintKind::OpenTypeGlyph { font: font.id.index(), glyph: *glyph }, Bounds {
x: x + advance.min(&0), y: y - ascent,
width: advance.abs(), height: ascent + descent,
x: x + advance.min(&0) + left, y: y - ascent,
width: advance.abs() + right - left, height: ascent + descent,
}))
}
DisplayItem::Rule {