File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -173,7 +173,9 @@ fn render_path_partial(
173173
174174 if stroke {
175175 if let Some ( stroke) = & path. stroke {
176- content. set_line_width ( ctx. c . px_to_pt ( stroke. width . get ( ) ) ) ;
176+ content. set_line_width (
177+ ctx. c . px_to_pt ( stroke. width . get ( ) * ctx. c . compute_scale ( ) ) ,
178+ ) ;
177179
178180 match stroke. linecap {
179181 LineCap :: Butt => content. set_line_cap ( LineCapStyle :: ButtCap ) ,
Original file line number Diff line number Diff line change @@ -184,6 +184,22 @@ impl CoordToPdf {
184184 self . transform . apply ( point. 0 , point. 1 )
185185 }
186186
187+ /// Compute the scale (e.g. to adapt the stroke width).
188+ pub fn compute_scale ( & self ) -> f64 {
189+ let mut complete_transform = Transform :: new_scale ( self . factor_x , self . factor_y ) ;
190+ complete_transform. append ( & self . transform ) ;
191+ let ( x_scale, y_scale) = complete_transform. get_scale ( ) ;
192+
193+ if x_scale. is_finite ( ) && y_scale. is_finite ( ) {
194+ let scale = x_scale. max ( y_scale) ;
195+ if scale > 0.0 {
196+ return scale;
197+ }
198+ }
199+
200+ 1.0
201+ }
202+
187203 /// Set a pre-transformation, overriding the old one.
188204 pub fn concat_transform ( & mut self , add_transform : Transform ) -> Transform {
189205 let old = self . transform . clone ( ) ;
You can’t perform that action at this time.
0 commit comments