Tincture.Typography.Hyphen (Tincture v0.1.0)

Copy Markdown View Source

TeX hyphenation.

Splits a word into the points where a line break may fall, using Liang's pattern algorithm — the same approach TeX uses, with the same pattern files.

Hyphen.hyphenate("typography", :en_gb)
#=> ["ty", "po", "graphy"]

Supported locales: :en_gb, :da_dk, :fi_fi, :nb_no, :sv_se. The pattern files are bundled under priv/hyphen/; see NOTICE for their provenance.

The line breaker uses this to find candidate breaks inside long words, which is what lets justified text avoid the rivers of whitespace that greedy breaking without hyphenation produces in narrow columns.

Summary

Types

locale()

@type locale() :: :en_gb | :da_dk | :fi_fi | :nb_no | :sv_se

option()

@type option() :: {:left_min, pos_integer()} | {:right_min, pos_integer()}

Functions

hyphenate(word, locale \\ :en_gb, opts \\ [])

@spec hyphenate(String.t(), locale(), [option()]) :: [String.t()]