Gopher text rendering ideas
──────────────────────────────────────────────────────────────────────

TL;DR: I would like to try a gopher client using monospaced and
proportional fonts.

Gopher is a text-based protocol, and as such is mainly used to share
text files.

Plain text doesn't come with any formating, like what HTML of or LaTeX
would provide. As such, gophernauts assume all clients use at least a
70 char wide display, and a monospace font.
If you take this paragraph, there is absolutely no added value for it
to wrap at 70 characters. Proportional fonts are usually more pleasant
to read. They're also more compact, meaning you can fit more text on a
page.

However, you need a monospaced font so this cute zebra doesn't look
like a gull:

             ,,
      ______/ ¨/)
  *~'(///////
      ||   ||
      ""   ""

This make use of a technique called "preformatted text".

So I had an idea. What if a client used proportional font for text
blocks, and monospace for preformatted text ?

You would need a way to figure out what is preformatted, what is raw
text, and find the delimitation between both.

The delimitation is easy. It's the same as with paragraphs: a new line.
Whenever there is a new line character on its own, it means you get to
start a new paragraph.

Now what could be the difference between raw, and preformatted text ? I
though about it, and I think that the main difference is the use of
white spaces.
When you write text, you really only need to put one space between
words (maybe two after a sentence).
However, with preformatted space, you (almost) always have to use
whitespaces for formatatting. Be it to draw ascii art, or align stuff.
Which means that you're very likely to find multiple whitespaces glued
together.

So how would that work ?

The client would read the text data from the server, and buffer the
input (that's mandatory!). You would need to buffer at  least one
paragraph, so buffer until you read 2 sequences of CRLF (or LF).
Now you got a full paragraph. You can check inside for multiple
occurences of the whitespaces, say at least 3 in a row.

If you find 3 whitespaces, the the paragraph is "preformatted". You
would then display it using a monospaced font. For anything else, use a
proportional font.

This is a pretty naive approach, yet it seems simple enough to work.
I'll see if I can get something working, and see how it goes.
--
~wgs

20200923.1722