@aurigma/text-whizz
Version:
This is a part of a text engine of Customer's Canvas/Design Atoms. Don't use it directly.
1,241 lines (1,075 loc) • 35.7 kB
TypeScript
declare module "@aurigma/text-whizz/TextWhizzJS" {
function _malloc(size: number): number;
function _free(ptr: number): void;
const HEAPU8: { buffer: ArrayBuffer };
export const EndLineOffset: number;
interface Collection<TItem> {
get(index: number): TItem;
push_back(item: TItem): void;
resize(arg0, arg1): void;
set(arg0, arg1): void;
size(): number;
}
export class StringMap
{
get(key: string): string;
set(key: string, value: string);
size(): number;
keys(): Collection<string>;
}
export interface FontInfo {
family: string;
style: string;
name: string;
}
export enum TextAlignment {
left,
center,
right,
justification,
justificationLastLeft,
justificationLastCenter,
justificationLastRight,
}
export enum FirstBaselineOffset {
ascent,
capHeight,
leading,
xHeight,
fixed,
emBox
}
export enum OpenTypeFeature {
Aalt=1, // Access All Alternates
Abvf, // Above - base Forms
Abvm, // Above - base Mark Positioning
Abvs, // Above - base Substitutions
Afrc, // Alternative Fractions
Akhn, // Akhands
Blwf, // Below - base Forms
Blwm, // Below - base Mark Positioning
Blws, // Below - base Substitutions
Calt, // Contextual Alternates
Case, // Case - Sensitive Forms
Ccmp, // Glyph Composition / Decomposition
Cfar, // Conjunct Form After Ro
Cjct, // Conjunct Forms
Clig, // Contextual Ligatures
Cpct, // Centered CJK Punctuation
Cpsp, // Capital Spacing
Cswh, // Contextual Swash
Curs, // Cursive Positioning
C2pc, // Petite Capitals From Capitals
C2sc, // Small Capitals From Capitals
Dist, // Distances
Dlig, // Discretionary Ligatures
Dnom, // Denominators
Dtls, // Dotless Forms
Expt, // Expert Forms
Falt, // Final Glyph on Line Alternates
Fin2, // Terminal Forms #2
Fin3, // Terminal Forms #3
Fina, // Terminal Forms
Flac, // Flattened accent forms
Frac, // Fractions
Fwid, // Full Widths
Half, // Half Forms
Haln, // Halant Forms
Halt, // Alternate Half Widths
Hist, // Historical Forms
Hkna, // Horizontal Kana Alternates
Hlig, // Historical Ligatures
Hngl, // Hangul
Hojo, // Hojo Kanji Forms(JIS X 0212 - 1990 Kanji Forms)
Hwid, // Half Widths
Init, // Initial Forms
Isol, // Isolated Forms
Ital, // Italics
Jalt, // Justification Alternates
Jp78, // JIS78 Forms
Jp83, // JIS83 Forms
Jp90, // JIS90 Forms
Jp04, // JIS2004 Forms
Kern, // Kerning
Lfbd, // Left Bounds
Liga, // Standard Ligatures
Ljmo, // Leading Jamo Forms
Lnum, // Lining Figures
Locl, // Localized Forms
Ltra, // Left - to - right alternates
Ltrm, // Left - to - right mirrored forms
Mark, // Mark Positioning
Med2, // Medial Forms #2
Medi, // Medial Forms
Mgrk, // Mathematical Greek
Mkmk, // Mark to Mark Positioning
Mset, // Mark Positioning via Substitution
Nalt, // Alternate Annotation Forms
Nlck, // NLC Kanji Forms
Nukt, // Nukta Forms
Numr, // Numerators
Onum, // Oldstyle Figures
Opbd, // Optical Bounds
Ordn, // Ordinals
Ornm, // Ornaments
Palt, // Proportional Alternate Widths
Pcap, // Petite Capitals
Pkna, // Proportional Kana
Pnum, // Proportional Figures
Pref, // Pre - Base Forms
Pres, // Pre - base Substitutions
Pstf, // Post - base Forms
Psts, // Post - base Substitutions
Pwid, // Proportional Widths
Qwid, // Quarter Widths
Rand, // Randomize
Rclt, // Required Contextual Alternates
Rkrf, // Rakar Forms
Rlig, // Required Ligatures
Rphf, // Reph Forms
Rtbd, // Right Bounds
Rtla, // Right - to - left alternates
Rtlm, // Right - to - left mirrored forms
Ruby, // Ruby Notation Forms
Rvrn, // Required Variation Alternates
Salt, // Stylistic Alternates
Sinf, // Scientific Inferiors
Size, // Optical size
Smcp, // Small Capitals
Smpl, // Simplified Forms
Ss01, // Stylistic Set 1
Ss02, // Stylistic Set 2
Ss03, // Stylistic Set 3
Ss04, // Stylistic Set 4
Ss05, // Stylistic Set 5
Ss06, // Stylistic Set 6
Ss07, // Stylistic Set 7
Ss08, // Stylistic Set 8
Ss09, // Stylistic Set 9
Ss10, // Stylistic Set 10
Ss11, // Stylistic Set 11
Ss12, // Stylistic Set 12
Ss13, // Stylistic Set 13
Ss14, // Stylistic Set 14
Ss15, // Stylistic Set 15
Ss16, // Stylistic Set 16
Ss17, // Stylistic Set 17
Ss18, // Stylistic Set 18
Ss19, // Stylistic Set 19
Ss20, // Stylistic Set 20
Ssty, // Math script style alternates
Stch, // Stretching Glyph Decomposition
Subs, // Subscript
Sups, // Superscript
Swsh, // Swash
Titl, // Titling
Tjmo, // Trailing Jamo Forms
Tnam, // Traditional Name Forms
Tnum, // Tabular Figures
Trad, // Traditional Forms
Twid, // Third Widths
Unic, // Unicase
Valt, // Alternate Vertical Metrics
Vatu, // Vattu Variants
Vert, // Vertical Writing
Vhal, // Alternate Vertical Half Metrics
Vjmo, // Vowel Jamo Forms
Vkna, // Vertical Kana Alternates
Vkrn, // Vertical Kerning
Vpal, // Proportional Alternate Vertical Metrics
Vrt2, // Vertical Alternates and Rotation
Vrtr, // Vertical Alternates for Rotation
Zero, // Slashed Zero
}
export enum ColorType {
none,
rgb,
cmyk,
gray,
indexed
}
export enum RangeCursorPos {
left,
right
}
export enum AutoSizeMode {
off,
widthOnly,
heightOnly,
widthHeight
}
export enum AutoSizeAnchor {
topLeft,
topCenter,
topRight,
centerLeft,
center,
centerRight,
bottomLeft,
bottomCenter,
bottomRight
}
export enum VerticalAlignment {
top,
center,
bottom,
justify
}
export enum CopyFittingMode {
off,
fitToBox,
fitToWidth,
fill,
fitToWidthWithScale,
fillWithScale
}
export enum TextOrientation {
horizontal,
vertical
}
export class Color {
/**
* @constructor
* @param type type of color type.
* @param components color components. Must be different depending on a type.
*/
constructor(type: ColorType, components: number[]);
/**
* Gets color type
* @returns color type
*/
getType(): ColorType;
R: number;
G: number;
B: number;
A: number;
C: number;
M: number;
Y: number;
K: number;
gray: number;
index: number;
}
export class OpenTypeSet {
/**
* Gets the value of the specified OpenType feature.
* @param feature OpenType feature
* @returns A number. Usually 0 means off, 1 means on.
*/
get(feature: OpenTypeFeature) : number;
/**
* Sets the value of the specified OpenType feature.
* @param feature OpenType feature
* @param value Usually 0 means off, 1 means on.
*/
set(feature: OpenTypeFeature, value: number);
}
export interface CharStyle {
fauxBold: boolean;
fauxItalic: boolean;
fillColor: Color;
fontName: string;
fontSize: number;
strokeColor: Color;
strokeWidth: number;
underline: boolean;
tracking: number;
leading: number;
wordSpacingScale: number;
superscript: boolean;
superscriptPosition: number;
superscriptSize: number;
subscript: boolean;
subscriptPosition: number;
subscriptSize: number;
openType: OpenTypeSet;
allCaps: boolean;
smallCaps: boolean;
baselineShift: number;
vertScale: number;
horzScale: number;
}
export enum ListStyleType {
none,
bullets,
numbers
}
export enum NumberFormatType {
none,
number,
lowerLetter,
upperLetter,
lowerRoman,
upperRoman
}
export enum NumberMode {
continueFromPrevious,
startAt
}
export interface ParagraphStyle {
firstLineIndent: number;
spaceBefore: number;
spaceAfter: number;
leftIndent: number;
rightIndent: number;
alignment: TextAlignment;
type: ListStyleType;
level: number;
formatType: NumberFormatType;
mode: NumberMode;
startAt: number;
bulletChar: number;
tabPosition: number;
}
export interface PointF
{
x: number;
y: number;
}
export interface TextLimits
{
maxLineCount: number;
maxCharCount: number;
maxCharCountPerLine: number;
}
export interface Rectangle {
x: number;
y: number;
width: number;
height: number;
}
export enum MoveDirection {
left,
right,
up,
down,
lineStart,
lineEnd,
textStart,
textEnd,
leftWord,
rightWord
}
export class FontRegistry {
/**
* @constructor
* @param dpi dpi value
*/
constructor(dpi: number);
/**
* Adds new font from text-whizz allocated buffer.
* @param ptr data pointer.
* @param length data size.
* @returns postscript name of the added font.
*/
add(ptr: number, length: number): string;
/**
* Gets the number of fonts inside FontRegistry.
* @returns the number of fonts.
*/
getCount(): number;
/**
* Clears FontRegistry
*/
clear(): void;
/**
* Checks whether the specified font is contained by the registry.
* @param psName postscript name.
* @returns true if contains.
*/
contains(psName: string): boolean;
/**
* Gets font information by postscript name.
* @param psName postscript name.
* @returns A structure with font information.
*/
getFontInfoByName(psName: string): FontInfo;
/**
* Creates a font object.
* @param psName postscript name.
* @param size font size in points.
* @returns a font object.
*/
createFont(psName: string, size: number): Font;
fallbackFonts: string[];
}
export class Matrix {
sx: number;
sy: number;
shx: number;
shy: number;
tx: number;
ty: number;
/**
* Creates a rotate matrix.
* @param angle angle in radians.
* @returns rotation matrix.
*/
static createRotate(angle: number): Matrix;
/**
* Creates a scale matrix.
* @param sx scale value for the x coordinate.
* @param sy scale value for the y coordinate.
* @returns scale matrix.
*/
static createScale(sx: number, sy: number): Matrix;
/**
* Creates a translate matrix.
* @param tx translate value for the x coordinate.
* @param ty translate value for the y coordinate.
* @returns translation matrix.
*/
static createTranslate(tx: number, ty: number): Matrix;
/**
* Creates the identity matrix.
* @returns identity matrix.
*/
static createIdentity(): Matrix;
/**
* Multiplies two matrices.
* @param m1 left matrix.
* @param m2 right matrix.
* @returns the result of the multiplication.
*/
static multiply(m1: Matrix, m2: Matrix): Matrix;
/**
* Creates an inverse matrix.
* @param mat the original matrix.
* @returns an inverse matrix.
*/
static createInv(mat: Matrix): Matrix;
/**
* Multiplies the matrix on another one.
* @param mat "another" matrix.
*/
concat(mat: Matrix);
/**
* Scales the current matrix.
* @param dx scale for X.
* @param dy scale for Y.
*/
scale(dx: number, dy: number);
/**
* Rotates the current matrix.
* @param angle rotate angle.
*/
rotate(angle: number);
/**
* Translates the current matrix.
* @param tx translate for X.
* @param ty translate for Y.
*/
translate(tx: number, ty: number);
/**
* Transforms the point by given coordinates with the matrix.
* @param x point's x coordinate.
* @param y point's y coordinate.
* @returns the transformed point.
*/
transform(x: number, y: number): PointF;
}
export interface PathParsingContext {
moveTo(x: number, y: number);
lineTo(x: number, y: number);
quadraticCurveTo(cpx: number, cpy: number, x: number, y: number);
bezierCurveTo(cpx1: number, cpy1: number, cpx2: number, cpy2: number, x: number, y: number);
closePath();
}
export class Path {
/**
* Starts new path segment.
* @param x coordinate x.
* @param y coordinate y.
*/
moveTo(x: number, y: number);
/**
* Adds a line from the last point.
* @param x coordinate x.
* @param y coordinate y.
*/
lineTo(x: number, y: number);
/**
* Adds a quadratic Bézier curve.
* @param cx coordinate x for control point.
* @param cy coordinate y for control point.
* @param x coordinate x for the endpoint.
* @param y coordinate y for the endpoint.
*/
curveTo3(cx: number, cy: number, x: number, y: number);
/**
* Adds a cubic Bézier curve.
* @param cx1 coordinate x for control point #1.
* @param cy1 coordinate y for control point #1.
* @param cx2 coordinate x for control point #2.
* @param cy2 coordinate y for control point #2.
* @param x coordinate x for the endpoint.
* @param y coordinate y for the endpoint.
*/
curveTo4(cx1: number, cy1: number, cx2: number, cy2: number, x: number, y: number);
/**
* Closes the current segment.
*/
close();
/**
* Adds a rectangle to the path.
* @param x coordinate x.
* @param y coordinate y.
* @param width rectangle width.
* @param height rectangle height.
*/
rect(x: number, y: number, width: number, height: number);
/**
* Adds the path to a 2d canvas drawing context.
* @param ctx The 2d context of a Canvas.
*/
addToContext(ctx: CanvasRenderingContext2D);
/**
* Adds the path to a PathParsingContext.
* @param ctx The PathParsingContext.
*/
parse(ctx: PathParsingContext);
getBounds() : Rectangle;
translate(tx: number, ty: number);
scale(sx: number, sy: number);
rotate(angle: number);
split() : Collection<Path>;
getLength() : number;
isEmpty() : boolean;
offsetContour(delta: number);
/**
* Detects if the point is inside of the path.
* @param x coordinate x.
* @param y coordinate y.
* @returns true if the point is inside
*/
isInside(x: number, y: number) : boolean;
/**
* Get clothest distance from the point to the path outline.
* @param x coordinate x.
* @param y coordinate y.
* @returns distance
*/
getDistanceToOutline(x: number, y: number) : number;
static xor(path1: Path, path2: Path): Path;
static intersect(path1: Path, path2: Path): Path;
static subtract(path1: Path, path2: Path): Path;
static union(path1: Path, path2: Path): Path;
}
export class Baseline {
position : PointF;
length : number;
order : number;
}
export class BaselinePosition {
baseLine : Baseline;
charOffset : number;
}
export class UndoInfo {
index : number;
count : number;
}
export class TextHandler {
/**
* @constructor
* @param text a text object to edit.
* @param dpi DPI value.
*/
constructor(fr: FontRegistry, dpi: number);
/**
* Gets a TextPosition object from the point.
* @param x coordinate x.
* @param y coordinate y.
* @param forSelection true means that EndOfLine offset is possible to return.
* @returns TextPosition object.
*/
getPosition(x: number, y: number, forSelection: boolean): TextPosition;
/**
* Gets a TextPosition object from the logical position.
* @param lineIndex logical line index. Not a paragraph index!!!
* @param offset the offset inside of the logical line.
* @returns TextPosition object.
*/
getPositionByIndex(lineIndex: number, offset: number): TextPosition;
/**
* Gets a TextPosition object from the first position.
* @returns TextPosition object.
*/
getFirstPosition(): TextPosition;
/**
* Gets a TextPosition object from the last position.
* @returns TextPosition object.
*/
getLastPosition(): TextPosition;
/**
* Gets a TextPosition object from the end position.
* @returns TextPosition object.
*/
getEndPosition(): TextPosition;
/**
* Gets a Cursor object.
* @returns an instance of Cursor class.
*/
getCursor(): Cursor;
/**
* Adds a text frame.
*/
addFrame(frame: TextFrame);
/**
* Gets frame by index.
*/
getFrame(index: number) : TextFrame;
/**
* Removes a text frame with the specified index.
*/
removeFrame(index: number);
/**
* Replaces a text frame with the specified index.
*/
replaceFrame(frame: TextFrame, index: number);
/**
* Gets the text frame count.
* @returns a number.
*/
getFrameCount(): number;
/**
* Sets the default char style. Makes sense only for the empty text handler.
*/
setDefaultCharStyle(charStyle: CharStyle);
/**
* Gets the default char style.
* @returns a char style.
*/
getDefaultCharStyle(): CharStyle;
/**
* Sets the default paragraph style.
*/
setDefaultParagraphStyle(paragraphStyle: ParagraphStyle);
/**
* Gets the default paragraph style.
* @returns a paragraph style.
*/
getDefaultParagraphStyle(): ParagraphStyle;
/**
* Gets the color palette used for indexed colors.
* @returns current ColorPalette object.
*/
getColorPalette(): ColorPalette;
/**
* Sets wrapping path.
*/
setWrappingPath(path : Path);
/**
* Gets bounds for text output.
* @returns a rectangle.
*/
getBounds(): Rectangle;
/**
* Gets TextRange for all text inside.
* @returns an instance of TextRange class.
*/
getTextRange(): TextRange;
/**
* Gets a TextRange for text rendered with current frames.
* @returns an instance of TextRange class.
*/
getVisibleTextRange(): TextRange;
/**
* Gets a TextRange for the specified text frame.
* @param index text frame index.
* @returns an instance of TextRange class.
*/
getTextFrameRange(index: number) : TextRange;
/**
* Renders text content onto the internal raster buffer in BGRA format.
* @param width image width.
* @param height image height.
* @returns a pointer to the internal raster buffer.
*/
renderImageData(width: number, height: number): number;
/**
* Saves text handler to a PNG image.
* @param data pointer to caller preallocated buffer.
* @param size buffer size.
* @returns written bytes count.
*/
saveToPNG(data: number, size: number) : number;
/**
* Gets information about the undo/redo queue in the form of index/count.
* @returns index/count values.
*/
getUndoInfo(): UndoInfo;
/**
* Makes undo for the last action.
*/
undo(): void;
/**
* Makes redo of the next action in the undo/redo queue.
*/
redo(): void;
/**
* Clears all actions in the undo/redo queue.
*/
clearUndoRedo(): void;
/**
* Gets a selection range for the specified undo/redo index. When both parts of the range are equal, we have a cursor.
* @param index undo/redo index.
* @returns TextRange with selection or cursor information.
*/
getUndoRedoCursorOrSelection(index: number): TextRange;
/**
* Draws text on the 2d context.
* @param ctx The 2d context of a Canvas.
*/
draw(ctx: CanvasRenderingContext2D);
/**
* Gets a paragraph count in the text.
* @returns paragraph count.
*/
getParagraphCount(): number;
/**
* Sets new style for the paragraph.
* @param index paragraph index.
* @param ps paragraph style.
*/
setParagraphStyle(index: number, ps: ParagraphStyle);
/**
* Gets a paragraph style.
* @param index paragraph index.
* @returns paragraph style
*/
getParagraphStyle(index: number): ParagraphStyle;
/**
* Gets a paragraph text range.
* @param index paragraph index.
* @returns TextRange
*/
getParagraphTextRange(index: number): TextRange;
/**
* Gets a paragraph metadata.
* @param index paragraph index.
* @param metadata metadata
*/
setParagraphMetadata(index: number, metadata: StringMap);
/**
* Gets a paragraph metadata.
* @param index paragraph index.
* @returns StringMap
*/
getParagraphMetadata(index: number): StringMap;
/**
* Sets a paragraph char style
* @param index paragraph index.
* @param cs char style.
*/
setParagraphCharStyle(index: number, cs: CharStyle);
/**
* Gets a paragraph char style
* @param index paragraph index.
* @returns char style.
*/
getParagraphCharStyle(index: number): CharStyle;
/**
* Sets limits for the text
* @param limits a structure containing limits.
* @param callback calls when the text doesn't meet any of the limits.
*/
setTextLimits(limits: TextLimits, callback: () => void);
/**
* Stops putting changes to undo/redo queue.
*/
pauseUndoRedo();
/**
* Starts putting changes to undo/redo queue.
*/
resumeUndoRedo();
}
export class ColorPalette {
add(color: Color): boolean;
remove(index: number);
getSize(): number;
get(index: number): Color;
}
export interface TextPosition {
/**
* Gets an offset inside the current baseline.
* @returns offset.
*/
getOffset(): number;
/**
* Gets an index of logical line.
* @returns offset.
*/
getLineIndex(): number;
getCharStyle(): CharStyle;
getWord(): TextRange;
getBaselinePosition() : BaselinePosition;
/**
* Determines whether this TextPosition is equal to another.
* @param other another TextPosition.
* @returns true if they are equal.
*/
isEqual(other: TextPosition): boolean;
/**
* Determines whether the TextPosition is valid. "Valid" means that original text still exists and was not modified.
* @returns true if valid.
*/
isValid(): boolean;
/**
* Gets the index of the paragraph
* @returns 0 based index
*/
getParagraphIndex(): number;
}
export class TextRange {
/**
* @constructor
* @param beginPosition a start of the range.
* @param endPosition an end of the range.
*/
constructor(beginPosition: TextPosition, endPosition: TextPosition);
/**
* Deletes text interval defined by the TextRange.
* @param cursorPos Indicates the current cursor position. Needed for undo/redo functionality.
*/
delete(cursorPos: RangeCursorPos): TextPosition;
/**
* Gets a string for the TextRange.
* @returns plain string.
*/
getChars(): string;
/**
* Gets a start position of the TextRange.
* @returns a TextPosition object.
*/
getStart(): TextPosition;
/**
* Gets an end position of the TextRange.
* @returns a TextPosition object.
*/
getEnd(): TextPosition;
/**
* Gets text styles inside the TextRange.
* @returns a collection of CharStyle objects.
*/
getCharStyles(): Collection<CharStyle>;
/**
* Gets a collection of paragraph settings inside the TextRange.
* @returns a collection of ParagraphStyle objects.
*/
getParagraphStyles(): Collection<ParagraphStyle>;
/**
* Determines whether the TextRange is valid. "Valid" means that original text still exists and was not modified.
* @returns true if valid.
*/
isValid(): boolean;
/**
* Updates text styles for the TextRange. You need to modify some style property in the callback function and return it.
* @param callback a function for changing styles.
*/
updateCharStyles(callback: (currentStyle: CharStyle) => CharStyle): void;
/**
* Updates paragraph settings for the TextRange. You need to modify some property in the callback function and return it.
* @param callback a function for changing settings.
*/
updateParagraphStyles(callback: (currentStyle: ParagraphStyle) => ParagraphStyle): void;
/**
* Gets a hover area for the text range. When several text lines, multiple subpaths are being used.
* @returns Path with multiple subpaths.
*/
getArea(): Path;
/**
* Gets the rich text for the text range.
* @param defaultParagraphStyle The paragraph style used as default while forming a rich text string.
* @param defaultCharStyle The char style used as default while forming a rich text string.
* @returns A string in GraphicsMill's rich text syntax.
*/
getFormattedText(defaultParagraphStyle: ParagraphStyle, defaultCharStyle: CharStyle): string;
/**
* Gets the rich text for the text range.
* @returns A string in GraphicsMill's rich text syntax.
*/
getFormattedTextForDefaults(): string;
/**
* Renders text content of the range onto the internal raster buffer in BGRA format.
* @param width buffer width.
* @param height buffer height.
* @param fillColor Fills the content with this color.
* @returns a pointer to the internal raster buffer.
*/
renderImageData(width: number, height: number, fillColor: Color): number;
/**
* Draws text on the 2d context.
* @param ctx The 2d context of a Canvas.
* @param fillColor Fills the content with this color.
*/
draw(ctx: CanvasRenderingContext2D, fillColor: Color);
/**
* Gets baselines belonging to the range.
* @returns an array of baselines.
*/
getBaselines(): Collection<Baseline>;
}
export class Cursor {
getPosition(): TextPosition;
move(direction: MoveDirection, forSelection: boolean): boolean;
set(pos: TextPosition);
insertText(text: string): TextPosition;
insertPlainText(text: string): TextPosition;
insertLine(): TextPosition;
getPath() : Path;
getCharStyle(): CharStyle;
setCharStyle(style: CharStyle);
getParagraphStyle(): ParagraphStyle;
setParagraphStyle(style: ParagraphStyle);
}
export class TextFrame{}
export class ShapeTextFrame extends TextFrame {
shape : Path;
firstBaselineOffset: FirstBaselineOffset;
firstBaselineMinOffset: number;
autoSizeMode: AutoSizeMode;
autoSizeAnchor: AutoSizeAnchor;
copyFittingMode: CopyFittingMode;
verticalAlignment: VerticalAlignment;
textOrientation : TextOrientation;
}
export class PointTextFrame extends TextFrame {
point : PointF;
textOrientation : TextOrientation;
}
export class ArchedTextFrame extends TextFrame {
center : PointF;
bend : number;
}
export enum PathTextAlignment {
ascender,
descender,
center,
baseline
}
export class PathTextFrame extends TextFrame {
/**
* A baseline path.
*/
baseline: Path;
/**
* Start offset.
*/
start: number;
/**
* End offset.
*/
end: number;
/**
* Whether to type on a backside.
*/
flip: boolean;
/**
* Path text alignment.
*/
pathAlignment: PathTextAlignment;
/**
* Additional space between characters in points.
*/
spacing: number;
/**
* Additional vertical offset to compensate for the baseline outline width.
*/
verticalOffset: number;
/**
* Copy fitting mode.
*/
copyFittingMode: CopyFittingMode;
}
export interface Font {
/**
* Gets font size in points.
*/
getSize(): number;
/**
* Gets the family name of the font.
* @returns a string
*/
getFamily(): string;
/**
* Gets the style name of the font.
* @returns a string
*/
getStyle(): string;
}
/**
* Gets exception name.
* @param exception a value from the catch block.
* @returns a string
*/
function getExceptionName(exception: any): string;
/**
* Gets exception message.
* @param exception a value from the catch block.
* @returns a string
*/
function getExceptionMessage(exception: any): string;
/**
* Clears the WebGL context.
*/
function clearContext();
/**
* Adds the whole text from the specified text handler to the WebGL context.
* @param textHandler TextHandler with text.
*/
function addTextToContext(textHandler: TextHandler);
/**
* Adds the text range from the specified text handler to the WebGL context.
* @param textHandler TextHandler with text.
* @param textRange text range.
*/
function addTextRangeToContext(textHandler: TextHandler, textRange: TextRange);
/**
* Adds the text range from the specified text handler to the WebGL context.
* @param textHandler TextHandler with text.
* @param textRange text range.
* @param fillColor fill color.
* @param drawBullets whether to draw ALL bullets in text or not.
*/
function addColorTextRangeToContext(textHandler: TextHandler, textRange: TextRange, fillColor: Color, drawBullets: boolean);
/**
* Adds the shape to the WebGL context. It doesn't handle inner holes yet!
* @param path A path containing the shape.
* @param fillColor fill color.
*/
function addShapeToContext(path: Path, fillColor: Color);
/**
* Sets the transformation matrix for the WebGL context.
* @param mat Affine matrix.
*/
function setContextTransform(mat: Matrix);
/**
* Sets the current context for webGL output.
* @param id Canvas ID. Something like "#layer1"
*/
function setCurrentContext(id: string);
/**
* Changes context size and GL viewport size.
* @param width width.
* @param height height.
*/
function setCurrentContextSize(width: number, height: number);
/**
* Sets clipping paths.
* @param path clipping paths.
*/
function setClippingPaths(path: Path);
/**
* Clears clipping paths.
*/
function clearClippingPaths();
/**
* Checks whether hardware acceleration is available and turned on.
* @param id Canvas ID. Something like "#layer1"
*/
function isHardwareAccelerationAvailable(id: string): boolean;
/**
* Gets a string with a full version number.
*/
function getVersion(): string;
}