The SamsaGlyph
object represents a glyph as either:
SamsaGlyph()
SamsaGlyph.components
points
property still contains the 4 phantom points.SamsaGlyph.endPts
points
array that indicate the last point of each contour.SamsaGlyph.font
SamsaFont
object that the glyph belongs to.SamsaGlyph.instructionLength
SamsaGlyph.instructions
SamsaGlyph.instructionLength
is non-zero, this is a SamsaBuffer
object containing the instruction bytes for the glyph; otherwise it is undefined
.SamsaGlyph.name
SamsaGlyph.numberOfContours
SamsaGlyph.numPoints
SamsaGlyph.points
[x, y, onCurve]
, where onCurve
is 0 for off-curve points and 1 for on-curve points). Note that the length of this array is 4 more than SamsaGlyph.numPoints
, because 4 phantom points are appended.SamsaGlyph.tvts
SamsaGlyph.decompose()
SamsaGlyph
object that is a simple glyph, by recursively decomposing the glyph if it is composite. The new glyph is visually identical to the original glyph. The components
array of the returned glyph will be empty. It is valid to call this method on a simple glyph, in which case the method returns a new glyph that is a copy of the original.SamsaGlyph.instantiate()
SamsaGlyph
object, being a new version of this glyph transformed according to the SamsaInstance
object passed as an argument.SamsaGlyph.svgPath()
d
attribute of an SVG <path>
element.// display the array of points for the glyph for the character "A"
const nodeBuffer = fs.readFileSync(filename);
const arrayBuffer = nodeBuffer.buffer;
const samsaBuffer = new SamsaBuffer(arrayBuffer);
const font = new SamsaFont(samsaBuffer);
const string = "A";
const glyphId = font.glyphIdFromUnicode(string.codePointAt(0));
const glyph = font.loadGlyphById(glyphId);
console.log(glyph.points);