loom & weft
Made for Swift.

Published release 0.2.1. Unreleased PR #2 reference.

LOOM 0.2.1 / WIDGETS

CharacterArt

Preserves artwork spacing without wrapping. Measures terminal-cell dimensions once, including a trailing newline’s extra row. Empty artwork has width 0 and height 1. Blank cells in its natural rectangle are painted with its style; additional assigned area is untouched.

Standard inherited Swift protocol operations such as synthesized equality and OptionSet set operations are not repeated. The public declarations below are extracted from the exact source revision listed in the coverage manifest.

Example

let art = CharacterArt(" /\\_/\\\n( o.o )", style: Style(foreground: .rgb(237, 166, 98)))
_ = (art.width, art.height)
Members on this page

Feature guides and release status

CharacterArt

Structure
struct CharacterArt

Conforms to: Swift.Sendable, Swift.SendableMetatype, Widget.

Draws character artwork at its original spacing without wrapping.

Width and height are measured in terminal cells. Tabs advance to four-column stops, and terminal controls are removed using the same rules as TextLayout. Every newline starts a row, including a trailing newline; an empty source has width zero and height one. Blank cells inside the artwork's natural rectangle are painted with its style. Extra space in the assigned area remains untouched.

Source · CharacterArt.swift:10

width

Instance Property
let width: Int

Width in terminal cells.

Source · CharacterArt.swift:11

height

Instance Property
let height: Int

Height in terminal cells.

Source · CharacterArt.swift:12

style

Instance Property
var style: Style

Visual attributes used when painting this value.

Source · CharacterArt.swift:13

init(_:style:)

Initializer
init(_ source: String, style: Style = Style())

Measures and caches artwork once, preserving explicit line breaks.

Parameters (2)
source
Argument type and any default are shown in the declaration; see the behavior notes above.
style
Text/cell appearance.
Source · CharacterArt.swift:18

render(in:buffer:)

Instance Method
func render(in area: Rect, buffer: inout Buffer)

Clips to the assigned area and buffer without drawing partial wide graphemes.

Parameters (2)
in
Argument type and any default are shown in the declaration; see the behavior notes above.
buffer
Mutable destination cell grid.
Source · CharacterArt.swift:27