Notes on text wrapping/layout for anyone interested...
There are a lot of approaches just for wrapping lines of text (even
before you get into interacting with other aspects of page layout).
The simplest is to assume a fixed-pitch font and a known max character
width per line, and just scan through the string, breaking the line when
you hit the max characters per line.
I'd say the next simplest is to assume fixed-pitch like above, but scan
through the string looking for characters that delimit "chunks"
(whitespace like space characters, certain punctuation), and, for each
chunk breaking the line when adding the chunk to it would exceed the max
character. Unless you're already on a new line, and the chunk is simply
too big.
Sometimes fixed-pitch formatting would fill lines with extra spaces, to
make the right hand side non-ragged. But that always looked poor in
fixed-pitch.
And we used to sometimes, in both fixed and variable pitch, do
hyphenation (inserting hyphens in the middle of words, to break them
across lines), but Web browsers put an end to that, except for some
print still (like some 2-column article formats).
As soon as you get past fixed-pitch fonts, you need to be able to at
least look up font metrics for individual characters, if not strings, to
see how wide in some units (points, pixels, mm, etc.) that will be.
Then, once you're doing fixed-pitch, horizontal whitespace (between
words, between sentences, between an abbreviated honorific and a name,
etc.) is not necessarily fixed either, and you can think about it. You
can also subtly increase or decrease these small horizontal whitespaces
to make a right edge of a paragraph less-ragged or to squeeze a chunk
onto a line on which it almost fits with default spacing.
Then you get into kerning -- being able to squeeze characters together,
based on their shapes. And sometimes combining/overlaying characters.
Like whitespace with fixed-pitch, this is another place that you can do
subtle adjustments for a non-ragged right edge, or to squeeze a chunk
onto the line.
You can pick what degree of sophistication you want to start with.
Then you get into integrating this simple horizontal line breaking with
the vertical[1], and with more complex page layout approaches.
And laying out things like mathematical expressions.
A long time ago, Computer Science's most revered procrastinator, Donald
Knuth, did a lot of study and innovation of typesetting and fonts.
Reading up on "the TeX algorithm" [2], and then maybe "Metafont", is not
a bad starting point, to get a sense of way of thinking about text
layout and having larger layouts converge (including annoying things
like page references in the text being laid out changing the page
numbering).
Even things that start to look outdated, like pagination with
orphan/widow control, can still be relevant (e.g., imagine a
non-paginated vertical scrolling view, and you would like the scrolling
to be subtly more readable than the scrolling-viewport-indifferent
layout and the fixed-pixel scroll increments). Or general ideas apply
to different aspects of page layout.
[1] "Outer Limits" intro. https://www.youtube.com/watch?v=8CtjhWhw2I8&t=15s
[2] https://en.wikipedia.org/wiki/TeX
--
You received this message because you are subscribed to the Google Groups "Racket
Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.