protected GVTFontFamily getFontFamily(BridgeContext ctx,
ParsedURL purl) {
String purlStr = purl.toString();
Element e = getBaseElement(ctx);
SVGDocument svgDoc = (SVGDocument)e.getOwnerDocument();
String docURL = svgDoc.getURL();
ParsedURL pDocURL = null;
if (docURL != null)
pDocURL = new ParsedURL(docURL);
// try to load an SVG document
String baseURI = XMLBaseSupport.getCascadedXMLBase(e);
purl = new ParsedURL(baseURI, purlStr);
UserAgent userAgent = ctx.getUserAgent();
try {
userAgent.checkLoadExternalResource(purl, pDocURL);
} catch (SecurityException ex) {
// Can't load font - Security violation.
// We should not throw the error that is for certain, just
// move down the font list, but do we display the error or not???
// I'll vote yes just because it is a security exception (other
// exceptions like font not available etc I would skip).
userAgent.displayError(ex);
return null;
}
if (purl.getRef() != null) {
// Reference must be to a SVGFont.
Element ref = ctx.getReferencedElement(e, purlStr);
if (!ref.getNamespaceURI().equals(SVG_NAMESPACE_URI) ||
!ref.getLocalName().equals(SVG_FONT_TAG)) {
return null;
}
SVGDocument doc = (SVGDocument)e.getOwnerDocument();
SVGDocument rdoc = (SVGDocument)ref.getOwnerDocument();
Element fontElt = ref;
if (doc != rdoc) {
fontElt = (Element)doc.importNode(ref, true);
String base = XMLBaseSupport.getCascadedXMLBase(ref);