loom & weft
Made for Swift.

Published release 0.2.1. Unreleased PR #2 reference.

LOOM 0.2.1 / TEXT, MARKDOWN, AND EDITING

terminalCellWidth

Measures one Character as terminal cells using weft’s Unicode width rules. Emulator/font choices can vary; TextLayout accepts a custom measurement closure if your app needs a different width policy.

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

_ = loom.terminalCellWidth(Character("界"))

Feature guides and release status

terminalCellWidth(_:)

Function
func terminalCellWidth(_ character: Character) -> Int

Measures one Character as terminal cells using weft’s Unicode width rules. Emulator/font choices can vary; TextLayout accepts a custom measurement closure if your app needs a different width policy.

Parameters (1)
character
Argument type and any default are shown in the declaration; see the behavior notes above.

Returns Int.

Source · TerminalExports.swift:21

terminalCellWidth(_:)

Function
func terminalCellWidth(_ character: Character) -> Int

Estimates the terminal cells occupied by one extended grapheme cluster.

This locale-independent policy treats combining marks, controls and default-ignorable scalars as zero cells, ambiguous-width characters as narrow, and East Asian wide/fullwidth characters as two cells. Emoji presentation sequences occupy two cells. VS15 requests text presentation but does not narrow an inherently East Asian wide character. Terminals may differ; renderers can substitute a width policy for a particular terminal.

Parameters (1)
character
Argument type and any default are shown in the declaration; see the behavior notes above.

Returns Int.

Source · CharacterWidth.swift:8