From 94b2b4687ad62209a20cadab45991cc43b4688e7 Mon Sep 17 00:00:00 2001 From: Tim Hoffmann <2836374+timhoffm@users.noreply.github.com> Date: Sun, 15 Dec 2019 18:54:42 +0100 Subject: [PATCH] Update docs of type1font --- lib/matplotlib/type1font.py | 36 +++++++++++++++++++++++++----------- 1 file changed, 25 insertions(+), 11 deletions(-) diff --git a/lib/matplotlib/type1font.py b/lib/matplotlib/type1font.py index 01caf460d15b..cd38c95fe44c 100644 --- a/lib/matplotlib/type1font.py +++ b/lib/matplotlib/type1font.py @@ -54,8 +54,13 @@ class Type1Font: def __init__(self, input): """ - Initialize a Type-1 font. *input* can be either the file name of - a pfb file or a 3-tuple of already-decoded Type-1 font parts. + Initialize a Type-1 font. + + Parameters + ---------- + input : str or 3-tuple + Either a pfb file name, or a 3-tuple of already-decoded Type-1 + font `~.Type1Font.parts`. """ if isinstance(input, tuple) and len(input) == 3: self.parts = input @@ -67,9 +72,7 @@ def __init__(self, input): self._parse() def _read(self, file): - """ - Read the font from a file, decoding into usable parts. - """ + """Read the font from a file, decoding into usable parts.""" rawdata = file.read() if not rawdata.startswith(b'\x80'): return rawdata @@ -306,12 +309,23 @@ def suppress(tokens): def transform(self, effects): """ - Transform the font by slanting or extending. *effects* should - be a dict where ``effects['slant']`` is the tangent of the - angle that the font is to be slanted to the right (so negative - values slant to the left) and ``effects['extend']`` is the - multiplier by which the font is to be extended (so values less - than 1.0 condense). Returns a new :class:`Type1Font` object. + Return a new font that is slanted and/or extended. + + Parameters + ---------- + effects : dict + A dict with optional entries: + + - 'slant' : float, default: 0 + Tangent of the angle that the font is to be slanted to the + right. Negative values slant to the left. + - 'extend' : float, default: 1 + Scaling factor for the font width. Values less than 1 condense + the glyphs. + + Returns + ------- + font : `Type1Font` """ tokenizer = self._tokens(self.parts[0]) transformed = self._transformer(tokenizer,