PaperForge.TextWrapper (PaperForge v0.2.0)

Copy Markdown View Source

Wraps text into lines that fit within a maximum width.

Text width is calculated using PaperForge.TextMetrics. Manual line breaks are preserved.

Summary

Functions

Splits a string into lines that do not exceed the requested width.

Types

option()

@type option() :: {:width, number()} | {:font, atom()} | {:size, number()}

Functions

wrap(text, options)

@spec wrap(binary(), [option()]) :: [binary()]

Splits a string into lines that do not exceed the requested width.

Examples

PaperForge.TextWrapper.wrap(
  "PaperForge generates PDF documents directly in Elixir",
  width: 200,
  font: :helvetica,
  size: 12
)