Match pdfTeX graphics-origin movement thresholds
This commit is contained in:
1 parent
ecb0f60960
commit
330c4bde51
7 files changed
+195
-75
No files matched your search
@@ -288,6 +288,55 @@ fn native_pdf_text_uses_the_rounded_origin_after_positioned_literals() {
|
||||
fs::remove_dir_all(work).unwrap();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn pdftex_origin_uses_the_two_axis_threshold_for_literals_and_rules() {
|
||||
let work = directory();
|
||||
let source = work.join("origin.tex");
|
||||
fs::write(
|
||||
&source,
|
||||
r"\catcode123=1 \catcode125=2 \catcode35=6 \catcode37=14
|
||||
\pdfoutput=1 \pdfdecimaldigits=3 \pdfpagewidth=200pt \pdfpageheight=200pt
|
||||
\pdfhorigin=0sp \pdfvorigin=0sp
|
||||
\def\place#1#2#3{\hbox to0sp{\kern#1sp\lower#2sp\hbox{#3}\hss}}
|
||||
\shipout\hbox{%
|
||||
\place{33}{13107200}{\pdfliteral{1 1 m 40 1 l S}}%
|
||||
\place{33}{13107528}{\vrule width20pt height655sp depth0sp}%
|
||||
\place{66}{13107167}{\pdfliteral{1 2 m 40 2 l S}}%
|
||||
\place{0}{13107200}{\pdfliteral{1 3 m 40 3 l S}}}
|
||||
\end",
|
||||
)
|
||||
.unwrap();
|
||||
let result = native_fonts::command()
|
||||
.args(["native", "--job", "--initex", "--etex"])
|
||||
.arg(&source)
|
||||
.arg("origin.pdf")
|
||||
.current_dir(&work)
|
||||
.output()
|
||||
.unwrap();
|
||||
assert!(
|
||||
result.status.success(),
|
||||
"{}",
|
||||
String::from_utf8_lossy(&result.stderr)
|
||||
);
|
||||
let pdf = lopdf::Document::load(work.join("origin.pdf")).unwrap();
|
||||
let contents = pdf.get_page_content(pdf.get_pages()[&1]).unwrap();
|
||||
let stream = lopdf::content::Content::decode(&contents).unwrap();
|
||||
let ordered: Vec<_> = stream.operations.iter()
|
||||
.filter(|op| matches!(op.operator.as_str(), "cm" | "S"))
|
||||
.collect();
|
||||
let operators: Vec<_> = ordered.iter().map(|op| op.operator.as_str()).collect();
|
||||
assert_eq!(operators, ["S", "S", "cm", "S", "cm", "S"]);
|
||||
assert!(matches!(
|
||||
&ordered[2].operands[4..],
|
||||
[lopdf::Object::Real(0.001), lopdf::Object::Real(0.001)]
|
||||
));
|
||||
assert!(matches!(
|
||||
&ordered[4].operands[4..],
|
||||
[lopdf::Object::Real(-0.001), lopdf::Object::Real(-0.001)]
|
||||
));
|
||||
fs::remove_dir_all(work).unwrap();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn shipped_pdf_spaces_take_a_real_font_slot_in_output_order() {
|
||||
let work = directory();
|
||||
|
||||
Reference in new issue
Block a user