# encodings: Support for OpenType-specific character encodings

## Overview:

fontTools includes support for some character encodings found in legacy Mac TrueType fonts. Many of these legacy encodings have found their way into the standard Python `encodings` library, but others still remain unimplemented. Importing `fontTools.encodings.codecs` will therefore add string `encode()` and `decode()` support for the following encodings:

- `x_mac_japanese_ttx`

- `x_mac_trad_chinese_ttx`

- `x_mac_korean_ttx`

- `x_mac_simp_chinese_ttx`

fontTools also includes a module (`fontTools.encodings.MacRoman`) that consists of a mapping of glyph IDs to glyph names in the MacRoman character set:

    >>> from fontTools.encodings.MacRoman import MacRoman
    >>> MacRoman[26]
    'twosuperior'

and a module (`fontTools.encodings.StandardEncoding`) that provides a similar mapping of glyph IDs to glyph names in the PostScript Standard Encoding.

## fontTools.encodings.codecs

Extend the Python codecs module with a few encodings that are used in OpenType (name table) but missing from Python. See https://github.com/fonttools/fonttools/issues/236 for details.

class fontTools.encodings.codecs.ExtendCodec(name, base_encoding, mapping)

  Bases: `Codec`

  encode(input, errors='strict')
  decode(input, errors='strict')
  error(e)

fontTools.encodings.codecs.search_function(name)

## fontTools.encodings.MacRoman

## fontTools.encodings.StandardEncoding