How to build a glyph for a control character

bhuynh's picture

I'm trying to build a custom font that will make control character EOT visible. For instance, the EOT character (ASCII 4) would would be inserted as a symbol when I type cntrl + D.

I have drawn the glyph in FontLab studio, but when I generate the font, the EOT character is not present.

Could some kind soul explain how I can achieve this, or point me to a decent resource that I might try to understand the problem?

Thank you

hrant's picture

The OS and/or the application will often not bother
rendering what you've place in a control character.
Sometimes it might even prevent software from working
properly. This applies even to the blank space character.

hhp

Theunis de Jong's picture

... when I generate the font, the EOT character is not present.

How do you know? Because pressing Ctrl+D in any software doesn't show it? (See Hrant's answer for that.) Or by inspecting your font with a utility that is able to show glyphs and assigned codes?

Theunis de Jong's picture

... A perfect reasonable representation for Ctrl+D in many programs is to show it as "^D". Not a font in the world that can work around that ...

(Except an Opentype font that substitutes the sequence "^D" with an actual glyph of one. But that would not be the same, would it?)

Mark Simonson's picture

Control characters are by definition not displayable. They are special codes used to do things other than display characters, like ringing the bell on the teletype machine.

bhuynh's picture

Thanks for replying guys.

I'm writing the software that's supposed to display this character. The software is supposed to replace some legacy equipment that displayed the EOT character with a specific symbol.

I know Ctrl+D works because it displays the following when I use Courier New:

On Windows XP:
a square (□)

On Windows 7:
a backwards L (┘)

When using my custom font, I just get a space. In debug mode, I can see that 0x04 is put into the buffer for the EOT character.

I'm pretty certain that whatever comes out of Fontlab does not have a symbol mapped to the 0x04 character. Is there anyway to map a glyph to the EOT character within Fontlab?

JanekZ's picture

This is strange, but there is a glyph in this position:


so maybe you can do it. I placed a "0" at 0x3, generated the CFF font and opened it again.
PS not in FontLab, in FontForge

Theunis de Jong's picture

I know Ctrl+D works because it displays the following when I use Courier New:

On Windows XP: a square (□)

On Windows 7: a backwards L (┘)

You are mistaken. "Works" is a relative term; you don't say what software you are using to "prove" your point.

And those characters are neither 'a square' nor 'a backwards L'. What character(s) do you get when you press any other Ctrl+ key? What character do you see when you enter a key code that is not available in the font?

Té Rowan's picture

As I recall, most Windows versions would display a box for a control character, probably because that's the font's 'missing character' symbol. I have seen it often enough instead of a ^Z or even ^@.

IIRC, some TeX encodings use the U0000..U001F space for glyphs, and I already know that FontForge can stuff that space...

bhuynh's picture

I've given up on trying to place a glyph into the EOT position and will instead handle the problem in my code:

Whenever I see the EOT char (x04), I replace it with the section sign (xA7). In my font, I've replaced the section sign with the symbol I want to use. This only works because I know my software doesn't have to support the section sign.

It still bothers me that I had to handle this with code. Both Fontlab and Fontforge have the glyph at this position, but I can't figure out how to it.

Thanks for all the replies, I would have kept spinning my wheels looking for the "perfect" solution had you guys not convinced me it was difficult (if not impossible) to do.

hrant's picture

I might use an even less useful character, like
the sputnik (generic currency sign, U+00A4).

hhp

Theunis de Jong's picture

Theoretically there is no specific problem with a character at this position, but the software has to support its actual drawing on screen. Your solution is as good as anything else; the use of other glyphs to display a Tab, Hard Return, Space, or other special character is common.

And usually its 'special' status is indicated by having a different color than the surrounding text. See commands like 'Show Invisible Characters" in your favourite text editor. (Microsoft Word, with its intrusive glaringly black "hidden" characters is an exception.)

Té Rowan's picture

Hmm… If your system uses Unicode as native encoding, you can probably hack things to emit Control Picture codes (U+2400..U+241F) instead.

bhuynh's picture

The system I'm communicating with is ~20 yrs old and only takes 8-bit words, so I need to stick to ANSI to not over-complicate things when I try to communicate. Thanks for the comment.

Té Rowan's picture

*blink* *blink* And I thought Magrat (my Linux box, whopping 466 bogoMIPS) was old!

Syndicate content Syndicate content