fontforge / fontforge.github.io

The FontForge homepage
http://fontforge.github.io/
107 stars 44 forks source link

Is this non-standard font possible? #172

Closed DavidCase closed 2 years ago

DavidCase commented 2 years ago

I wish to create a font that displays bit patterns (4 bit squares) for the hexadecimal characters ([0-9] & [A-F]). The characters would need to abut exactly both above and below, i.e. no space between characters and with line spacing equal to the height of the characters. This is for displaying black and white bit mapped images encoded as hex strings. Is this possible to do in FontForge or does it violate some rule(s) of font design that will make it impossible. I'm working on MacOS (Big Sur).

ctrlcctrlv commented 2 years ago

No rule is violated per se, however, this won't work how you want.

Even if you create glyphs assigned to all the characters in the C0 Controls (0x00–1F) and C1 Controls (0x80–0x9F), the OS won't show them in general. And the OS will expect valid UTF-8 in most cases and places—it won't even look for a character if it sees a lone 0x82, you'd actually need 0xC2 0x82 to refer to the C1 Control U+0082 (unencoded, sometimes called by its ANSI name, "BREAK PERMITTED HERE").

Confused enough yet? Good, because now there's the problem of linebreaks. The font cannot say "in my font \n (or \r, or \r\n) is not a linebreak". You will never be able to output anything for U+000A, for me FontForge doesn't even try:

image

Some shaping engines will refuse to do what you want with spaces as well. You'll also be breaking all sorts of assumptions around linebreaking and wordwrapping.

Long and short of it—bad idea. Please don't implement this in a font, sorry, there are indeed myriad roadblocks.

DavidCase commented 2 years ago

Thanks for your feedback. I do not want to invest a lot of time in an impossible project. I implemented this idea back in the days of System 9 and bit-mapped fonts and wondered if it could be done under MacOS. To be perhaps a bit more clear on what the idea was, it worked like this: in a text editor one opens a specially prepared file containing only the hex characters 0-9 and A-F and line returns (\r, \n). The font for this one is Courier 12 ...

image

Then switching fonts to the hexadecimal font (I called mine Hex=O=Rams) in 2 pt size and setting the line wrap sufficiently large, in this case 512, one gets the following image ..

image

So my idea did use line returns and the 0 character looked like a space. I'm not sure if that would change your opinion in any way, but it occurred to me that I could have been clearer. Thanks again for your feedback.

davidmerfield commented 2 years ago

It's not directly relevant to fontforge but the venerable Donald Knuth has a paper on Fonts for Digital Halftones you might enjoy. Would be a fun excuse to experiment with metafont.

ctrlcctrlv commented 2 years ago

@DavidCase Well that's a different question entirely :-)

Using [0-9A-F] is certainly possible.