Skip to content

Commit

Permalink
Add new TranslateRotate matrix for fonts
Browse files Browse the repository at this point in the history
  • Loading branch information
fschutt committed Dec 8, 2021
1 parent a7fe7a2 commit 0c770ed
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
13 changes: 12 additions & 1 deletion src/types/plugins/graphics/ctm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ pub enum TextMatrix {
/// Text translate matrix, used for indenting (transforming) text
/// (different to regular text placement)
Translate(Mm, Mm),
/// Combined translate + rotate matrix
TranslateRotate(Mm, Mm, f64),
}

impl Into<[f64; 6]> for TextMatrix {
Expand All @@ -48,7 +50,16 @@ impl Into<[f64; 6]> for TextMatrix {
let y_pt: Pt = y.into();
[ 1.0, 0.0, 0.0, 1.0, x_pt.0, y_pt.0 ]
}
Rotate(rot) => { let rad = (360.0 - rot).to_radians(); [rad.cos(), -rad.sin(), rad.sin(), rad.cos(), 0.0, 0.0 ] /* cos sin -sin cos 0 0 cm */ }
Rotate(rot) => {
let rad = (360.0 - rot).to_radians();
[rad.cos(), -rad.sin(), rad.sin(), rad.cos(), 0.0, 0.0 ] /* cos sin -sin cos 0 0 cm */
},
TranslateRotate(x, y, rot) => {
let rad = (360.0 - rot).to_radians();
let x_pt: Pt = x.into();
let y_pt: Pt = y.into();
[rad.cos(), -rad.sin(), rad.sin(), rad.cos(), x_pt.0, y_pt.0 ] /* cos sin -sin cos x y cm */
}
}
}
}
Expand Down
4 changes: 3 additions & 1 deletion src/types/plugins/graphics/xobject.rs
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,9 @@ impl Into<lopdf::Stream> for ImageXObject {
params.into_iter().for_each(|param| dict.set(param.0, param.1));
}

lopdf::Stream::new(dict, self.image_data)
let mut stream = lopdf::Stream::new(dict, self.image_data);
stream.compress();
stream
}
}

Expand Down

0 comments on commit 0c770ed

Please sign in to comment.