CdlUtils

CdlUtils.getSvgPathStrings(charOrUnicode, options)

This method returns a promise containing an array of SVG pathstrings. These pathstrings are designed to be used as the d attribute of an SVG path element.

charOrUnicode can be either a single character such as "你", the unicode hex for a character such as "4F60", or a CdlChar object (more on this later).

options is an object literal with the following keys:

  • apiKey:Your developer API key. Required unless a custom dataLoader is used.
  • dataLoader:a function which returns CDL XML. Read more about this in the Advaced usage section on loading data.
  • xmlParser:Only required for running CdlUtils in node.js. More about this below in the section on using CdlUtils in node.
  • onError:An optional callback function in the event of an error. Typically this would occur if there is a network problem or if you attempt to load an invalid character. The callback is passed an Error object.
  • x:int, default 0. x-offset to begin rendering SVG from
  • y:int, default 0. y-offset to begin rendering SVG from
  • width:int, default 400,
  • height:int, default 400
  • font:string, default 'song'. Either 'plain' or 'song' font
  • fixMargin:boolean, default true. Whether to pad the returned SVG so it fits inside the bounds specified.
  • variant:the variant of the character to load if the CDL db contains multiple variants for this character. This param is usually not needed.


fetchCdlChar(charOrUnicode, options)

This method returns a promise containing a CdlChar object. More on these below in the section on manipulating CDL.

charOrUnicode can be either a single character such as "你", the unicode hex for a character such as "4F60", or a CdlChar object.

options is an object literal with the following keys:

  • dataLoader:required a function which returns CDL XML. Read more about this in the Advaced usage section on loading data.
  • variant:the variant of the character to load if the CDL db contains multiple variants for this character. This param is usually not needed.
  • xmlParser:Only required for running CdlUtils in node.js. Read more about this in the Advanced usage section on using CdlUtils in node.