Fix PDF transform (#2850)

This commit is contained in:
Sébastien d'Herbais de Thun 2023-12-04 14:24:05 +01:00 committed by GitHub
parent b8b1a92151
commit f5c90c8714
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 22 additions and 2 deletions

View File

@ -1,7 +1,7 @@
use ecow::eco_format;
use pdf_writer::types::{ColorSpaceOperand, PaintType, TilingType};
use pdf_writer::{Filter, Finish, Name, Rect};
use typst::layout::{Abs, Transform};
use typst::layout::{Abs, Ratio, Transform};
use typst::util::Numeric;
use typst::visualize::{Pattern, RelativeTo};
@ -73,7 +73,9 @@ pub(crate) fn write_patterns(ctx: &mut PdfContext) {
resources_map.finish();
tiling_pattern
.matrix(transform_to_array(*transform))
.matrix(transform_to_array(
transform.post_concat(Transform::scale(Ratio::one(), -Ratio::one())),
))
.filter(Filter::FlateDecode);
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 343 B

View File

@ -0,0 +1,18 @@
// Tests that simple patterns work.
---
#set page(width: auto, height: auto, margin: 0pt)
#let pat = pattern(size: (10pt, 10pt), line(stroke: 4pt, start: (0%, 0%), end: (100%, 100%)))
#rect(width: 50pt, height: 50pt, fill: pat)
---
#set page(width: auto, height: auto, margin: 0pt)
#let pat = pattern(size: (10pt, 10pt), {
place(line(stroke: 4pt, start: (0%, 0%), end: (100%, 100%)))
place(line(stroke: 4pt, start: (100%,0%), end: (200%, 100%)))
place(line(stroke: 4pt, start: (0%,100%), end: (100%, 200%)))
place(line(stroke: 4pt, start: (-100%,0%), end: (0%, 100%)))
place(line(stroke: 4pt, start: (0%,-100%), end: (100%, 0%)))
})
#rect(width: 50pt, height: 50pt, fill: pat)