coldtype.pens.datpen.DATPens

class DATPens(pens=[])

A set/collection of DATPen’s

Behaves like a list but can be queried somewhat like a DOM

addFrame(frame, typographic=False, passthru=False)

Add a frame that isn’t derived from the bounds

attr(key='default', field=None, **kwargs)

Set a style attribute on the pen.

bounds()

Calculated bounds of a DATPens

clearFrames()

Get rid of any non-bounds-derived pen frames; i.e. frames set by Harfbuzz

closePath()

The standard RecordingPen.closePath, but returns self for chainability.

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

curveTo(*points)

The standard RecordingPen.curveTo, but returns self for chainability.

endPath()

The standard RecordingPen.endPath, but returns self for chainability.

explode()

Noop on a set

ffg(glyph_name)

(f)ind the (f)irst (g)lyph named this name

fft(tag)

(f)ind the (f)irst (t)agged with tag

filter(fn: Callable[[int, coldtype.pens.datpen.DATPen], 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

getFrame(th=False, tv=False)

Get the frame of the DATPens; th means (t)rue (h)orizontal; ty means (t)rue (v)ertical; passing either ignores a non-bounds-derived frame in either dimension

glyphs_named(glyph_name)

Pluck glyphs named glyph_name

indexed_subset(indices)

Take only the pens at the given indices

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.

lineTo(p1)

The standard RecordingPen.lineTo, but returns self for chainability.

map(fn: Callable[[int, coldtype.pens.datpen.DATPen], Optional[coldtype.pens.datpen.DATPen]])

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, coldtype.pens.datpen.DATPen], 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

moveTo(p0)

The standard RecordingPen.moveTo, but returns self for chainability.

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

print_tree(depth=0)

Print a hierarchical representation of the pen set

qCurveTo(*points)

The standard RecordingPen.qCurveTo, but returns self for chainability.

record(pen)

Alias for append

removeBlanks()

Remove blank pens from the set

removeOverlap()

Remove overlaps within this shape and return itself.

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(rounding)

Round all values for all pens in this set

round_to(rounding)

Round all values for all pens in this set to nearest multiple of rounding value (rather than places, as in round)

rp()

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)

tagged(tag)

Yield all top-level pens tagged w/ tag

transform(transform, transformFrame=True)

Perform an arbitrary transformation on the pen, using the fontTools Transform class.