# Layout

## Content

# Class: Layout

Represents one or more paragraphs of multi-formatted text. Provides text analysis and layout functionality.

## Extends

- [`ObjectBase`](ObjectBase)

## Constructors

### Constructor

```ts
new Layout(layoutProperties?): Layout;
```

Creates a new Layout with specified properties.

#### Parameters

##### layoutProperties?

[`LayoutProperties`](../type-aliases/LayoutProperties)

The layout settings, including one or more paragraphs of multi-formatted text.

#### Returns

`Layout`

#### Overrides

```ts
ObjectBase.constructor
```

### Constructor

```ts
new Layout(baseLayout, layoutProperties?): Layout;
```

Creates a new Layout based on properties of an existing Layout.

#### Parameters

##### baseLayout

`Layout`

The Layout object used as the base for the new Layout.

##### layoutProperties?

[`LayoutProperties`](../type-aliases/LayoutProperties)

The settings overriding properties of the base Layout.

#### Returns

`Layout`

#### Overrides

```ts
ObjectBase.constructor
```

### Constructor

```ts
new Layout(om, layoutProperties?): Layout;
```

Creates a new Layout with specified properties.

#### Parameters

##### om

[`ObjectManager`](ObjectManager)

An object manager that controls the lifetime of the Layout object.

##### layoutProperties?

[`LayoutProperties`](../type-aliases/LayoutProperties)

The layout settings, including one or more paragraphs of multi-formatted text.

#### Returns

`Layout`

#### Overrides

```ts
ObjectBase.constructor
```

## Accessors

### addSpacingAfterLastLine

#### Get Signature

```ts
get addSpacingAfterLastLine(): boolean;
```

Gets a value indicating whether the line spacing should be added after the last line of text.

##### Returns

`boolean`

***

### allowOverhangingWords

#### Get Signature

```ts
get allowOverhangingWords(): boolean;
```

Gets a value indicating whether long words can overhang beyond the layout box bounds.

##### Returns

`boolean`

***

### canSkipFirstLineWithIndentation

#### Get Signature

```ts
get canSkipFirstLineWithIndentation(): boolean;
```

Gets a value indicating whether the whole first line of a paragraph with indentation can be skipped.

##### Returns

`boolean`

***

### codePoints

#### Get Signature

```ts
get codePoints(): Int32Array;
```

Gets the array of UTF-32 characters (code points) in a Layout.

##### Returns

`Int32Array`

***

### columnWidth

#### Get Signature

```ts
get columnWidth(): number;
```

Gets the width of the layout box measured from the left margin (for positive values) or from the right margin (for negative values), in graphic units.

##### Returns

`number`

***

### contentHeight

#### Get Signature

```ts
get contentHeight(): number;
```

Gets the height of the formatted text, in graphic units.

##### Returns

`number`

***

### contentHeightFitsInBounds

#### Get Signature

```ts
get contentHeightFitsInBounds(): boolean;
```

Gets a value indicating whether the height of the formatted text fits in the specified MaxHeight.

##### Returns

`boolean`

***

### contentRect

#### Get Signature

```ts
get contentRect(): Rect;
```

Gets a rectangle containing the formatted text, in graphic units.

##### Returns

[`Rect`](../type-aliases/Rect)

***

### contentWidth

#### Get Signature

```ts
get contentWidth(): number;
```

Gets the width of the formatted text, in graphic units.

##### Returns

`number`

***

### contentWidthFitsInBounds

#### Get Signature

```ts
get contentWidthFitsInBounds(): boolean;
```

Gets a value indicating whether the width of the formatted text fits in the specified MaxWidth.

##### Returns

`boolean`

***

### contentX

#### Get Signature

```ts
get contentX(): number;
```

Gets the X coordinate of the rectangle containing the formatted text, in graphic units.

##### Returns

`number`

***

### contentY

#### Get Signature

```ts
get contentY(): number;
```

Gets the Y coordinate of the rectangle containing the formatted text, in graphic units.

##### Returns

`number`

***

### defaultFormat

#### Get Signature

```ts
get defaultFormat(): Format;
```

Gets the [Format](Format) object used as default text format for the current Layout.

##### Returns

[`Format`](Format)

***

### defaultTabSize

#### Get Signature

```ts
get defaultTabSize(): number;
```

Gets spacing between the default tab stops, in graphic units.

##### Returns

`number`

***

### delimiterCharCode

#### Get Signature

```ts
get delimiterCharCode(): number;
```

