matplotlib._type1font#

A class representing a Type 1 font.

This version reads pfa and pfb files and splits them for embedding inpdf files. It also supports SlantFont and ExtendFont transformations,similarly to pdfTeX and friends.

Usage:

font=Type1Font(filename)clear_part,encrypted_part,finale=font.partsslanted_font=font.transform({'slant':0.167})extended_font=font.transform({'extend':1.2})subset_font=font.subset([ord(c)forcin'Hello World'])

Sources:

  • Adobe Technical Note #5040, Supporting Downloadable PostScriptLanguage Fonts.

  • Adobe Type 1 Font Format, Adobe Systems Incorporated, third printing,v1.1, 1993. ISBN 0-201-57044-0.

classmatplotlib._type1font.Type1Font(input)[source]#

Bases:object

A class representing a Type-1 font, for use by backends.

Attributes:
partstuple

A 3-tuple of the cleartext part, the encrypted part, and the finale ofzeros.

decryptedbytes

The decrypted form ofparts[1].

propdict[str, Any]

A dictionary of font properties. Noteworthy keys include:

  • FontName: PostScript name of the font

  • Encoding: dict from numeric codes to glyph names

  • FontMatrix: bytes object encoding a matrix

  • UniqueID: optional font identifier, dropped when modifying the font

  • CharStrings: dict from glyph names to byte code

  • Subrs: array of byte code subroutines

  • OtherSubrs: bytes object encoding some PostScript code

Initialize a Type-1 font.

Parameters:
inputstr or 3-tuple

Either a pfb file name, or a 3-tuple of already-decoded Type-1fontparts.

decrypted#
parts#
prop#
subset(characters,name_prefix)[source]#

Return a new font that only defines the given characters.

Parameters:
characterssequence of bytes

The subset of characters to include. These are indices into thefont's encoding array. The encoding array of a Type-1 font canonly include 256 characters, but other glyphs may be accessedvia the seac operator.

name_prefixstr

Prefix to prepend to the font name.

Returns:
Type1Font
transform(effects)[source]#

Return a new font that is slanted and/or extended.

Parameters:
effectsdict

A dict with optional entries:

  • 'slant'float, default: 0

    Tangent of the angle that the font is to be slanted to theright. Negative values slant to the left.

  • 'extend'float, default: 1

    Scaling factor for the font width. Values less than 1 condensethe glyphs.

Returns:
Type1Font
with_encoding(encoding)[source]#

Change the encoding of the font.

Parameters:
encodingdict

A dictionary mapping character codes to glyph names.

Returns:
Type1Font