drafting.text.reader.Style

class Style(font: Optional[Union[drafting.text.reader.Font, str]] = None, fontSize: int = 12, tracking=0, trackingMode=1, kern_pairs={}, space=None, baselineShift=0, xShift=None, rotate=0, reverse=False, removeOverlap=False, lang=None, narrower=None, include_blanks=False, palette=0, capHeight=None, data={}, layer=None, liga=True, fill=(0, 0.5, 1), stroke=None, strokeWidth=0, variations={}, variationLimits={}, trackingLimit=0, scaleVariations=True, mods=None, features={}, increments={}, varyFontSize=False, preventHwid=False, fitHeight=None, load_font=True, tag=None, **kwargs)

Class for configuring font properties

Keyword arguments

  • font: can either be a drafting.text.Font object, a pathlib.Path, or a plain string path

  • fontSize: standard point-based font-size, expressed as integer

  • tracking (aka tu): set the tracking, by default in font-source-point-size aka as if the font-size was always 1000; this means tracking is by default done relatively rather than absolutely (aka the relative tracking will not change when you change the fontSize)

  • trackingMode: set to 0 to set tracking in a classic fontSize-based (defaults to 1, as described just above)

  • space: set this to override the width of the standard space character (useful when setting text on a curve and the space is getting collapsed)

  • baselineShift (aka bs): if an integer, shifts glyphs by that amount in y axis; if a list, shifts glyphs at corresponding index in list by that amount in y axis

  • xShift (aka xs): if an integer, shifts glyphs by that amount in x axis; if a list, shifts glyphs at corresponding index in list by that amount in x axis

  • rotate: rotate glyphs by degree

  • reverse (aka r): reverse the order of the glyphs, so that the left-most glyph is first in when vectorized via .pens()

  • removeOverlaps (aka ro): automatically use skia-pathops to remove overlaps from the glyphs (useful when using variable ttf fonts)

  • lang: set language directly, to access language-specific alternate characters/rules

Shorthand kwargs

  • kp for kern_pairs — a dict of glyphName->[left,right] values in font-space

  • tl for trackingLimit

  • bs for baselineShift

  • ch for capHeight — a number in font-space; not specified, read from font; specified as ‘x’, capHeight is set to xHeight as read from font