W3C home > Mailing lists > Public > whatwg@whatwg.org > January 2008

[whatwg] Opera SVG Re: How to use SVG in HTML5?

From: Charles McCathieNevile <chaals@opera.com>
Date: Mon, 28 Jan 2008 18:41:57 +1100
Message-ID: <op.t5mqb70wwxe0ny@widsith.lan>
Hi Vlad,

as I read these, Opera is doing the right thing. Since the SVG you use  
doesn't have a viewBox attribte to say how the thing should fit, it  
creates an "initial viewport" where the size in px that the image element  
gets corresponds to a view in SVG user units. So a 300x100 img shows a  
portion of the SVG that goes from 0,0 (the top left) to 300,100 at the  
bottom right - in other words, only a part of the tiger.

If you add a viewBox then the preserveAspectRatio attribute can be used,  
and has the default value of none, which squeezes the SVG to fit the space  
you give it. Without viewBox the preserveAspectRatio has no effect, since  
there is nothing that says how what size the contents of the SVG should be.

So I don't think there is a bug at all. If you use something like inscape  
that doesn't add a viewBox, your SVG will do what your demos do. We can in  
fact change that in Opera for example by adding a default viewBox of some  
kind, but technically that is in violation of the current specs for SVG up  
to and including 1.2.

I've cc'ed Erik, our SVG lead and the hair of the SVG WG, in case he wants  
to offer anything more, or correct anything I have misunderstood.

cheers

Chaals

On Sat, 26 Jan 2008 00:10:08 +1100, Vlad Alexander (xhtml.com)  
<vlad.alexander at xhtml.com> wrote:

> Hi Charles,
>
> Thanks for looking into this. Here you go:
>
> http://xhtml.com/misc/svg-img1.htm
>
> http://xhtml.com/misc/svg-img2.htm
>
> http://xhtml.com/misc/svg-img3.htm
>
> Regards,
> -Vlad
> http://xhtml.com
>
>
> -------- Original Message --------
> From: Charles McCathieNevile
> Date: 2008-01-24 10:47 PM
>> Hi Vlad,
>>
>> On Fri, 25 Jan 2008 00:50:45 +1100, Vlad Alexander (xhtml.com)
>> <vlad.alexander at xhtml.com> wrote:
>> ...
>>> I tested Opera's support for SVG through the img element and it
>>> incorrectly clips the SVG image. The width and height attributes of
>>> the img element need to set the viewport for the SVG image and scale
>>> the SVG non-uniformly to fit the viewport.
>>
>> What was your test case? Can you share it so we can check whether this
>> is a known problem or issue?
>>
>> cheers
>>
>> Chaals
>>
>
>



-- 
Charles McCathieNevile  Opera Software, Standards Group
     je parle fran?ais -- hablo espa?ol -- jeg l?rer norsk
http://my.opera.com/chaals   Try Opera 9.5: http://snapshot.opera.com
Received on Sunday, 27 January 2008 23:41:57 UTC

This archive was generated by hypermail 2.4.0 : Wednesday, 22 January 2020 16:59:00 UTC