UNPKG

@itwin/core-common

Version:

iTwin.js components common to frontend and backend

173 lines 8.49 kB
/** @packageDocumentation * @module Annotation */ import { ColorDefProps } from "../ColorDef"; /** Specifies how to separate the numerator and denominator of a [[FractionRun]], by either a horizontal or diagonal bar. * @see [[TextStyleSettingsProps.stackedFractionType]] and [[TextStyleSettings.stackedFractionType]]. * @beta */ export type StackedFractionType = "horizontal" | "diagonal"; /** Describes the color in which to draw the text in a [[TextRun]]. * "subcategory" indicates that the text should be drawn using the color of the [SubCategory]($backend) specified by the [GeometryStream]($docs/learning/common/GeometryStream.md) hosting the * text. * @beta */ export type TextStyleColor = ColorDefProps | "subcategory"; /** Serves both as the JSON representation of a [[TextStyleSettings]], and a way for a [[TextBlockComponent]] to selectively override aspects of a [[TextStyle]]'s properties. * @beta */ export interface TextStyleSettingsProps { /** The color of the text. * Default: "subcategory". */ color?: TextStyleColor; /** The name of a font stored in a [Workspace]($backend), used to draw the contents of a [[TextRun]]. * Default: "" (an invalid font name). */ fontName?: string; /** The height each line of text, in meters. Many other settings use the line height as the basis for computing their own values. * For example, the height and offset from baseline of a subscript [[TextRun]] are compuated as lineHeight * [[subScriptScale]] and * lineHeight * [[subScriptOffsetFactor]], respectively. * Default: 1.0. */ lineHeight?: number; /** Multiplier used to compute the vertical distance between two lines of text. * The distance is computed in meters as lineSpacingFactor * [[lineHeight]]. * Default: 0.5. */ lineSpacingFactor?: number; /** Specifies whether the content of a [[TextRun]] should be rendered **bold**. * Default: false. */ isBold?: boolean; /** Specifies whether the content of a [[TextRun]] should be rendered in *italics*. * Default: false. */ isItalic?: boolean; /** Specifies whether the content of a [[TextRun]] should be underlined. * Default: false. */ isUnderlined?: boolean; /** Multiplier used to compute the height of both the numerator and denominator of a [[FractionRun]]. * The height is computed in meters as stackedFractionScale * [[lineHeight]]. * Default: 0.7. */ stackedFractionScale?: number; /** Specifies how to separate the numerator and denominator of a [[FractionRun]]. * Default: "horizontal". */ stackedFractionType?: StackedFractionType; /** Multiplier used to compute the vertical offset from the baseline for a subscript [[TextRun]]. * The offset is computed in meters as subScriptOffsetFactor * [[lineHeight]]. * Default: -0.15. */ subScriptOffsetFactor?: number; /** Multiplier used to compute the height of a subscript [[TextRun]]. * The height is computed as subScriptScale * [[lineHeight]]. * Default: 2/3 */ subScriptScale?: number; /** Multiplier used to compute the vertical offset from the baseline for a super [[TextRun]]. * The offset is computed in meters as superScriptOffsetFactor * [[lineHeight]]. * Default: -0.5. */ superScriptOffsetFactor?: number; /** Multiplier used to compute the height of a superscript [[TextRun]]. * The height is computed as superScriptScale * [[lineHeight]]. * Default: 2/3 */ superScriptScale?: number; /** A scale applied to the width of each glyph. * Default: 1.0 */ widthFactor?: number; } /** A description of the formatting to be applied to a [[TextBlockComponent]]. * Named instances of these settings can be stored as [[TextStyle]]s in a [Workspace]($backend). * @note This is an immutable type. Use [[clone]] to create a modified copy. * @see [[TextStyleSettingsProps]] for documentation of each of the settings. * @beta */ export declare class TextStyleSettings { /** The color of the text. */ readonly color: TextStyleColor; /** The name of a font stored in a [Workspace]($backend), used to draw the contents of a [[TextRun]]. */ readonly fontName: string; /** The height each line of text, in meters. Many other settings use the line height as the basis for computing their own values. * For example, the height and offset from baseline of a subscript [[TextRun]] are compuated as lineHeight * [[subScriptScale]] and * lineHeight * [[subScriptOffsetFactor]], respectively. */ readonly lineHeight: number; /** Multiplier used to compute the vertical distance between two lines of text. * The distance is computed in meters as lineSpacingFactor * [[lineHeight]]. */ readonly lineSpacingFactor: number; /** Specifies whether the content of a [[TextRun]] should be rendered **bold**. */ readonly isBold: boolean; /** Specifies whether the content of a [[TextRun]] should be rendered in *italics*. */ readonly isItalic: boolean; /** Specifies whether the content of a [[TextRun]] should be underlined. */ readonly isUnderlined: boolean; /** Multiplier used to compute the height of both the numerator and denominator of a [[FractionRun]]. * The height is computed in meters as stackedFractionScale * [[lineHeight]]. */ readonly stackedFractionScale: number; /** Specifies how to separate the numerator and denominator of a [[FractionRun]]. */ readonly stackedFractionType: StackedFractionType; /** Multiplier used to compute the vertical offset from the baseline for a subscript [[TextRun]]. * The offset is computed in meters as subScriptOffsetFactor * [[lineHeight]]. */ readonly subScriptOffsetFactor: number; /** Multiplier used to compute the height of a subscript [[TextRun]]. * The height is computed as subScriptScale * [[lineHeight]]. */ readonly subScriptScale: number; /** Multiplier used to compute the vertical offset from the baseline for a super [[TextRun]]. * The offset is computed in meters as superScriptOffsetFactor * [[lineHeight]]. */ readonly superScriptOffsetFactor: number; /** Multiplier used to compute the height of a superscript [[TextRun]]. * The height is computed as superScriptScale * [[lineHeight]]. */ readonly superScriptScale: number; /** Multiplier used to compute the width of each glyph, relative to [[lineHeight]]. */ readonly widthFactor: number; /** A fully-populated JSON representation of the default settings. */ static defaultProps: Readonly<Required<TextStyleSettingsProps>>; /** Settings initialized to all default values. */ static defaults: TextStyleSettings; private constructor(); /** Create a copy of these settings, modified according to the properties defined by `alteredProps`. */ clone(alteredProps?: TextStyleSettingsProps): TextStyleSettings; /** Create settings from their JSON representation. */ static fromJSON(props?: TextStyleSettingsProps): TextStyleSettings; toJSON(): TextStyleSettingsProps; equals(other: TextStyleSettings): boolean; } /** The JSON representation of a [[TextStyle]]. * @beta */ export interface TextStyleProps { /** The name of the style. */ name: string; /** The settings defined for the style. Any omitted properties will use their default values, as described by [[TextStyleSettingsProps]]. */ settings?: TextStyleSettingsProps; } /** A named, immutable [[TextStyleSettings]] stored in a [Workspace]($backend). * @see [[TextBlockComponent.styleName]] to define the text style for a component of a [[TextBlock]]. * @note This is an immutable type. Use [[clone]] to create a modified copy. * @beta */ export declare class TextStyle { readonly name: string; readonly settings: TextStyleSettings; private constructor(); /** Create a style from its JSON representation. */ static fromJSON(json: TextStyleProps): TextStyle; /** Create a new style. */ static create(name: string, settings: TextStyleSettings): TextStyle; /** Create a copy of this style with the same name, and settings modified according to the properties defined by `alteredSettings`. */ clone(alteredSettings: TextStyleSettingsProps): TextStyle; equals(other: TextStyle): boolean; } //# sourceMappingURL=TextStyle.d.ts.map