Bind shipped XeLaTeX font maps to native font resources

This commit is contained in:
gloamxun committed 2026-11-28 21:22:51 +08:00
1 parent dcc6a3984c
commit af6466cd98
11 files changed
+482 -25

No files matched your search

+24 -1
View File
@@ -164,6 +164,7 @@ struct NativeSvgGlyph<'a> {
position: [i64; 2],
size: i64,
expansion: i32,
xdv_matrix: crate::native_font::XdvFontMatrix,
slot: u8,
font: &'a str,
glyph: &'a str,
@@ -204,6 +205,7 @@ impl DisplayItem {
position: [*x, *y],
size: *size,
expansion: font.expansion,
xdv_matrix: paint.xdv_matrix,
slot: *slot,
font: paint.program.name(),
glyph: &paint.encoding[usize::from(*slot)],
@@ -549,6 +551,7 @@ impl DisplayList {
position: [x, y],
size,
expansion,
xdv_matrix,
slot,
font,
glyph,
@@ -571,7 +574,27 @@ impl DisplayList {
} else {
String::new()
};
out.push_str(&format!("<g data-font=\"{}\" data-glyph=\"{}\" data-slot=\"{slot}\" aria-label=\"{}\"><path d=\"{}\" transform=\"translate({x:.5} {y:.5}) scale({horizontal_scale:.8} -{scale:.8})\" fill=\"#{:02x}{:02x}{:02x}\"{fill_opacity}/></g>\n", escape(font), escape(glyph), escape(&label), path, fill[0],fill[1],fill[2]));
use std::fmt::Write as _;
write!(
out,
"<g data-font=\"{}\" data-glyph=\"{}\" data-slot=\"{slot}\" aria-label=\"{}\"><path d=\"{}\" transform=\"",
escape(font), escape(glyph), escape(&label), path,
).unwrap();
if xdv_matrix.is_identity() {
write!(out, "translate({x:.5} {y:.5}) scale({horizontal_scale:.8} -{scale:.8})").unwrap();
} else {
let [extend, slant] = xdv_matrix.coefficients();
write!(
out,
"matrix({:.8} 0 {:.8} -{scale:.8} {x:.5} {y:.5})",
horizontal_scale * extend,
scale * slant,
).unwrap();
}
writeln!(
out, "\" fill=\"#{:02x}{:02x}{:02x}\"{fill_opacity}/></g>",
fill[0], fill[1], fill[2],
).unwrap();
}
DisplayItem::OpenTypeGlyph { x, y, size, font, glyph, text, .. } => {
let face = match opentype_faces.entry(font.id) {