Coordinates with units

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Coordinates with units

Christophe DANG NGOC CHAN
Hello,

I'm not sure this is the right mailing list so please redirect me if I'm at the wrong place.

My issue: the W3C recommandations say, in chapter "Basic Data Types and Interfaces",
section "Basic data types":

"
[…] Its syntax is the same as that for .

[…]


A length is a distance measurement, given as a number along with a unit which may be optional."

So, the following SVG code should be valid:

**********

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">




d="M0 0 L5cm 5cm"
fill="none" stroke="black" stroke-width="1px"
/>



**********

It is validated by https://validator.w3.org/ and is correctly displayed in other browsers,
but *not* in Firefox 52.0.2 (under Windows 7) which shows an empty image.

Is there something wronng with me or is this a bug?

Regards

--
Christophe Dang Ngoc Chan
[hidden email]
_______________________________________________
dev-tech-svg mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-svg
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Coordinates with units

Daniel Holbert-3
On 04/03/2017 02:10 AM, Christophe DANG NGOC CHAN wrote:
> I'm not sure this is the right mailing list so please redirect me if I'm at the wrong place.

Given that this is a possible-Firefox-bug (from your perspective as
someone encountering an issue), then this is one of two right places.

The other place would be in Mozilla's Bugzilla instance:
 https://bugzilla.mozilla.org/enter_bug.cgi?product=Core&component=SVG

But here is fine too, for now.

> A length is a distance measurement, given as a number along with a unit which may be optional."
>
> So, the following SVG code should be valid:
>
> **********
[...]
> d="M0 0 L5cm 5cm"
> fill="none" stroke="black" stroke-width="1px"
> />

It looks like some of your markup got stripped out in your post (see
https://groups.google.com/forum/#!topic/mozilla.dev.tech.svg/E8-vuJvbabg
for what your post ended up looking like).  But I assume you were asking
about a <path> element there, and you're wondering: why do the "cm"
units make that path data invalid.

Is that what you're asking?

The values in the path data are not normal SVG 'length' values --
they're more restricted.  The syntax is given here, for path data:
https://www.w3.org/TR/SVG2/paths.html#TheDProperty

In particular, that spec section says: "All coordinates and lengths
specified within path data must be treated as being in user units in the
current user coordinate system."  ("user units" = unitless values)

> It is validated by https://validator.w3.org/

That site doesn't validate arbitrary attribute values, as far as I know.
It's more for basic validation stuff, like missing close tags.  So its
approval isn't relevant here.  For example, I just tested a document
with <svg width="fish">, and it validated correctly there, even though
"fish" is invalid for the width attribute.

> and is correctly displayed in other browsers,
> but *not* in Firefox 52.0.2 (under Windows 7) which shows an empty image.

That is surprising to me, but it's hard to investigate further since
your testcase's markup didn't make it into your post intact.

Could you link to an actual testcase hosted somewhere on the internet,
or post a demo on http://jsfiddle.net/ ?  (Note: you can just directly
write <svg>...</svg> in the HTML box there and it should just work.)  I
tried making your test code into a demo at
https://jsfiddle.net/k2hfdhdc/ , but Chrome renders it just like Firefox
does -- no path.
_______________________________________________
dev-tech-svg mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-svg
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Coordinates with units

Christophe DANG NGOC CHAN
Hello, 
 
> Message du 03/04/17 17:28
> De : "Daniel Holbert"
>
> On 04/03/2017 02:10 AM, Christophe DANG NGOC CHAN wrote:
> > I'm not sure this is the right mailing list so please redirect me if I'm at the wrong place.
>
> Given that this is a possible-Firefox-bug (from your perspective as
> someone encountering an issue), then this is one of two right places.

OK, thanks.
I prefere to discuss it before declaring a bug that might not be a bug (-:

> > A length is a distance measurement, given as a number along with a unit which may be optional."
> >
> > So, the following SVG code should be valid:
> >
> > **********
> [...]
> > d="M0 0 L5cm 5cm"
> > fill="none" stroke="black" stroke-width="1px"
> > />
>
> It looks like some of your markup got stripped out in your post (see
> https://groups.google.com/forum/#!topic/mozilla.dev.tech.svg/E8-vuJvbabg
> for what your post ended up looking like).

Well, I select "raw text" on my webmail interface…
But the same error occurs when I look in my "sent" box.
I paste it again with a different bracket Unicode character,
but mind that you cannot copy-paste it then:

**********

〈 ?xml version="1.0" encoding="UTF-8" standalone="no"?〉
〈 !DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"〉

〈 svg width="248" height="176" version="1.1"
xmlns="http://www.w3.org/2000/svg"


〈 path
d="M0 0 L5cm 5cm"
fill="none" stroke="black" stroke-width="1px"
/〉

〈 /svg〉

**********


> But I assume you were asking
> about a element there, and you're wondering: why do the "cm"
> units make that path data invalid.
>
> Is that what you're asking?

Indeed

> The values in the path data are not normal SVG 'length' values --
> they're more restricted. The syntax is given here, for path data:
> https://www.w3.org/TR/SVG2/paths.html#TheDProperty
>
> In particular, that spec section says: "All coordinates and lengths
> specified within path data must be treated as being in user units in the
> current user coordinate system." ("user units" = unitless values)

OK, but this is SVG2.
I declared SVG1.1 and I did not see anything like this in the SVG1.1 recommendations,
but maybe it's hidden in a place where I didn't look at.

Additionally, I also noticed that the cm -> px conversion ratio was
1 cm = 37.81 px
whereas it should be 35.43 in SVG1.1, see https://www.w3.org/TR/SVG11/coords.html#Units
but when I declare SVG1.1, I excpect the software to follow the related recomandations.

This can be seen by drawing side by side a line
— the attribute x="1cm" works fine with a line element —
and a path.

E.g.

**********

〈?xml version="1.0" encoding="UTF-8" standalone="no"?>
〈!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">

〈svg width="248" height="176" version="1.1"
xmlns="http://www.w3.org/2000/svg"


〈path
d="M0 0 L70.86 70.86"
fill="none" stroke="black" stroke-width="1px"
/〉

〈line
x1="0.2cm" y1="0" x2="2.2cm" y2="2cm"
fill="none" stroke="black" stroke-width="1px"
/〉

〈/svg〉

**********

> > and is correctly displayed in other browsers,
> > but *not* in Firefox 52.0.2 (under Windows 7) which shows an empty image.
>
> That is surprising to me, but it's hard to investigate further since
> your testcase's markup didn't make it into your post intact.

I tried again and you're right.
I probably made an error during my trials.

> Could you link to an actual testcase hosted somewhere on the internet,
> or post a demo on http://jsfiddle.net/ ? (Note: you can just directly
> write ... in the HTML box there and it should just work.)