Gets a UTF-32 character code used as a delimiter that signals the beginning of the portion of text to be preserved (for text trimming).

##### Returns

`number`

***

### delimiterCharCount

#### Get Signature

```ts
get delimiterCharCount(): number;
```

Gets the delimiter count, counting from the end of the text, to preserve text from (for text trimming).

##### Returns

`number`

***

### ellipsisCharCode

#### Get Signature

```ts
get ellipsisCharCode(): number;
```

Gets a UTF-32 code of the omission sign (ellipsis character) for text trimming. A value of 0 prevents the ellipsis character from showing.

##### Returns

`number`

***

### firstLineIndent

#### Get Signature

```ts
get firstLineIndent(): number;
```

Gets the indent of the first line after paragraph separator, in graphic units.
Positive value applies indentation to the first line, negative value applies indentation to all lines except the first one.

##### Returns

`number`

***

### firstLineIsStartOfParagraph

#### Get Signature

```ts
get firstLineIsStartOfParagraph(): boolean;
```

Gets a value indicating whether the first line of text is the start of paragraph.

##### Returns

`boolean`

***

### flowDirection

#### Get Signature

```ts
get flowDirection(): FlowDirection;
```

Gets the flow direction (how lines of text are placed relative to one another).

##### Returns

[`FlowDirection`](../enumerations/FlowDirection)

***

### fontCollection

#### Get Signature

```ts
get fontCollection(): FontCollection;
```

Gets the font collection used for searching fonts and font fallbacks.

##### Returns

[`FontCollection`](FontCollection)

***

### fontFallbackScope

#### Get Signature

```ts
get fontFallbackScope(): FontFallbackScope;
```

Gets the scope for searching fallback fonts for the glyphs missing in the font defined in [Format](Format).

##### Returns

[`FontFallbackScope`](../enumerations/FontFallbackScope)

***

### fontScaleFactor

#### Get Signature

```ts
get fontScaleFactor(): number;
```

Gets the uniform scale factor for all fonts used in the current Layout. Valid values are from 0.001 to 1000.

##### Returns

`number`

***

### hasMissingFontCharacters

#### Get Signature

```ts
get hasMissingFontCharacters(): boolean;
```

Gets a value indicating whether text runs contain some characters that are not present in
the specified fonts and fallback fonts, so those characters cannot be displayed correctly.

##### Returns

`boolean`

***

### honorIdeographicBaseline

#### Get Signature

```ts
get honorIdeographicBaseline(): boolean;
```

Gets a value indicating whether the ideographic baseline should be used instead of the Roman baseline for hieroglyph characters.

##### Returns

`boolean`

***

### honorLastLineSpacing

#### Get Signature

```ts
get honorLastLineSpacing(): boolean;
```

Gets a value indicating whether line spacing for the last line is considered a part of the layout content.

##### Returns

`boolean`

***

### honorTrailingLineBreak

#### Get Signature

```ts
get honorTrailingLineBreak(): boolean;
```

Gets a value indicating whether the trailing line break causes a blank line to be added to the output text layout.

##### Returns

`boolean`

***

### id

#### Get Signature

```ts
get id(): number;
```

Gets the reference to the object.

##### Returns

`number`

#### Inherited from

