SVG: scaling if no width/height is given

Regina Henschel rb.henschel at t-online.de
Sun Jun 23 15:13:43 PDT 2013


Hi Christina,

Regina Henschel schrieb:
> Hi Christina,
>
> Regina Henschel schrieb:
>> Hi Christina,
>>
>> I have seen you patch at Gerrit now.
>>
>> I think, that SvgAspectRatio::createLinearMapping is the wrong place to
>> constrain the scaling because this method is used in svgimagenode.cxx
>> and svgstyleattributes.cxx too. I think, that the decision whether to
>> keep aspect ratio or not, should be made in the node itself. Have you
>> tried to set the default settings explicitly in the constructor of
>> SvgSvgNode?
>
> "constructor" is a bad idea, because it would effect inner svg-nodes too.

I have looked a little bit more around and did some tests with svg-files 
in the browser.

(1)
There is
http://www.w3.org/TR/SVG/struct.html#SVGElement
and in the section "preserveAspectRatio" the rule,
"If the attribute is not specified, then the effect is as if a value of 
'xMidYMid meet' were specified."

I have made some test in the browser and as far as I see, when for an 
inner svg element the attribute preserveAspectRatio is missing, then it 
does not use the attribute of the parent svg element, but uses the default.

So in the meantime I think, that it is correct to set the attribute 
value 'xMidYMid meet' in the constructor. If the attribute 
preserveAspectRatio exists, then SvgSvgNode::parseAttribute will 
actualize this value.

With this change you will get already keeping ratio.

(2)
http://www.w3.org/TR/SVG/coords.html#IntrinsicSizing
"If either/both of the ‘width’ and ‘height’ of the rootmost ‘svg’ 
element are in percentage units (or omitted), the aspect ratio is 
calculated from the width and height values of the ‘viewBox’ specified 
for the current SVG document fragment."

Therefore I think it is wrong, that DIN A4 is set as default, but the 
viewBox has to be used.

Kind regards
Regina









More information about the LibreOffice mailing list