Package limn.graphics

Interface SvgRenderer


public interface SvgRenderer
SPI that draws SVG: opens a document from SVG text, draws it into pixels at any size, and lets an attribute of one of its elements be changed between two drawings, which is how an animated SVG is played. The backend installs one at startup (SvgIcon.installRenderer(limn.graphics.SvgRenderer)); a headless test can install its own. No AWT: the backend's lives beside its other natives.

The toolkit reads every SVG itself before a renderer sees it: it parses the XML, refuses what is damaged or too large, takes the animations out to play them itself, and hands the renderer text that refers to nothing outside itself. A renderer is never given a path or an address.

Called from any thread, including several at once, as SvgIcon.imageAsync(int) draws on the worker pool. A SvgRenderer.Document is used by one thread at a time; two documents may be used at once.

  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Interface
    Description
    static interface 
    One SVG, opened: measured, drawn and changed until it is closed.
  • Method Summary

    Modifier and Type
    Method
    Description
    default boolean
    addFont(String family, boolean bold, boolean italic, byte[] data)
    Makes a face available to SVG text by its family name, beside the system's installed fonts.
    open(byte[] svg)
    Opens a document.
  • Method Details

    • open

      SvgRenderer.Document open(byte[] svg)
      Opens a document.
      Parameters:
      svg - SVG text in UTF-8, read and never written
      Returns:
      the document, which the caller closes
      Throws:
      MalformedContentException - if the text is no SVG, or one with no size
    • addFont

      default boolean addFont(String family, boolean bold, boolean italic, byte[] data)
      Makes a face available to SVG text by its family name, beside the system's installed fonts. Nothing happens by default: a renderer that draws no text has no use for one.
      Parameters:
      family - the family name a file asks for
      bold - whether the face is the family's bold
      italic - whether it is its italic
      data - the font file's bytes, TrueType or OpenType
      Returns:
      whether the renderer took it