pyhershey.shape_text

Module Contents

Functions

shape_text(text: str, mapping: str, advance_height: float, font_size: float = 1, text_align: str = 'left', const_advance_width: Optional[float] = None) → List[Dict[str, Any]]

Very basic text shaping for ascii text

pyhershey.shape_text.shape_text(text: str, mapping: str, advance_height: float, font_size: float = 1, text_align: str = 'left', const_advance_width: Optional[float] = None)List[Dict[str, Any]][source]

Very basic text shaping for ascii text

Parameters
  • text (str) – text to be shaped. New lines should be marked with \n.

  • mapping (str) – the ascii to hershey mapping to be used (cf. ascii_mappings)

  • advance_hight (float) – the distance between two consecutive base lines. Does not scale with font_size!

  • font_size (float, optional) – the font size to be used. Default to 1.

  • text_align (str, optional) – the text alignment. Can be “left”, “center” or “right”. Default to “left”.

  • const_advance_width (float, optional) – if given, the text advance width is constant (monospaced). Default to None.

Raises

ValueError – if text_align is not “left”, “center” or “right”.

Returns

list with dictionary for every glyph of style [{'glyph': <GlyphView>, 'pos': <Tuple[float, float]>}, ...].

Return type

List[Dict[str, any]]