Search code examples
character-encodingfontspostscript

Delimiter-Mapped Fontface?


My project is creating a font (or something that I can use somewhat like a font) that maps each word to an individual glyph in the font. The main point of this is to automatically generate "alternate language" passages form arbitrary text, for use in such things as D&D or online games.

I have finished creating an algorithm for generating a new character for a word, in the case that the converter has never encountered that word, but I am stumped by how to store these character descriptions for later use. Does anybody know of any character mapping algorithms/etc that I could use that can be made to work with PostScript Language Fonts?

The PostScript Language Reference manual did not have any useful information in this regards. I have tried searching as best I know how for such a thing all over the internet, but all the info my searches have turned has been completely irrelevant. I am unsure of what this sort of thing would be called, even just a pointer to how to start looking would be greatly appreciated.

If no such thing exists, how would I implement a custom encoding algorithm to do this? The PostScript Language Reference Manual makes some small reference to that possibility, but my searches in that regard haven't turned up any useful info.


Solution

  • I think postscript can do this. A postscript font contains two mappings: char-code -> glyph-name, glyph-name -> glyph-drawing-commands. And you can bypass the char map by using the glyphshow operator. And you can create a custom font with definefont. So I'm imagining something like this (rough-draft, untested):

    /doglyph {
        {
            cvn glyphshow
        } stopped {
            %<-- Reinstall  font with new word here
            glyphshow
        } if
    } def
    
    /myshow { % (string of words)
        ( ) {
            search {
                doglyph
            }{
                doglyph exit
            } ifelse
        } loop
    } def