Re: [Sugar-devel] Handling of SVG in Sugar/Sugarizer

2020-08-26 Thread Lionel Laské
Le mer. 26 août 2020 à 07:34, James Cameron  a écrit :

>
> > Hmmm. Are you sure you should not define a  tag in the
> SVG
> > file and reference #myid in the  tag?
>
> I don't know, but I don't think so.  There's no HTML used by Sugar in
> the steps to read and render an SVG file.
>
> It's not related to HTML, it's related to the XML tag  in SVG.
I think that the  tag in SVG should reference a part of another SVG,
not a whole SVG.
It's why you should reference a specific  id in the targeted SVG
file.
In my sample.





> I've been unable to make it work.
>
> Command line test case;
>
> cat > test.css < * {
> width: 100px;
> height: 100px;
> --stroke-color: blue;
> --fill-color: cyan;
> }
> EOF
>
> rsvg-convert --format=png --output=test.png --stylesheet=test.css
> abcd-icon2.svg
>
> Result is PNG of size 55 x 55 pixels, with no stroke or fill colour.
>
> I don't know what to use as a selector.
>
> Or the Rust CSS implementation doesn't handle var.
>
>
Sound like there is an open issue on this in RSVG library:
https://gitlab.gnome.org/GNOME/librsvg/-/issues/459

 Lionel.
___
Sugar-devel mailing list
Sugar-devel@lists.sugarlabs.org
http://lists.sugarlabs.org/listinfo/sugar-devel


Re: [Sugar-devel] Handling of SVG in Sugar/Sugarizer

2020-08-25 Thread Lionel Laské
Le mar. 25 août 2020 à 06:51, James Cameron  a écrit :

>
> To help answer that, I've prepared a fork of Hello World with the
> sugar3.graphics.icon module inline.
>
> https://github.com/sugarlabs/hello-world/tree/test-svg-css
>
>
Nice!


> Next, I need a sample SVG file with CSS file in the form you plan to
> use.
>
>
You could find at set of new icons here:
https://github.com/llaske/svgstudy/tree/master/icons/new


> I'm not sure what the next step is, but perhaps Rsvg library has code
> already to do this.
>
> I've tried with an SVG external source, but the test fails to render.
>
> https://github.com/sugarlabs/hello-world/tree/test-svg-css-external-source
>

Perhaps I need to set the base uri.
>
>
Hmmm. Are you sure you should not define a  tag in the
SVG file and reference #myid in the  tag?
It's the way I'm doing. See in my test page here:
https://github.com/llaske/svgstudy/blob/master/icons/new/abcd-icon2.svg?short_path=f320e6c#L17
https://github.com/llaske/svgstudy/blob/master/test.html#L355

BTW I think it's better to do this step by step:
- Use CSS variables with a CSS style sheet
- Then once it works, try to use SVG external source



> https://lazka.github.io/pgi-docs/#Rsvg-2.0/classes/Handle.html#Rsvg.Handle
>
> There is a new set_stylesheet function in Rsvg 2.48 we might use, if
> the Python bindings actually work.
>

Yes, it seems to do the job.


Interesting, thanks.  I've not used Inkscape seriously yet.  I had
> thought the original SVG files should be kept separate to the
> transformed files.
>
>
No, it's better to have only one file to maintain.

Regards.

Lionel
___
Sugar-devel mailing list
Sugar-devel@lists.sugarlabs.org
http://lists.sugarlabs.org/listinfo/sugar-devel


Re: [Sugar-devel] Handling of SVG in Sugar/Sugarizer

2020-08-21 Thread Lionel Laské
I agree with the change.
>
>
Good to hear.


> For your interest, Sugar loads SVG and changes the colours in
> sugar3.graphics.icon _SVGLoader;
>
>
> https://github.com/sugarlabs/sugar-toolkit-gtk3/blob/master/src/sugar3/graphics/icon.py#L116
>

Thanks for the link. The question is: is it possible to replace this code
by native call of SVG features.


> In your study you say;
>
> "The SVG file should be updated manually" ... in some cases
> sugariconify can be used to update the file automatically.
>
> https://github.com/sugarlabs/sugariconify
>
>
This tool transforms an existing SVG file to allow it to use it in Sugar.
But once transformed it's no longer possible to edit transformed colors in,
for example, Inkscape.
My idea is to have a way to edit the transformed file in Inkscape like if
it was a "standard" SVG file.
With the new CSS representation I propose It should be doable in Inkscape
because Inkscape 1.0 seems to support CSS files [3].
But unfortunately I can't figure out how to do it :-(

  Lionel.

[3] https://wiki.inkscape.org/wiki/index.php/Release_notes/1.0
___
Sugar-devel mailing list
Sugar-devel@lists.sugarlabs.org
http://lists.sugarlabs.org/listinfo/sugar-devel


