1 <FlowDocument xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
2 TextAlignment="Justify"
3 IsOptimalParagraphEnabled="True"
4 IsHyphenationEnabled="True"
5 IsColumnWidthFlexible="True"
12 “One of the most important operations necessary when text materials
13 are prepared for printing or display is the task of dividing long
14 paragraphs into individual lines. When this job has been done well,
15 people will not be aware of the fact that the words they are reading
16 have been broken apart arbitrarily and placed into a somewhat rigid
17 and unnatural rectangular framework; but if the job has been done
18 poorly, readers will be distracted by bad breaks that interrupt
19 their train of thought.”
23 <Hyperlink NavigateUri="http://www-cs-faculty.stanford.edu/~knuth/">
29 Principle of Optimal Paragraph
33 Knuth started his revolutionary work of developing a computer program to
34 produce high quality publication in the late ’70. The program he developed
35 called TEX (pronounced “tek”) is highly regarded as the work that helps
36 shape the field of digital typography and desktop publishing. It is still
37 being widely used and constantly extended by many others up to today. One
38 of the most intriguing inventions in this program is its ability to produce
39 superior quality paragraph layout for printing and reading purpose – arguably
40 comparable to the work manually done by most respectable publishers of the
41 modern times. This typographically beautiful paragraph layout is driven by
42 a line breaking algorithm known as <Italic>total-fit</Italic> or
43 <Italic>optimum-fit</Italic> algorithm. Some call the kind of paragraph
44 produced by this algorithm <Italic>Optimal Paragraph</Italic>.
47 In principle, the task of text formatting consists of two main components:
48 choosing where to end individual lines and how to justify the lines. The first
49 component may involve the task of word division called <Italic>hyphenation</Italic>.
50 Line justification is the task of fitting a line into a desired width. Usually
51 it is done by distributing the extra space into or taking out excess space
52 from inter-word spaces in the line. Line justification is strongly dependent
53 to line breaking. When line breaking is done properly, justification can be
54 done without the need to change the spacing too much and thereby avoiding
55 holes between words that would distress the eyes of the reader.
58 Unlike a standard line breaking algorithm which breaks the line without taking
59 into account the line that may come after it, the total-fit algorithm breaks
60 line by looking ahead on what may come later in the paragraph and make a single
61 decision to break all the lines at once. The main idea of the algorithm is to
62 provide a way to break a paragraph into lines so that the inter-word spacing is
63 balanced between all the lines of the paragraph. This is attained by choosing
64 the sequence of breakpoints with the minimal total cost over all lines. The
65 cost of a line depends on many factors that can affect the visual appearance
66 of the line, such as the measure of inter-word space changing, the division of
67 the last word of the line, etc.
71 A paragraph is considered optimal when all inter-word spaces over all lines are set as
72 close as possible to the ideal inter-word spaces. Therefore, an optimum paragraph is in
73 fact a paragraph composed in such a way that the total contrast of inter-word spaces set
74 in all lines with the ideal inter-word spaces cannot be reduced anymore.