This is a classical programming problem, originally described by Peter Naur, commonly known as the "TelegramProblem" (see DataFlow wiki http://www.jpaulmorrison.com/cgi-bin/wiki.pl?TelegramProblem) ---- Filling and justifying the words of a paragraph is a global computation that has sent more than one author off to study the techniques of the hot metal Linotype operator. DonKnuth and his students have studied computerization of the problem in some detail. AlanKay has used the problem as a test case for object-oriented programming systems. I first heard of his tradition in the context of PlayGround. What would be the instructions one would give characters that had to compose themselves? * Stay with your word, if possible, otherwise stay with your syllable and use a hyphen to split your word. * If you're not evenly spaced, move a little bit to be so. * If you're not comfortably spaced then let the letters at the front and back of your word know. If you're one of those letters then pass it on to the beginning or end of the line. If you're already there, try jumping to another line. ---- A comment from the ignorant: I think that one really interesting question is "how far apart are these two letters (symbols)?" "Distance between letters" is easy to compute for a row of "XXXXXXXX", but the "distance" between the letters "To" may need to account for the leading edge of the 'T' overlapping the 'o' -- so the closest point between the two letters may be measured up from the 'o' to the overlapping 'T'. ''So, a character looks at its neighbours and asks itself: am I a member of one or more kerning pairs? 'T' will be more comfortable embracing its following 'o', and 'o' will very much want to cosy up to its leading 'T'. Since kerning varies a lot from font to font, the characters may not be able to work this out for themselves. They may have to appeal to the font to tell them how touchy-feely they should get. In extreme cases, two or more characters might want to call in a ligature to replace them, but that involves issues beyond justifying a paragraph. Since the widespread adoption of DesktopPublishing kerning shows signs of becoming a lost art.'' ''Also, see EricGill's AnEssayOnTypography for good reasons not to right justify your text anyway. -- KeithBraithwaite'' ---- Typographic characters of the world '''unite!''' Throw off the chains of your oppressive document formatters! ;-> ---- Adobe introduced a new tool to the arsenal with MultipleMasterFonts; they can vary the geometry of the font to help lines fit better in the space available. When combined with older techniques, the result gives better aesthetic results on average (e.g. avoiding rivers), even without using dynamic programming techniques such as Knuth experimented with. This page barely touches on the issues involved; all these things add up to a deep and broad subject, and includes quite a few things that are still unsolved research problems. -- DougMerritt ---- CategoryStory CategoryTypography