I don't know that tool, but here it is:
https://jsfiddle.net/psao0fm4/

Thanks for your answer,

Regards

--
Christophe Dang Ngoc Chan
[hidden email]
_______________________________________________
dev-tech-svg mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-svg
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Coordinates with units

Daniel Holbert-3
On 4/4/17 1:30 AM, Christophe DANG NGOC CHAN wrote:

>> The values in the path data are not normal SVG 'length' values --
>> they're more restricted. The syntax is given here, for path data:
>> https://www.w3.org/TR/SVG2/paths.html#TheDProperty
>>
>> In particular, that spec section says: "All coordinates and lengths
>> specified within path data must be treated as being in user units in the
>> current user coordinate system." ("user units" = unitless values)
>
> OK, but this is SVG2.
> I declared SVG1.1

(SVG2 is just the latest version of the SVG spec, at least from a
browser's perspective. Browsers [Firefox at least, and I think others]
don't change SVG behavior based on the doctype.)

> and I did not see anything like this in the SVG1.1 recommendations,
> but maybe it's hidden in a place where I didn't look at.

It's a bit more buried in that version of the spec -- there's a
definition of the grammar of the afterthought:
https://www.w3.org/TR/SVG11/paths.html#PathDataBNF

> Additionally, I also noticed that the cm -> px conversion ratio was
> 1 cm = 37.81 px
> whereas it should be 35.43 in SVG1.1, see https://www.w3.org/TR/SVG11/coords.html#Units

The spec says no such thing. You're skipping over some key spec text there.

The conversion ratio depends on many factors (e.g. depends on your
screen size & resolution).  SVG does not define a specific conversion
factor -- the section you're quoting *begins with a hypothetical*:

  # suppose that the user agent can determine
  # from its environment that "1px" corresponds
  # to "0.2822222mm" [...]  Then, for all
  # processing of SVG content:
  # [...]
  #  * "1cm" equals "35.43307px"

So -- this spec text is *just an example*. The "suppose" at the
beginning is very important.

> I tried again and you're right.
> I probably made an error during my trials.
>
>> Could you link to an actual testcase hosted somewhere on the internet,
>> or post a demo on http://jsfiddle.net/ ? (Note: you can just directly
>> write ... in the HTML box there and it should just work.)
>
> I don't know that tool, but here it is:
> https://jsfiddle.net/psao0fm4/

OK, it sounds like there's no issue here then.  Thanks for the heads-up
about a potential issue, in any case!
_______________________________________________
dev-tech-svg mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-svg
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Coordinates with units

Christophe DANG NGOC CHAN
Hello, 

I change the order of the topics. 
 
> Message du 04/04/17 18:23
> De : "Daniel Holbert"
>
> > and I did not see anything like this in the SVG1.1 recommendations,
> > but maybe it's hidden in a place where I didn't look at.
>
> It's a bit more buried in that version of the spec -- there's a
> definition of the grammar of the afterthought:
> https://www.w3.org/TR/SVG11/paths.html#PathDataBNF

OK thanks.
It's a way of writing I'm unable to understand so I trust you.
It's a good thing that it's written in English in the SVG2 recommandations (-:

> > Additionally, I also noticed that the cm -> px conversion ratio was
> > 1 cm = 37.81 px
> > whereas it should be 35.43 in SVG1.1, see https://www.w3.org/TR/SVG11/coords.html#Units
>
> The spec says no such thing. You're skipping over some key spec text there.
> […]
> So -- this spec text is *just an example*. The "suppose" at the
> beginning is very important.

OK, I didn't got that point.

But then the "real life" units should be limited to setting the size of the image
and should be forbidden in any kind of coordinates or length inside the image.
Shouldn't it?

I mean I would be less confused, and I guess I'm not the only one.

> (SVG2 is just the latest version of the SVG spec, at least from a
> browser's perspective. Browsers [Firefox at least, and I think others]
> don't change SVG behavior based on the doctype.)

On this general point, I don't agree.
The web browsers should keep the compatibility with old images,
the rendering should not change between several versions of a browser (apart from bug issues).

Regards

--
Christophe Dang Ngoc Chan
[hidden email]
_______________________________________________
dev-tech-svg mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-svg
Loading...