05-03-2010 10:47 PM
I'm having a bit of a struggle understanding how to use external fonts in SVG documents.
I first tried embedding the font in the document (<defs>) per JSR 226 but then it appears this is not supported on the BB, the (fairly old) documentation says you can xlink to an external file and gives an example:
<font-face-uri xlink:href="externalFont1.cbtf" />
Since I don't know how to make a .cbtf file I have attempted to compile the SVG font using the SVGC tool that comes with Theme Studio, I get no errors but I get a tiny PME file (<100 bytes) that obviously does not contain the <glyph> elements.
At this stage I'm pretty confused, its not clear whether the SVG documentation is really relevant since it seems to predate the introduction of JSR-226 support.
Has anyone managed to use an external font in SVG on the BlackBerry outside of Plazmic?
Solved! Go to Solution.
05-03-2010 11:06 PM
I'll start off by saying I have absolutely no experience but will see if I can help you and learn something too.
I looked at http://www.w3.org/TR/SVGMobile12/fonts.html and at the bottom it tells how to use a SVG file for the font. If you then used "javax.microedition.m2g.ExternalResourceHandler" you could load the SVG and use it to pass the "font" to the ScalableImage and get your SVG rendered (theoretically).
05-04-2010 01:19 AM - edited 05-04-2010 01:21 AM
Thanks for the reply!
It seems that the BlackBerry implementation of JSR 226 is broken in that it won't load embedded fonts, external fonts are not allowed in SVG Tiny 1.1 so it seems we are stuck there.
Fortunately I have found a solution that works though, you can usenet.rim.device.api.ui.FontManager to load a True-Type font and that font then becomes accessible via SVG.
05-04-2010 06:49 AM
That works too but only on 5.0 and above.
05-04-2010 08:17 AM
hmmm, you're right I missed that.
I'm pretty sure the ExternalResourceHandler approach is not going to work since the SVG engine won't load embedded fonts in the main file so I'd guess it would not load them in an external file either, plus this:
"Note that SVGT 1.1 does not contain external references to SVG files, therefore an external resource can not contain subsequent external resources."
This is part of JSR 226 anyway, SVG fonts must be embedded in the main document.
So it looks like OS 4.6 and OS 4.7 are only able to use the system fonts.. another half-a**ed effort by RIM then.
05-18-2010 11:33 PM
Actually despite my little outburst you were perfectly correct.. by implementing an ExternalResourceHandler it is possible to load TrueType fonts in OS 4.6, 4.7 and 5.0.. Thanks!
05-19-2010 07:12 AM
Glad I could help. How did you get a TrueType font loaded on 4.6 and 4.7? I ask because from what I can tell FontManager only supports loading user-made fonts in 5.0 and higher.
05-19-2010 05:27 PM
I specify the font in the <defs> section of the SVG file and the SVG renderer requests it via the ExternalResourceHandler. The documentation doesn't mention the ability to load TrueType fonts in this way but I just tried it on a hunch and it worked on all 3 OSes.
05-19-2010 05:57 PM
That's actually good to know, though it would take some work a developer who needs to load a font on a lower-then-5.0 OS can use SVG to do it.
05-29-2010 06:44 PM
I did actually try this by defining the following :
<defs> <font-face font-family="arial_black"> <font-face-src> <font-face-uri xlink:href="img/ariblk.ttf"/> </font-face-src> </font-face> </defs>
and logged every requestResource call.
Result is that ariblk.ttf is not listed when testing on a Bold 9000 simulator/OS 4.6.
Did you test on simulator or device?
How did you reference the external font?