-
Notifications
You must be signed in to change notification settings - Fork 0
Lists of available functions
This page will contain the interfaces, functions, or other useful programatic utilities that you can use within Derakuma.
PenCommand contains all of the glyphs' pen data. Usually, PenCommand is an objected array, defined as PenCommand[].
Note: PD and PU are always in pairs!
-
PD: Pen down. Puts the pen down and starts drawing -
PU: Pen up. Stops drawing temporarily until the nextPD -
MP: Move pen. Moves the pen to the next location. This must be done after aPDcommand has been invoked.
-
command: 'PD' | 'PU' | 'MP': Defines all of the commands. -
x: number: Defines the absolute x coordinate of the specified vector, from 0 to 9 to the right. -
y: number: Defines the absolute y coordinate of the specified vector, from 0 to 9 upwards.
Defines the loading method of .bene font files.
-
FontLoadMethod.FETCH: Requests Derakuma to load.benevia a web request. If this is used, Derakuma must be wrapped under anasyncfunction. -
FontLoadMethod.FILENode/Bun only! Loads the.benefont synchronously via your system's filesystem. This will not work on the web version.
Contains the entire font metadata.
-
formatVersion?: string: Specifies the Fontobene format version. -
id?: string: Specifies the font's unique ID. Do not apply spaces here, only alphabets or numbers are allowed. Any encoding formats are allowed, provided they are supplied in the constructor. However for web, this must be explicitly UTF-8 -
name?: string: The font name. -
description?: string: Describes the font. -
version?: string(Not to be confused with the format version) Specifies the font's current version/revision -
authors: string[]: Lists the authors responsible for the font. -
licenses: string[]: Specifies the license of the font. -
letterSpacing: number: Specifies the spacing required between letters/characters. The letter spacing should range from 0-16. -
lineSpacing: number: Specifies the line spacing required, vertically. Vertical line spacing must range between 0-24. -
monospaceWidth?: number: If specified, specifies the fixed with of all characters.
Contains information about the requested glyph.
-
codepoint: string: Specifies the Unicode codepoint (e.g. codepoint is 0061, then unicode is certainly U+0061) -
char?: string: Specifies the character requested -
polylines: Array<Array<{ x: number; y: number }>>: Contains the polyline data. Every instance ofArray<{ x: number; y: number }>is a stroke (e.g. length of the parentArrayis 2, so there are two strokes) -
whitespace: number: Specifies the whitespace needed, trailing and is part of the advancement calculation. -
minX: number: Specifies the absolute minimum of a character's glyph (nearest edge in the left). Typically, the bare minimum should be 0. -
maxX: number: Specifies the maximum of the character. This must be equal or lower than 9 (<= 9).
The main class for handling all of Derakuma's main Fontobene features.
The main constructor for Derakuma. This is a must before doing any font operations, which means code such as new DerakumaParser('./source.bene').documentedFunction() is highly illegal.
-
source: string: Defines the URL of the font file. It can either be a URL or a local file system resource. -
loadMethod?: FontLoadMethod: Defines the load method needed to load the specific font. Refer toFontLoadMethodfor this. Defaults toFontLoadMethod.FETCH. -
encoding?: BufferEncoding | stringNode/Bun only! Specifies the encoding to open and parse the file, if your.benefile is saved not in UTF-8. Defaults toutf-8.
Runs an asynchronous method to specify that waiting for the font to be loaded. Only required when loadMethod in the constructor is left blank or is FontLoadMethod.FETCH. Returns a Promise<void> object.
Displays the full metadata of the parsed Fontobene file. Refer to FontMetadata.
Gets pen commands, only for one character. Returns PenCommand[], or an Error if not initialized. If a glyph does not exist, it will return the glyph for U+FFFD, if available, or Derakuma's built-in placeholder.
-
character: string | number: Specifies the requested character. It can be a single character, or a Unicode that has been turned into a decimal.
Same as getGlyph(character), however this returns a full Glyph object of the specified character, or an Error if not initialized. If a glyph does not exist, it will return the glyph for U+FFFD, if available, or Derakuma's built-in placeholder.
-
character: string | number: Specifies the requested character. It can be a single character, or a Unicode that has been turned into a decimal.
Returns a boolean to check whether a glyph exists for a specified character or Unicode decimal, or an Error if not initialized.
-
character: string | number: Specifies the requested character. It can be a single character, or a Unicode that has been turned into a decimal.
Returns a number to calculate horizontal advancements from previous glyph to the next glyph, or an Error if not initialized. If monospaceWidth is defined, this will return the monospaceWidth value instead.
-
character: string | number: Specifies the requested character. It can be a single character, or a Unicode that has been turned into a decimal.
Gets all pen commands of each characters in a sentence.
-
text: string: The text to display (can be separated by spaces) ReturnsArray<{ char: string; x: number; commands: PenCommand[] }>, or anErrorif not initialized.
-
char: The character itself. -
x: The x position relative from the last glyph's minimum X position, added up by the last glyph's maximum X position.
Returns a string[] to list all available glyphs for the specified font, or an Error if not initialized.