@@ -166,8 +166,8 @@ sizeInPoints s = (pxXf * 72 / dpiXf, pxYf * 72 / dpiYf)
166166-- | Calculate (height, width) in points, considering the desired dimensions in the
167167-- attribute, while falling back on the image file's dpi metadata if no dimensions
168168-- are specified in the attribute (or only dimensions in percentages).
169- desiredSizeInPoints :: WriterOptions -> Attr -> ImageSize -> (Double , Double )
170- desiredSizeInPoints opts attr s =
169+ desiredSizeInPoints :: WriterOptions -> Attr -> Maybe Integer -> ImageSize -> (Double , Double )
170+ desiredSizeInPoints opts attr pageWidthPoints' s =
171171 case (getDim Width , getDim Height ) of
172172 (Just w, Just h) -> (w, h)
173173 (Just w, Nothing ) -> (w, w / ratio)
@@ -176,7 +176,11 @@ desiredSizeInPoints opts attr s =
176176 where
177177 ratio = fromIntegral (pxX s) / fromIntegral (pxY s)
178178 getDim dir = case dimension dir attr of
179- Just (Percent _) -> Nothing
179+ Just (Percent a) ->
180+ case (dir, pageWidthPoints') of
181+ (Width , Just pageWidthPoints) ->
182+ Just $ fromIntegral pageWidthPoints * a
183+ _ -> Nothing
180184 Just dim -> Just $ inPoints opts dim
181185 Nothing -> Nothing
182186
0 commit comments