[`ObjectBase`](ObjectBase).[`id`](ObjectBase#id)

***

### justifiedSpaceExtension

#### Get Signature

```ts
get justifiedSpaceExtension(): number;
```

Gets the maximum white space extension factor before applying extension to other characters when text is justified. Values are between 0 and 10000.

##### Returns

`number`

***

### justifiedSpaceShrinking

#### Get Signature

```ts
get justifiedSpaceShrinking(): number;
```

Gets the white space shrinking factor when text is justified. Values are between 0.0 and 1.0.

##### Returns

`number`

***

### justifiedTextExtension

#### Get Signature

```ts
get justifiedTextExtension(): number;
```

Gets the maximum text extension factor when text is justified. Values are between 0 and 10000.

##### Returns

`number`

***

### justifyLastLine

#### Get Signature

```ts
get justifyLastLine(): boolean;
```

Gets a value indicating whether for paragraphs that have textAlignment set to "Distributed" the last line will be justified (typical in East Asian typography).

##### Returns

`boolean`

***

### lastLineIsEndOfParagraph

#### Get Signature

```ts
get lastLineIsEndOfParagraph(): boolean;
```

Gets a value indicating whether the last line of text is the end of paragraph.

##### Returns

`boolean`

***

### layoutPerformed

#### Get Signature

```ts
get layoutPerformed(): boolean;
```

Gets a value indicating if the [Layout#performLayout](#performlayout) method was executed at least once.

##### Returns

`boolean`

***

### lineBreakingRules

#### Get Signature

```ts
get lineBreakingRules(): LineBreakingRules;
```

Gets the line breaking algorithm.

##### Returns

[`LineBreakingRules`](../enumerations/LineBreakingRules)

***

### lineGapBeforeFirstLine

#### Get Signature

```ts
get lineGapBeforeFirstLine(): boolean;
```

Gets a value indicating whether the typographic line gap should be added before the first line of text.

##### Returns

`boolean`

***

### lines

#### Get Signature

```ts
get lines(): TextLine[];
```

Gets the array of text lines after executing the [Layout#performLayout](#performlayout) method.

##### Returns

[`TextLine`](../type-aliases/TextLine)[]

***

### linesBetweenConsecutiveHyphens

#### Get Signature

```ts
get linesBetweenConsecutiveHyphens(): number;
```

Gets the minimum number of lines not using hyphens after breaking a word across lines and displaying a visible hyphen at the position of soft hyphen.

##### Returns

`number`

***

### lineSpacingScaleFactor

#### Get Signature

```ts
get lineSpacingScaleFactor(): number;
```

Gets the scaling factor to be applied to the computed line height. Values are between 0 and 1000.

##### Returns

`number`

***

### marginBottom

#### Get Signature

```ts
get marginBottom(): number;
```

Gets the bottom margin of the layout box, in graphic units.

##### Returns

`number`

***

### marginLeft

#### Get Signature

```ts
get marginLeft(): number;
```

Gets the left margin of the layout box, in graphic units.

##### Returns

`number`

***

### marginRight

#### Get Signature

```ts
get marginRight(): number;
```

Gets the right margin of the layout box, in graphic units.

##### Returns

`number`

***

### marginTop

#### Get Signature

```ts
get marginTop(): number;
```

Gets the top margin of the layout box, in graphic units.

##### Returns

`number`

***

### maxHeight

#### Get Signature

```ts
get maxHeight(): number;
```

Gets the height of the layout box, in graphic units.

##### Returns

`number`

***

### maxLastLineOverflowFactor

#### Get Signature

```ts
get maxLastLineOverflowFactor(): number;
```

Gets the maximum fraction of the last line's height overflowing beyond the layout bounds for that line not to be truncated.

##### Returns

`number`

***

### maxWidth

#### Get Signature

```ts
get maxWidth(): number;
```

Gets the width of the layout box, in graphic units.

##### Returns

`number`

***

### minimalLineSpacing

#### Get Signature

```ts
get minimalLineSpacing(): number;
```

Gets the explicit minimal distance between lines, in graphic units.

##### Returns

`number`

***

### om

#### Get Signature

```ts
get om(): ObjectManager;
```

Gets the owner [ObjectManager](ObjectManager) instance.

##### Returns

[`ObjectManager`](ObjectManager)

#### Inherited from

[`ObjectBase`](ObjectBase).[`om`](ObjectBase#om)

***

### paragraphAlignment

#### Get Signature

```ts
get paragraphAlignment(): ParagraphAlignment;
```

Gets the alignment of paragraphs along the flow direction axis.

##### Returns

[`ParagraphAlignment`](../enumerations/ParagraphAlignment)

***

### paragraphSpacing

#### Get Signature

```ts
get paragraphSpacing(): number;
```

Gets the additional spacing between paragraphs, in graphic units.

##### Returns

`number`

***

### restrictedFontLookup

#### Get Signature

```ts
get restrictedFontLookup(): boolean;
```

Gets a value indicating whether the fonts should be searched in the custom collection only, if any specified.

##### Returns

`boolean`

***

### rightToLeft

#### Get Signature

```ts
get rightToLeft(): boolean;
```

Gets the base direction for horizontal and sideways text.

##### Returns

`boolean`

***

### rotateSidewaysCounterclockwise

#### Get Signature

```ts
get rotateSidewaysCounterclockwise(): boolean;
```

Gets a value indicating whether sideways text should be rotated counterclockwise.

##### Returns

`boolean`

***

### rowHeight

#### Get Signature

```ts
get rowHeight(): number;
```

Gets the height of the layout box measured from the top margin (for positive values) or from the bottom margin (for negative values), in graphic units.

##### Returns

`number`

***

### softHyphenReplacementCharCode

#### Get Signature

```ts
get softHyphenReplacementCharCode(): number;
```

Gets a UTF-32 character code used as replacement for soft hyphen characters (0x00AD) at ends of lines when breaking words across lines.

##### Returns

`number`

***

### suppressShaping

#### Get Signature

```ts
get suppressShaping(): boolean;
```

Gets a value indicating if shaping and positioning of graphemes should be skipped for the sake of speed.

##### Returns

`boolean`

***

### tabStops

#### Get Signature

```ts
get tabStops(): TabStop[];
```

Gets the array of custom tab stops.

##### Returns

[`TabStop`](../type-aliases/TabStop)[]

***

### textAlignment

#### Get Signature

```ts
get textAlignment(): TextAlignment;
```

Gets the alignment of text along the reading direction axis.

##### Returns

[`TextAlignment`](../enumerations/TextAlignment)

***

### textExtensionStrategy

#### Get Signature

```ts
get textExtensionStrategy(): TextExtensionStrategy;
```

Gets the rules used for justified text extension.

##### Returns

[`TextExtensionStrategy`](../enumerations/TextExtensionStrategy)

***

### trimmingGranularity

#### Get Signature

```ts
get trimmingGranularity(): TrimmingGranularity;
```

Gets the text granularity used to trim text overflowing the layout box.

##### Returns

[`TrimmingGranularity`](../enumerations/TrimmingGranularity)

***

### uniformLineSpacing

#### Get Signature

```ts
get uniformLineSpacing(): number;
```

Gets the explicit distance between lines, in graphic units.

##### Returns

`number`

***

### useEmbeddableFonts

#### Get Signature

```ts
get useEmbeddableFonts(): boolean;
```

Get a value indicating if the linked and fallback fonts have to be embeddable.

##### Returns

`boolean`

***

### vertical

#### Get Signature

```ts
get vertical(): boolean;
```

Gets a value indicating whether the [LayoutProperties#flowDirection](../type-aliases/LayoutProperties#flowdirection) was vertical when the [Layout#performLayout](#performlayout) method was last called.

##### Returns

`boolean`

***

### wordBoundaryRules

#### Get Signature

```ts
get wordBoundaryRules(): WordBoundaryRules;
```

Gets a value specifying the algorithm for detecting word boundaries (for text justification and text trimming).

##### Returns

[`WordBoundaryRules`](../enumerations/WordBoundaryRules)

***

### wrapMode

#### Get Signature

```ts
get wrapMode(): WrapMode;
```

Gets a value specifying text wrapping behavior to prevent text from flowing outside the layout box.

##### Returns

[`WrapMode`](../enumerations/WrapMode)

## Methods

### append()

#### Call Signature

```ts
append(text): void;
```

Adds text with default format to the current Layout.

##### Parameters

###### text

`string`

The text to append.

##### Returns

`void`

#### Call Signature

```ts
append(text, format): void;
```

Adds text with specified format to the current Layout.

##### Parameters

###### text

`string`

The text to append.

###### format

[`Format`](Format)

The text format to use.

##### Returns

`void`

#### Call Signature

```ts
append(
   text, 
   font, 
   fontSize, 
   foreColor): void;
```

Adds text with specified format attributes to the current Layout.

##### Parameters

###### text

`string`

The text to append.

###### font

[`Font`](Font)

The font to use.

###### fontSize

`number`

The font size.

###### foreColor

[`Color`](../type-aliases/Color)

The text color.

##### Returns

`void`

#### Call Signature

```ts
append(runProperties): void;
```

Adds a text run with specified format to the current Layout.

##### Parameters

###### runProperties

[`RunProperties`](../type-aliases/RunProperties)

A text section (run) with formatting.

##### Returns

`void`

***

### appendLine()

#### Call Signature

```ts
appendLine(text): void;
```

Adds text and line break characters (0x0D, 0x0A) with default format to the current Layout.

##### Parameters

###### text

`string`

The text to append.

##### Returns

`void`

#### Call Signature

```ts
appendLine(text, format): void;
```

Adds text and line break characters (0x0D, 0x0A) with specified format to the current Layout.

##### Parameters

###### text

`string`

The text to append.

###### format

[`Format`](Format)

The text format to use.

##### Returns

`void`

#### Call Signature

```ts
appendLine(
   text, 
   font, 
   fontSize, 
   foreColor): void;
```

Adds text and line break characters (0x0D, 0x0A) with specified format attributes to the current Layout.

##### Parameters

###### text

`string`

The text to append.

###### font

[`Font`](Font)

The font to use.

###### fontSize

`number`

The font size.

###### foreColor

[`Color`](../type-aliases/Color)

The text color.

##### Returns

`void`

#### Call Signature

```ts
appendLine(runProperties): void;
```

Adds a text run and line break characters (0x0D, 0x0A) with specified format to the current Layout.

##### Parameters

###### runProperties

[`RunProperties`](../type-aliases/RunProperties)

A text section (run) with formatting.

##### Returns

`void`

***

### appendLineBreak()

```ts
appendLineBreak(format?): void;
```

Adds line break characters (0x0D, 0x0A).

#### Parameters

##### format?

[`Format`](Format)

Text format, if specified, the default format is used otherwise.

#### Returns

`void`

***

### appendParagraphBreak()

```ts
appendParagraphBreak(format?): void;
```

Adds a special character (0x2029) that causes a paragraph break but prevents a page break between paragraphs.

#### Parameters

##### format?

[`Format`](Format)

Text format, if specified, the default format is used otherwise.

#### Returns

`void`

***

### appendSectionBreak()

```ts
appendSectionBreak(format?): void;
```

Appends a form feed character ('\f', character code 0x000C) to the text. This causes
any text added after it to "not fit" - if the text layout is drawn, that text will not be rendered.
If the [Layout#split](#split) method is called, the text will be split at this point.

#### Parameters

##### format?

[`Format`](Format)

Text format, if specified, the default format is used otherwise.

#### Returns

`void`

***

### appendSoftBreak()

```ts
appendSoftBreak(format?): void;
```

Adds a line separator character (0x2028) that causes a line break without ending the paragraph.

#### Parameters

##### format?

[`Format`](Format)

Text format, if specified, the default format is used otherwise.

#### Returns

`void`

***

### applyOffset()

```ts
applyOffset(dx, dy): void;
```

Adjusts the positions of content rectangle.

#### Parameters

##### dx

`number`

The offset along the horizontal direction.

##### dy

`number`

The offset along the vertical direction.

#### Returns

`void`

***

### clear()

```ts
clear(): void;
```

Clears the current text layout, removing all text and formatting associated with individual text runs.

#### Returns

`void`

***

### free()

```ts
free(): void;
```

Detaches the object from the [ObjectManager](ObjectManager) and deallocates its memory, if possible.

#### Returns

`void`

#### Inherited from

[`ObjectBase`](ObjectBase).[`free`](ObjectBase#free)

***

### performLayout()

```ts
performLayout(): boolean;
```

Determines the coordinates of all text lines and glyph runs.

#### Returns

`boolean`

true if the whole text fits in the bounds of Layout, false if some text doesn't fit
in bounds and the [Layout#split](#split) method must be executed to move the rest of the text into another Layout instance.

***

### rebind()

```ts
rebind(omTo): void;
```

Rebinds the object from the current [ObjectManager](ObjectManager) to the specified one.

#### Parameters

##### omTo

[`ObjectManager`](ObjectManager)

The new [ObjectManager](ObjectManager) for the object.

#### Returns

`void`

#### Inherited from

[`ObjectBase`](ObjectBase).[`rebind`](ObjectBase#rebind)

***

### split()

```ts
split(splitOptions, rest): SplitResult;
```

Fits all or the first portion of the current text layout into the current layout bounds.
If the whole text did not fit into the bounds, the rest is moved into the Layout instance
specified by the 'rest' parameter.

#### Parameters

##### splitOptions

[`SplitOptions`](SplitOptions)

Options controlling how text is split.

##### rest

`Layout`

Recipient for the text that did not fit in the current bounds.

#### Returns

[`SplitResult`](../enumerations/SplitResult)

A value indicating the result of splitting the current text layout.

***

### truncate()

```ts
truncate(lastLineTrimming?): boolean;
```

If a portion of the text content does not fit into the current layout bounds, removes
that portion so that the remaining text fits.
Returns true if at least some text remains that fits into the current layout bounds.
Returns false if the current layout did not contain any text or all text had to be removed.
Note that if there is only one line, and it does not fit into the available height,
it is not removed, and this method returns true.

#### Parameters

##### lastLineTrimming?

[`TrimmingGranularity`](../enumerations/TrimmingGranularity)

The text granularity used when trimming the last line of text.

#### Returns

`boolean`
