You are viewing a plain text version of this content. The canonical link for it is here.
Posted to batik-users@xmlgraphics.apache.org by Archie Cobbs <ar...@dellroad.org> on 2007/05/14 23:30:06 UTC

SVG fonts and memory usage

Hi,

I have an SVG document which simply includes several other (let's say
10) SVG documents using tags like <image xlink:href="otherdoc1.svg"/>,
etc.

The 10 other included documents all want to use glyphs from the same
small set (let's say 4) of SVG fonts, which are themselves defined in
4 SVG files.

However, I cannot get this to work because of these problems:

1. If I reference the 4 SVG fonts in the top level document, then they don't
    seem to be accessible from the 10 included documents (guess this
    makes sense from an encapsulation point of view).

2. If I reference the 4 fonts from within each of the 10 included ocuments,
    then even though the 10 included documents are referencing the same
    4 SVG font files, it appears that each font is duplicated in memory for
    each included document, which makes 10 x 4 = 40 font copies, which
    quickly blows up memory.

3. I tried changing all the font references from this

        <font-face font-family="'MyFont'">
            <font-face-src>
               <font-face-uri xlink:href="myfont.svg#font"/>
            </font-face-src>
        </font-face>

   to this:

        <font-face font-family="'MyFont'">
            <definition-src xlink:href="myfont.svg#font"/>
        </font-face>

  but then I get this:

     java.lang.NullPointerException
	at org.apache.batik.bridge.FontFace.getFontFamily
	at org.apache.batik.bridge.SVGFontFace.getFontFamily(Unknown Source)
	at org.apache.batik.bridge.SVGFontUtilities.getFontFamily
        ...etc...

  which is expected I guess because <definition-src> is not implemented
  yet.

So my question is simply how do I define an SVG font and reference it
from multiple included documents without blowing up memory because the
font is duplicated so many times??

Thanks for any insights...

-Archie

__________________________________________________________________________
Archie Cobbs      *        CTO, Awarix        *      http://www.awarix.com

---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org


Re: SVG fonts and memory usage

Posted by th...@kodak.com.
Hi Archie,

archie.cobbs@gmail.com wrote on 05/14/2007 05:30:06 PM:

> I have an SVG document which simply includes several other (let's say
> 10) SVG documents using tags like <image xlink:href="otherdoc1.svg"/>,
> etc.
> 
> The 10 other included documents all want to use glyphs from the same
> small set (let's say 4) of SVG fonts, which are themselves defined in
> 4 SVG files.
> 
> However, I cannot get this to work because of these problems:

   Yes, in Batik right now each document is an island.  In general
I agree that it would be good if we made your use case more efficient.
Probably by caching the font data based on the URL so we wouldn't create
40 copies of the font data.

   The main concern with this sort of setup is security, as you need
to ensure that all of the documents referencing the font actually have
permission to access that data.

> So my question is simply how do I define an SVG font and reference it
> from multiple included documents without blowing up memory because the
> font is duplicated so many times??

   Right now you can't.

---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org