VMPrint API Reference - v1.0.0
    Preparing search index...

    Class LayoutEngine

    LayoutEngine shapes elements into flow boxes, paginates them, and returns positioned page boxes for rendering.

    Hierarchy

    • LayoutProcessor
      • LayoutEngine
    Index

    Constructors

    Properties

    config: LayoutConfig
    fallbackFonts: any[] = []
    font: any = null
    fontPromise: Promise<void> | null = null
    runtime: EngineRuntime

    Methods

    • Calculates the effective line height for a single line, accounting for baseline alignment spread in mixed-script lines.

      Parameters

      • line: RichLine
      • baseFontSize: number
      • lineHeight: number

      Returns number

    • Calculates the total height of a set of wrapped lines. Uses a UNIFORM line height across all lines in the element (the max effective height of any single line) so that mixed-script paragraphs have consistent vertical spacing throughout.

      Parameters

      Returns number

    • Parameters

      • glyphs: { char: string; x: number; y: number }[]

      Returns { char: string; x: number; y: number }[]

    • Calculates the available content width for a style definition.

      Parameters

      • Optionalstyle: any

      Returns number

    • Returns the optical scaling factor for a given script class. These factors adjust the rendered font size so secondary scripts appear visually harmonious with the primary (Latin) text.

      Parameters

      • scriptClass: string

      Returns number

    • Classifies the dominant script of a text string based on its first non-space character's Unicode code point.

      Parameters

      • text: string

      Returns string

    • Parameters

      • unit: FlowBox
      • Optionalcontext: FlowMaterializationContext

      Returns FlowBox

    • Returns the width in points of a given string using fontkit's layout. Optionally populates the glyph positions if a segment object is provided.

      Parameters

      • text: string
      • Optionalfont: any
      • OptionalfontSize: number
      • letterSpacing: number = 0
      • OptionalpopulateSegment: TextSegment

      Returns number

    • Parameters

      • element: Element
      • OptionalidentitySeed: FlowIdentitySeed

      Returns NormalizedFlowBlock

    • Parameters

      • unit: FlowBox
      • currentY: number
      • layoutBefore: number
      • margins: { left: number }
      • _pageWidth: number
      • pageIndex: number

      Returns Box | Box[]

    • Parameters

      • familyName: string
      • weight: string | number
      • style: string = 'normal'

      Returns any

    • Segments text into chunks based on which enabled font supports the characters.

      Parameters

      • text: string
      • OptionalpreferredFamily: string
      • OptionalpreferredLocale: string
      • OptionalfallbackFamiliesOverride: string[]
      • OptionalsharedFontCache: Map<string, any>

      Returns { fontName?: string; fontObject?: any; text: string }[]

    • Parameters

      • factory: ExternalPackagerFactory | undefined

      Returns void

    • Parameters

      • block: NormalizedFlowBlock

      Returns FlowBox

    • Parameters

      • text: string

      Returns { isCJK: boolean; text: string }[]

    • Parameters

      • box: FlowBox
      • availableHeight: number
      • layoutBefore: number

      Returns { partA: FlowBox; partB: FlowBox } | null

    • Specialized word-wrapper for rich text segments.

      Parameters

      • segments: TextSegment[]
      • maxWidth: number
      • font: any
      • fontSize: number
      • letterSpacing: number = 0
      • textIndent: number = 0
      • OptionallineLayoutResolver: (lineIndex: number) => { width: number; xOffset: number; yOffset?: number }
      • OptionallineLayoutOut: { offsets: number[]; widths: number[]; yOffsets: number[] }

      Returns RichLine[]