Proposals/Text to path API

From SVG
< Proposals
Revision as of 22:37, 27 October 2011 by Cmccorma (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

This is a proposal for an API that allows authors to convert text into a path.

dictionary SVGTextComponentPath {

  // Can be one of the following: "text", "underline", "overline", "line-through", "emphasis"
  DOMString type;

  // The path for the specified component of the text.
  SVGPathSegList path;

partial interface SVGTextContentElement {

  // Return an SVGPathSegList representing the entire geometry of the text content element,
  // including glyphs and decorations.
  SVGPathSegList toPath();

  // Return an SVGPathSegList for the glyphs and decorations for the given substring.
  SVGPathSegList toPath(unsigned long charnum, unsigned long nchars);

  // Returns separate SVGPathSegLists for the glyphs and decorations of the entire text
  // content element.
  sequence<SVGTextComponentPath> toComponentPaths();

  // Returns separate SVGPathSegLists for the glyphs and decorations for the given substring.
  sequence<SVGTextComponentPath> toComponentPaths(unsigned long charnum, unsigned long nchars);


  • Should the methods return anything if called on an SVG text content element that is not in the tree or is not being rendered?
  • Need to define the order that the text/decoration/emphasis paths are returned in.
  • Should we also be able to get the paths representing the text stroking?
  • (Dirk) It's possible there is no way to guarantee identical results across implementations, even for a given font. Does this matter?
  • (Dirk) Should the resulting path data include transformations (scaling, rotation, etc.)?
  • (Dirk) Is returning decorations really necessary?
  • (Rik) Should return each glyph's path separately, since if they overlap you will get different rendering results.
  • (Rik) An alternative design to consider is to get a list of glyph positions out of the API, and then be able to get the path for each individual glyph.
  • (Rik) It should be stated that the paths returned should be able to be painted either as nonzero or evenodd and get the same result.
  • (Rik) There needs to be an API for permission checking.
  • Should we have a DOM API instead that is not tied to a DOM <text> object? At least <text> gives you font properties, but maybe you don't want to have to insert an element into the document just to do a text-to-outline call.