drafting.pens.draftingpens.DraftingPens¶
-
class
DraftingPens
(pens=None)¶ -
ambit
(th=False, tv=False)¶ Get the calculated rect boundary of the DraftingPens; th means (t)rue (h)orizontal; ty means (t)rue (v)ertical; passing either ignores a non-bounds-derived frame in either dimension
-
attr
(key='default', field=None, **kwargs)¶ Set a style attribute on the pen.
-
bounds
()¶ Calculated bounds of a DraftingPens
-
closePath
()¶ Close the current sub path. You must call either pen.closePath() or pen.endPath() after each sub path.
-
collapse
(levels=100, onself=False)¶ AKA flatten in some programming contexts, though flatten is a totally different function here that flattens outlines; this function flattens nested collections into one-dimensional collections
-
copy
(with_data=False)¶ Get a completely new copy of this whole set of pens, usually done so you can duplicate and further modify a DATPens without mutating the original
-
endPath
()¶ End the current sub path, but don’t close it. You must call either pen.closePath() or pen.endPath() after each sub path.
-
explode
()¶ Noop on a set
-
ffg
(glyph_name)¶ (f)ind the (f)irst (g)lyph named this name
-
fft
(tag, fn=None)¶ (f)ind the (f)irst (t)agged with tag
-
filter
(fn: Callable[[int, drafting.pens.draftingpen.DraftingPen], bool])¶ Filter top-level pen(s)
-
flatten
(levels=100, onself=False)¶ AKA flatten in some programming contexts, though flatten is a totally different function here that flattens outlines; this function flattens nested collections into one-dimensional collections
-
frameSet
(th=False, tv=False)¶ All the frames of all the pens
-
glyphs_named
(glyph_name)¶ Pluck glyphs named glyph_name
-
interleave
(style_fn, direction=- 1, recursive=True)¶ Provide a callback-lambda to interleave new DATPens between the existing ones; useful for stroke-ing glyphs, since the stroked glyphs can be placed behind the primary filled glyphs.
-
map
(fn: Callable[[int, drafting.pens.draftingpen.DraftingPen], Optional[drafting.pens.draftingpen.DraftingPen]])¶ Apply fn to all top-level pen(s) in this set; if fn returns a value, it will overwrite the pen it was given as an argument; fn lambda receives idx, p as arguments
-
mfilter
(fn)¶ Same as filter but (m)utates this DATPens to now have only the filtered pens
-
mmap
(fn: Callable[[int, drafting.pens.draftingpen.DraftingPen], None])¶ Apply fn to all top-level pen(s) in this set but do not look at return value; first m in mmap stands for mutate; fn lambda receives idx, p as arguments
-
pen
()¶ A flat representation of this set as a single pen
-
pfilter
(fn)¶ Filter all pens, recursively
-
pmap
(fn)¶ Apply fn to all individal pens, recursively
-
remove
(*args)¶ remove a pen from these pens by identify, or by tag if a string is passed
-
remove_blanks
()¶ Remove blank pens
-
reversePens
()¶ Reverse the order of the pens; useful for overlapping glyphs from the left-to-right rather than right-to-left (as is common in OpenType applications)
-
round_to
(rounding)¶ Round all values for all pens in this set to nearest multiple of rounding value (rather than places, as in round)
-
tagged
(tag)¶ Yield all top-level pens tagged w/ tag
-
track
(t, v=False)¶ Track-out/distribute elements
-
track_to_rect
(rect, pullToEdges=False, r=0)¶ Distribute pens evenly within a frame
-
transform
(transform, transformFrame=True)¶ Perform an arbitrary transformation on the pen, using the fontTools Transform class.
-
tree
(out=None, depth=0) → str¶ Hierarchical string representation
-