import { GlyphVertices } from './glyphvertices'; import { Label } from './label'; /** * The typesetter is responsible for layouting text on the screen or in a virtual space. It takes a label, * which defines where it wants to appear (@see {@link Label}), and a font face that is used to display the * text, and computes the actual position for each glyph. Its output is a vertex array, which describes the glyphs * position and appearance on the screen/in the scene and which can be rendered using a LabelRenderPass. */ export declare class Typesetter { private static readonly DELIMITERS; /** * Configuring the vertex for a given glyph to be rendered. If no vertex is given or the glyph is not depictable, * this method immediately exits at the beginning. * @param fontFace - Font face to be applied for setting up the vertex. * @param pen - Typesetting position which is the not-yet-transformed position the glyph will be rendered at. * @param glyph - Glyph that is to be rendered/configured. * @param vertices - Glyph vertex store required for rendering. * @param index - Glyph vertex index for store manipulation. */ private static writeVertex; /** * Compute an initial line anchor w.r.t. the targeted anchoring. * @param label - Label to adjust the y-positions for. */ private static lineAnchorOffset; /** * Resolves a typed float array storing the advances of each of the label's characters. * @param label - Label to resolve advances for. * @param text - Text to compute advances for, if none is given, label.text is used. * @returns - A typed float array of all ordered character advances. */ private static advances; /** * Resolves a typed float array storing the kernings of each of the label's characters. * @param label - Label to resolve kernings for. * @param text - Text to compute advances for, if none is given, label.text is used. * @returns - A typed float array of all ordered character kernings. */ private static kernings; /** * Create array of word, delimiter, and line feed fragments. A fragment thereby denotes the start and exclusive end * index as well as the type. The array is intended to favor maintainability over performance. * @param label - Label to create fragments for. * @returns - Fragments, i.e., indices ranges and associated fragment type (word, linefeed, delimiter). */ private static fragments; /** * Compute fragment widths without kernings w.r.t. preceding and subsequent fragments. * @param fragments - * @param advances - * @param kernings - * @returns - */ private static fragmentWidths; /** * Computes the left and right side thresholds for elide computation. * @param label - Label to query elide mode and line width from. * @param ellipsisWidth - Pre-computed width of the full ellipsis (t avoid re-computation). * @returns - The left and right thresholds intended for elide fragment retrieval. */ private static elideThresholds; /** * Creates a sub list of fragments that fit into threshold. The last fragment might be adjusted in order to cram * as many characters as possible for the elide. Reverse flag can be used do start left or right. * @param threshold - Threshold in typesetting space. * @param labelFragments - Pre-computed label fragments. * @param labelFragmentWidths - Pre-accumulated widths of the label fragments. * @param labelAdvances - Advances in order to reduce lookups. * @param labelKernings - Kernings in order to reduce lookups. * @param reverse -If enabled, the right side elide fragments will be collected and adjusted. Left side otherwise. * @returns - A new fragment, fragment-widths array for elide advancing, and overall width. */ private static elideFragments; /** * Computes origin, tangent, and up vector for every vertex of in the given range. * @param transform - Transformation to apply to every vertex. * @param vertices - Glyph vertices to be transformed (expected untransformed, in typesetting space). * @param begin - Vertex index to start alignment at. * @param end - Vertex index to stop alignment at. */ private static transformVertices; /** * @param currentRectangle - [minX, minY, minZ, maxX, maxY, maxZ] is updated in-place * @param newRectangle - [minX, minY, minZ, maxX, maxY, maxZ] used to update currentRectangle */ private static updateRectangleMinMax; /** * Returns a vec2 [min, max] containing the minimum and the maximum of the given values. * @param currentMin - the current minimum (e.g., initialized to +Infinity) * @param currentMax - the current maximum (e.g., initialized to -Infinity) * @param values - find the maximum and minimum of the given values */ private static minMax; /** * Returns [minX, minY, minZ, maxX, maxY, maxZ] of the vertices coordinates, i.e., origins, * origins + tangents, origins + ups, from which a bounding rectangle can be calculated. * @param vertices - Glyph vertices to be transformed (expected untransformed, in typesetting space). * @param begin - Vertex index to start alignment at. * @param end - Vertex index to stop alignment at. */ private static getMinMaxVertices; /** * Adjusts the vertices for a line after typesetting (done due to line feed, word wrap, or end of line) w.r.t. * the targeted line alignment. * @param width - Width of the line (e.g., typesetting position at the end of the line in typesetting space). * @param alignment - Targeted alignment, e.g., left, center, or right. * @param vertices - Glyph vertices for rendering to align the origins' x-components of (expected untransformed). * @param begin - Vertex index to start alignment at. * @param end - Vertex index to stop alignment at. */ private static transformAlignment; /** * Create and transform glyph vertices for rendering. * @param label - Label providing transform data, e.g., alignment and static transform. * @param vertices - Glyph vertices to apply transformations to. * @param lines - Indices of glyph vertices on same lines to apply line-based transformations. */ private static transform; /** * Typesets the given label, transforming the vertices in-world, ready to be rendered. * @param label - The label that is to be typeset. * @param vertices - in/out The glyph vertices, a prepared (optionally empty) vertex storage. * @returns - The number of glyphs that are actually typeset and setup as vertices. */ static typeset(label: Label, vertices: GlyphVertices): number; } export declare namespace Typesetter { enum FragmentType { Word = 0, Delimiter = 1, LineFeed = 2 } }