Shape and render explicit OpenType fonts in native Unicode jobs
This commit is contained in:
1 parent
3caf1eced2
commit
70822cbd94
33 files changed
+1255
-80
No files matched your search
@@ -294,3 +294,46 @@ fn shipped_pdf_spaces_take_a_real_font_slot_in_output_order() {
|
||||
}
|
||||
fs::remove_dir_all(work).unwrap();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn unicode_job_shapes_file_font_and_exports_the_actual_glyphs() {
|
||||
let p = directory();
|
||||
let face = PathBuf::from(env!("CARGO_MANIFEST_DIR"))
|
||||
.join("vendor/printpdf/assets/fonts/RobotoMedium.ttf");
|
||||
fs::copy(face, p.join("actual.ttf")).unwrap();
|
||||
fs::write(
|
||||
p.join("probe.tex"),
|
||||
r#"\catcode123=1 \catcode125=2
|
||||
\pdfcompresslevel=0 \pdfobjcompresslevel=0
|
||||
\font\body="[actual.ttf]" at 10pt
|
||||
\shipout\hbox{\body AV office naïve}
|
||||
\end"#,
|
||||
)
|
||||
.unwrap();
|
||||
let result = Command::new(env!("CARGO_BIN_EXE_texrra"))
|
||||
.args([
|
||||
"native", "--job", "--initex", "--etex", "--input-profile", "unicode",
|
||||
"--input-policy", "project", "--layout-manifest", "layout.json", "probe.tex",
|
||||
"native.pdf",
|
||||
])
|
||||
.env("TEXRRA_STATE_DIR", p.join("state"))
|
||||
.current_dir(&p)
|
||||
.output()
|
||||
.unwrap();
|
||||
assert!(result.status.success(), "{}", String::from_utf8_lossy(&result.stderr));
|
||||
let layout: serde_json::Value =
|
||||
serde_json::from_slice(&fs::read(p.join("layout.json")).unwrap()).unwrap();
|
||||
let glyphs = layout["pages"][0]["glyphs"].as_array().unwrap();
|
||||
let text: String = glyphs.iter().map(|glyph| glyph["text"].as_str().unwrap()).collect();
|
||||
assert_eq!(text, "AVofficenaïve");
|
||||
assert!(glyphs.iter().any(|glyph| glyph["text"] == "fi" && glyph["glyph"] == 420));
|
||||
assert!(glyphs.iter().all(|glyph| glyph["resource"]["path"].as_str().unwrap().ends_with("actual.ttf")));
|
||||
let map = layout["source_map"]["pages"][0]["entries"].as_array().unwrap();
|
||||
assert_eq!(map.len(), glyphs.len());
|
||||
let pdf = fs::read(p.join("native.pdf")).unwrap();
|
||||
let pdf = String::from_utf8_lossy(&pdf);
|
||||
assert!(pdf.contains("/Subtype /CIDFontType2"));
|
||||
assert!(pdf.contains("/FontFile2"));
|
||||
assert!(pdf.contains("/ToUnicode"));
|
||||
fs::remove_dir_all(p).unwrap();
|
||||
}
|
||||
Reference in new issue
Block a user