×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

PostScript FAQ

Character Encoding

How do I get accented characters? by tgreer
Posted: 17 Jul 03

Every PostScript Type 1 font contains glyphs (drawings) of all of the standard character shapes, including accented characters and special symbols (copyright, registration mark, etc.).

However, PostScript Type 1 fonts use an 8-bit encoding scheme, which means that only 256 of the characters are encoded (essentially, available for use).

The trick to getting access to these special characters is to re-encode the font. Here is the code to switch to the ISOLatin1 encoding vector, which encodes all the standard characters, numbers, and puncutation, but also includes the accented characters:


/HelveticaLatin
  << /Helvetica findfont {} forall >>
  begin
    /Encoding ISOLatin1Encoding 256 array copy def currentdict
  end
definefont pop

/HelveticaLatin 48 selectfont


First we give our new font a name, in this example, HelveticaLatin.

The next line is a clever way to copy a dictionary, which you have to do since font dictionaries are read-only.

The double open-angle brackets starts a new dictionary. Next we put the standard Helvetica font on the stack. The forall loop iterates through the dictionary, leaving each entry on the stack... performing the empty procedure {}.

When the loop completes, we have all the entries from the Helvetica font on the stack. The double close-angle brackets completes the new dictionary.

To change the encoding vector, we make this new dictionary the current dictionary with "begin", create an array, moving the ISOLatin1Encoding array values into it and defining it. We then put this dicitionary back on the operand stack, and then remove the dictionary from the dictionary stack.

We use the copy on the operand stack to pass to the definefont operator, creating our new font.

Accented characters are now encoded. Passing such characters as T and ¬ into your string will now work as well as any other character.

Thomas D. Greer
http://www.tgreer.com

Back to PostScript FAQ Index
Back to PostScript Forum


My Archive

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close