Table of Contents

Class PatternHyphenator

Namespace
MiPdf.Layout
Assembly
MiPdf.dll

Liang's hyphenation algorithm (as used by TeX) with pattern files from the hyph-utf8 project, e.g. hyph-de-1996.tex (German), hyph-de-ch-1901.tex (Swiss German) or hyph-en-us.tex. Load patterns with FromTex(string, int, int); the pattern files are not bundled.

public sealed class PatternHyphenator : IHyphenator
Inheritance
PatternHyphenator
Implements
Inherited Members

Examples

var german = PatternHyphenator.FromTex(File.ReadAllText("hyph-de-1996.tex"));
TextLayout.DefaultHyphenator = german;           // or per paragraph: paragraph.Hyphenator = german

Constructors

PatternHyphenator(IEnumerable<string>, IEnumerable<string>?, int, int)

public PatternHyphenator(IEnumerable<string> patterns, IEnumerable<string>? exceptions = null, int leftMin = 2, int rightMin = 2)

Parameters

patterns IEnumerable<string>

Patterns such as "hy3ph" or ".ab1c" (digits mark break priorities).

exceptions IEnumerable<string>

Exception words with explicit hyphens, e.g. "ta-ble".

leftMin int

Minimum number of characters before a break.

rightMin int

Minimum number of characters after a break.

Properties

LeftMin

Minimum number of characters before a break.

public int LeftMin { get; }

Property Value

int

RightMin

Minimum number of characters after a break.

public int RightMin { get; }

Property Value

int

Methods

FromTex(string, int, int)

Loads a TeX pattern file (\patterns{...} and optional \hyphenation{...}).

public static PatternHyphenator FromTex(string tex, int leftMin = 2, int rightMin = 2)

Parameters

tex string
leftMin int
rightMin int

Returns

PatternHyphenator

GetBreakPoints(string)

Returns the indexes i where a hyphen may be inserted before word[i], honoring LeftMin and RightMin. Exception words return their explicit hyphen positions. Matching is case-insensitive.

public IReadOnlyList<int> GetBreakPoints(string word)

Parameters

word string

Returns

IReadOnlyList<int>