2

I am trying to embed an external stylesheet in an svgz file. I can embed it just fine into the svg file but it seems to be stripped out when I save as svgz. Any help would be appreciated here is the code from the svg file:

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">  
<?xml-stylesheet type="text/css" href="/assets/styles/stylesheets/web-fonts.css" ?>
<svg xmlns="http://www.w3.org/2000/svg">  

I am using Illustrator for saving out the files

James A Mohler
  • 11,060
  • 15
  • 46
  • 72
Zanderi
  • 907
  • 9
  • 15

2 Answers2

2

I don't know whether SVGZ will work with CSS but SVGZ is a SVG compressed with GZIP.

You can change SVG to SVGZ this way:

  1. get SVG file : example.svg
  2. remove extension .svg : example
  3. compress using GZIP : example.gz
  4. change extenson to .svgz : example.svgz
furas
  • 134,197
  • 12
  • 106
  • 148
  • Turns out that Illustrator strips out the stylesheet, I was able to install 7zip and in a round-about way gzip and send it to myself. If you know of a better tool or way to gzip a file on windows I would be extremely appreciative to you. 7zip forces you to compress and email you can't simply compress the file. – Zanderi Jul 12 '13 at 15:45
  • 1
    I use linux but I was using windows and 7zip long time ago and it seemed to me that 7zip can gzip without mailing. Maybe in options you can change it. Or I'm wrong. You can use (in command line or batch) [gzip from GnuWin32](http://gnuwin32.sourceforge.net/packages/gzip.htm) `gzip < example.svg > example.svgz`. I test SVGZ in [Inkscape](http://inkscape.org/) and there is no need to remove extension .svg before compressing. – furas Jul 12 '13 at 20:58
  • After testing thoroughly I found that it is indeed possible to embed the style sheets within svgz but you have to use another method to compress the files other than illustrator as illustrator will strip the reference. Also in order for the reference to work in mobile it is case sensitive. I ended up using http://gnuwin32.sourceforge.net/packages/gzip.htm to compress my files and renamed the extension as furas recommended and it works fantastic – Zanderi Jul 26 '13 at 18:52
0

The confusion about 7zip seems to be due to how it names things. Only the email options use the word "compress". Use the "Add to archive" option to compress a file without emailing it.

Like furas, I use Inkscape but want to further optimize the SVGs (e.g. remove the metadata element and its contents which Inkscape seems to always add), so can't use it to generate the SVGZ files.

(As a new user, I have to post a new answer instead of a comment on the existing one.)

Kravimir
  • 691
  • 1
  • 6
  • 7