Random notes about svg

Fonts

edit

Use "serif", "sans-serif", "monospace" as font-family, instead of specific names such as "Times" and "AvantGarde"

Embedded images

edit

Raster images have to be embedded in the svg image, not referred. Instead of:

<image width="500" height="300" xlink:href="imagename.png">

use:

<image width="500" height="300" xlink:href="data:image/png;base64,...">

replacing ... with the base64 encoding of the raster image. The comma after "base64" is necessary and is not part of the encoding of the raster image.

The following awk script performs this conversion (run as awk -f thisprogram imagename.png):

function x(l) {
  n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/_";
  return substr(n,l+1,1);
}

function v() {
  q=""
  for(n=0; n<256; n++) {
    q=q sprintf("%c",n);
  }
  return q;
}

function p(c) {
  return index(q,c)-1;
}

function encodethree(s) {
  a=p(substr(s,1,1));
  b=p(substr(s,2,1));
  c=p(substr(s,3,1));
  if( length(s)==0 )
    return;
  else if( length(s)==1 )
    printf("%s%s==",x(rshift(a,2)),x(lshift(a%4,4)));
  else if( length(s)==2 )
    printf("%s%s%s=",
      x(lshift(a%4,4)),
      x(or(lshift(a%4,4),rshift(b,4))),
      x(lshift(b%16,2)));
  else
    printf("%s%s%s%s",
      x(rshift(a,2)),
      x(or(lshift(and(a,3),4),rshift(b,4))),
      x(or(lshift(and(b,15),2),rshift(c,6))),
      x(and(c,63)));
}


BEGIN { r=""; q=v(); il=0; }
{
  s=r $0 "\n";
  len = length(s);
  if(len<3)
    r=s;
  else {
    for(i=1;i+2<=len;i+=3) {
      encodethree(substr(s,i,3));

      il++;
      if( il==18 ) {
        printf("\n");
        il=0;
      }
    }
    r=substr(s,i);
  }
}
END { encodethree(r); }