Hi Victor,

"Victor Mote" <[EMAIL PROTECTED]> wrote on 06/14/2007 08:03:59 PM:

> I would now like to add, if possible, the ability to handle fonts
> embedded in an SVG document, specifically to parse them and then embed 
them
> in PDF (for now) output. We have the basic infrastructure in place to do
> that, but I have struggled to get access to the raw font data in the SVG
> document.

   If you can get a reference to the CSSEngine:
        ((SVGOMDocument)e.getOwnerDocument()).getCSSEngine();

   You can ask it for the @font-face rules in the stylesheets:
   /**
     * Gets the StyleMaps generated by @font-face rules
     * encountered by this CSSEngine thus far.
     */
    public List getFontFaces()

   This will have a bunch of batik.css.engine.FontFaceRule
Objects.  From that you can get a parsed URL which will give
you the raw font data.

> The font content is embedded in the SVG as follows:
> <style type="text/css">
>   <![CDATA[
> @font-face{font-family:'Saturn';src:url("data:;base64,\
> T1RUTwACAC ... (font data omitted for brevity)

> 1. I think the SVG document is in the correct general form. It was 
created
> by Adobe Illustrator, and renders successfully in Internet Explorer 7.0.

    Last I checked Illustrator used a fairly odd format for storing
font data in the SVG file (ttf?)  It's essentially Type 1 font
outlines embedded in a TrueType wrapper.

    You should also be aware that the only required format for
Fonts in SVG is SVG fonts.

> 2. SVGOMDocument throws a "not implemented" RuntimeException at
> getStyleSheets().
> 
> 3. SVGOMStyleElement throws a similar exception at getSheet().
> 
> 4. SVGOMStyleElement throws an NPE somewhere in getCSSStyleSheet(). (I 
can't
> tell exactly where with my current setup: The distribution object code 
does
> not have line numbers compiled into it, so I can't walk through it with 
a
> debugger).

    I suspect that this is happening when you try and build the 
SVG Graphics tree?  If so this is because Batik doesn't support the
variant of fonts that Illustrator uses.

    We don't include line numbers as adding them grows the Jar files 
noticeably.  But it's really easy to build your own distribution with
debug on.  The simplest thing is to download the source distribution,
change build.xml:91 so 'debug' is set to 'on' (this can also be
done in a build.properties file with the line: debug=on).

    Then run ant with 'jars' as the target.

    This will build a batik-1.6/7 dir just like the distribution.

> 5. I see the collection of GVTFont-related stuff that is available in 
the
> text nodes, but don't see a way to get to the actual font data through 
that
> means.

    The GVT stuff would have Java Font Instances or our internal SVG Font
data.  It's probably the wrong place to tap in to get 'raw' font data.

> Questions:
> 1. Am I on the right track to try to get access to the StyleSheet 
instance?

    Yes, I think you want to get the font data from our CSSEngine.

> 2. Is there a document-level way to get to the style sheets for the
> document, or do I need to walk the tree to find them?

   See above.

> 3. Do you have any advice about the best way to get to that raw font 
data?

   See above.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to