commit ce5f84ff02e04a10d345776571ae0a2439b09e8f Author: Thibaut Cuvelier <tcuvel...@lyx.org> Date: Mon May 20 16:59:46 2024 +0200
XHTML: in InsetGraphics, use the bounding box that LyX computes for each image instead of using the scale. --- src/insets/InsetGraphics.cpp | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/src/insets/InsetGraphics.cpp b/src/insets/InsetGraphics.cpp index d4d0fd7049..1d19507d00 100644 --- a/src/insets/InsetGraphics.cpp +++ b/src/insets/InsetGraphics.cpp @@ -1086,17 +1086,24 @@ docstring InsetGraphics::xhtml(XMLStream & xs, OutputParams const & op) const bool const haveheight = !params().height.zero(); if (havewidth || haveheight) { if (havewidth) - imgstyle += "width: " + params().width.asHTMLString() + ";"; + imgstyle = "width: " + params().width.asHTMLString() + ";"; if (haveheight) imgstyle += " height: " + params().height.asHTMLString() + ";"; } else if (params().scale != "100") { - // The `scale` CSS property is supposed to be used for responsive - // designs, but it behaves mostly as LyX. The only problem is that - // the image's bounding box is not scaled. (As opposed to a width, - // which is a percentage of the HTML container: the meaning of the - // percentage is completely different, but the bounding box has the - // right size.) - imgstyle = "scale: " + params().scale + "%;"; + // Use the scale on the bounding box. + char* endPtr; + double const scale = strtod(params().scale.c_str(), &endPtr); + if (*endPtr == '\0') { // Parsing was possible. + Length width = params().width; + width.value(scale * width.value()); + Length height = params().height; + height.value(scale * height.value()); + + imgstyle = "width: " + width.asHTMLString() + "; "; + imgstyle += "height: " + height.asHTMLString() + ";"; + } + // Otherwise, failure to parse the scale: no information to pass on + // to the HTML output. } if (!imgstyle.empty()) imgstyle = "style='" + imgstyle + "' "; -- lyx-cvs mailing list lyx-cvs@lists.lyx.org http://lists.lyx.org/mailman/listinfo/lyx-cvs