Re: [Sugar-devel] Handling of SVG in Sugar/Sugarizer

2020-08-20 Thread James Cameron
Thanks Lionel,

I agree with the change.

For your interest, Sugar loads SVG and changes the colours in
sugar3.graphics.icon _SVGLoader;

https://github.com/sugarlabs/sugar-toolkit-gtk3/blob/master/src/sugar3/graphics/icon.py#L116

In your study you say;

"The SVG file should be updated manually" ... in some cases
sugariconify can be used to update the file automatically.

https://github.com/sugarlabs/sugariconify

On Thu, Aug 20, 2020 at 10:55:13PM +0200, Lionel Laské wrote:
> 
> Hi all,
> 
> From the beginning, the handling of SVG files in Sugar rely on Entity fields 
> in
> the header of files. Something like:
> 
>  "[1]http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd; [
> 
> 
> ]>
> 
> This mechanism is described on [1]. Sugarizer rely on the same mechanism to
> colorize icons.
> 
> Because this "hack" has some drawbacks - specifically on performance - I think
> to change it in a future version of Sugarizer to use native SVG/CSS features
> instead. I've done a detailed study here [2] to explain how it could work.
> 
> Of course it will generate compatibility issues but it would be nice to see if
> the same thing could be done in Python too. I'm not a Python/Gtk specialist 
> but
> will be happy to help on it.
> 
> Regards.
> 
>     Lionel.
> 
> [1] [2]https://wiki.sugarlabs.org/go/Development_Team/Almanac/Making_Icons
> [2] [3]https://github.com/llaske/svgstudy
> 
> References:
> 
> [1] http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd
> [2] https://wiki.sugarlabs.org/go/Development_Team/Almanac/Making_Icons
> [3] https://github.com/llaske/svgstudy

> ___
> Sugar-devel mailing list
> Sugar-devel@lists.sugarlabs.org
> http://lists.sugarlabs.org/listinfo/sugar-devel


-- 
James Cameron
http://quozl.netrek.org/
___
Sugar-devel mailing list
Sugar-devel@lists.sugarlabs.org
http://lists.sugarlabs.org/listinfo/sugar-devel


Re: [Sugar-devel] Handling of SVG in Sugar/Sugarizer

2020-08-20 Thread Walter Bender
Very interesting. I hadn't known that svg had css support these days. Would
make sense to take advantage.

On Thu, Aug 20, 2020, 4:55 PM Lionel Laské  wrote:

>
> Hi all,
>
> From the beginning, the handling of SVG files in Sugar rely on Entity
> fields in the header of files. Something like:
>
>  "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd; [
>   
>   
> ]>
>
> This mechanism is described on [1]. Sugarizer rely on the same mechanism
> to colorize icons.
>
> Because this "hack" has some drawbacks - specifically on performance - I
> think to change it in a future version of Sugarizer to use native SVG/CSS
> features instead. I've done a detailed study here [2] to explain how it
> could work.
>
> Of course it will generate compatibility issues but it would be nice to
> see if the same thing could be done in Python too. I'm not a Python/Gtk
> specialist but will be happy to help on it.
>
> Regards.
>
> Lionel.
>
>
> [1] https://wiki.sugarlabs.org/go/Development_Team/Almanac/Making_Icons
> [2] https://github.com/llaske/svgstudy
> ___
> Sugar-devel mailing list
> Sugar-devel@lists.sugarlabs.org
> http://lists.sugarlabs.org/listinfo/sugar-devel
>
___
Sugar-devel mailing list
Sugar-devel@lists.sugarlabs.org
http://lists.sugarlabs.org/listinfo/sugar-devel


[Sugar-devel] Handling of SVG in Sugar/Sugarizer

2020-08-20 Thread Lionel Laské
Hi all,

>From the beginning, the handling of SVG files in Sugar rely on Entity
fields in the header of files. Something like:

http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd; [


]>

This mechanism is described on [1]. Sugarizer rely on the same mechanism to
colorize icons.

Because this "hack" has some drawbacks - specifically on performance - I
think to change it in a future version of Sugarizer to use native SVG/CSS
features instead. I've done a detailed study here [2] to explain how it
could work.

Of course it will generate compatibility issues but it would be nice to see
if the same thing could be done in Python too. I'm not a Python/Gtk
specialist but will be happy to help on it.

Regards.

Lionel.


[1] https://wiki.sugarlabs.org/go/Development_Team/Almanac/Making_Icons
[2] https://github.com/llaske/svgstudy
___
Sugar-devel mailing list
Sugar-devel@lists.sugarlabs.org
http://lists.sugarlabs.org/listinfo/sugar-devel