UNPKG

@itwin/core-common

Version:

iTwin.js components common to frontend and backend

254 lines • 12.6 kB
/** @packageDocumentation * @module Annotation */ import { DeepReadonlyObject, DeepRequiredObject } from "@itwin/core-bentley"; import { ColorDefProps } from "../ColorDef"; /** Set of predefined shapes that can be computed and drawn around the margins of a [[TextBlock]] * @beta */ export declare const textAnnotationFrameShapes: readonly ["none", "line", "rectangle", "circle", "equilateralTriangle", "diamond", "square", "pentagon", "hexagon", "octagon", "capsule", "roundedRectangle"]; /** Describes a predefined shape that can be computed and drawn around the margins of a [[TextBlock]] * @beta */ export type TextAnnotationFrameShape = typeof textAnnotationFrameShapes[number]; /** * Describes what color to use when filling the frame around a [[TextBlock]]. * If `background` is specified, [[GeometryParams.BackgroundFill]] will be set to `BackgroundFill.Outline`. * If `none` is specified, no fill will be applied. * @beta */ export type TextAnnotationFillColor = TextStyleColor | "background" | "none"; /** 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"; /** * Describes how to draw the frame around a [[TextAnnotation]]. * The frame can be a simple line, a filled shape, or both. * If only a subset of properties are specified, the others will be set to their default value. * @beta */ export interface TextFrameStyleProps { /** Shape of the frame. Default: "none" */ shape?: TextAnnotationFrameShape; /** The color to fill the shape of the text frame. This fill is applied using [[FillDisplay.Blanking]]. Default: "none" */ fill?: TextAnnotationFillColor; /** The color of the text frame's outline. Default: black */ border?: TextStyleColor; /** This will be used to set the [[GeometryParams.weight]] property of the frame (in pixels). Default: 1px */ borderWeight?: number; } /** Properties describing the appearance of [[TextAnnotationLeader]] in a [[TextAnnotation]]. * Used when producing geometry for [[TextAnnotation]]. * @beta */ export interface TextLeaderStyleProps { /** The color of the leader. * If `inherit` is specified, the [[TextAnnotationLeader]] will use the color specified in the parent [[TextStyleSettings]]`. * Default: "inherit". */ color?: TextStyleColor | "inherit"; /** Whether to use an elbow in the leader. * Default: false */ wantElbow?: boolean; /** Multiplier used to compute length of the elbow in the leader. * The elbowLength is computed in meters as elbowLength * [[lineHeight]]. * Default: 1.0 */ elbowLength?: number; /** Multiplier to compute height of the leader terminator. * The terminator height is computed in meters as terminatorHeight * [[lineHeight]]. * Default: 1.0 */ terminatorHeightFactor?: number; /** Multiplier to compute width of the leader terminator. * The terminator width is computed in meters as terminatorWidth * [[lineHeight]]. * Default: 1.0 */ terminatorWidthFactor?: number; } /** Serves both as the JSON representation of a [[TextStyleSettings]], and a way for a [[TextBlockComponent]] to selectively override aspects of a [AnnotationTextStyle]($backend)'s properties. * @beta */ export interface TextStyleSettingsProps { /** The color of the text. * Default: "subcategory". */ color?: TextStyleColor; /** The name of a font stored in an iModel, 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 computed 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; /** Properties describing appearance of leaders in a [[TextAnnotation]] * Used when producing geometry for [[TextAnnotation]] * Default: {color:"subcategory", wantElbow:"false",elbowLength:1, terminatorWidthFactor:1, terminatorHeightFactor:1}. */ leader?: TextLeaderStyleProps; /** The size (in meters) used to calculate the tab stops in a run. * These are equally spaced from the left edge of the TextBlock. * Default: 4 meters. */ tabInterval?: number; /** * A description of the frame around the text annotation. * Used when producing geometry for [[TextAnnotation]]s. * Default: {shape: "none", fill: "none", border: black, borderWeight: 1} for no frame. */ frame?: TextFrameStyleProps; } /** A description of the formatting to be applied to a [[TextBlockComponent]]. * Named instances of these settings can be stored as [AnnotationTextStyle]($backend)s in an iModel. * @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 an iModel, 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 computed 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; /** Properties describing appearance of leaders in a [[TextAnnotation]]. * Used when producing geometry for [[TextAnnotation]]. */ readonly leader: Readonly<Required<TextLeaderStyleProps>>; /** The size (in meters) used to calculate the tab stops in a run. * These are equally spaced from the left edge of the TextBlock. Default is 4 meters. */ readonly tabInterval: number; /** The frame settings of the [[TextAnnotation]]. */ readonly frame: Readonly<Required<TextFrameStyleProps>>; /** A fully-populated JSON representation of the default settings. A real `fontName` must be provided before use. */ static defaultProps: DeepReadonlyObject<DeepRequiredObject<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; /** Creates a deep copy of the `TextStyleSettingsProps`. */ static cloneProps(props: TextStyleSettingsProps): TextStyleSettingsProps; /** Create settings from their JSON representation. */ static fromJSON(props?: TextStyleSettingsProps): TextStyleSettings; toJSON(): TextStyleSettingsProps; /** Compare two [[TextLeaderStyleProps]] for equality. * @param other The other leader style properties to compare against. * @returns true if the two leader styles are equal, false otherwise. */ leaderEquals(other: TextLeaderStyleProps): boolean; frameEquals(other: TextFrameStyleProps): boolean; equals(other: TextStyleSettings): boolean; /** * Returns a list of validation errors for this instance. * * A TextStyleSettings object may contain values that are invalid in all contexts. * If this method returns any error strings, using the settings will likely result in rendering failures or runtime exceptions. * * This method only checks for universally invalid values. Additional domain-specific validation may be required depending on the context in which these settings are used. * * @returns An array of error strings describing the invalid values, or an empty array if the settings are valid. */ getValidationErrors(): string[]; } //# sourceMappingURL=TextStyle.d.ts.map