This module handles TeX encoding file.
An encoding file map the glyph index with its symbolic name. It uses the .enc extension.
For example, the content of cork.enc is:
/CorkEncoding [ % now 256 chars follow
% 0x00
/grave /acute /circumflex /tilde /dieresis /hungarumlaut /ring /caron
/breve /macron /dotaccent /cedilla
/ogonek /quotesinglbase /guilsinglleft /guilsinglright
...
% 0xF0
/eth /ntilde /ograve /oacute /ocircumflex /otilde /odieresis /oe
/oslash /ugrave /uacute /ucircumflex /udieresis /yacute /thorn /germandbls
] def
The percent character is used for comment as for TeX.
The content of this file can be parsed using:
cork_encoding = Encoding('/usr/share/texmf/fonts/enc/dvips/base/cork.enc')
The encoding’s name can be retrieved using:
>>> cork_encoding.name
'CorkEncoding'
The number of glyphes can be obtained using the function len():
>>> len(cork_encoding)
256
The index of the glyph eth can be retrieved using:
>>> cork_encoding['eth']
0xF0
and reciprocally:
>>> cork_encoding[0xF0]
'eth'
The methods to_index() and to_name() are used internally for this purpose.