Py5Font.get_shape()#
Get a single character as a Py5Shape object.
Examples#

def setup():
    font = py5.create_font('DejaVu Sans', 32)
    chr_p = font.get_shape('p')
    chr_y = font.get_shape('y')
    chr_5 = font.get_shape('5')
    chr_p.disable_style()
    chr_y.disable_style()
    chr_5.disable_style()
    py5.fill(0)
    py5.no_stroke()
    x = 25
    py5.shape(chr_p, x, 40)
    x += chr_p.get_width()
    py5.shape(chr_y, x, 60)
    x += chr_y.get_width()
    py5.shape(chr_5, x, 80)
Description#
Get a single character as a Py5Shape object. Use the detail parameter to draw the shape with only straight line segments.
Calling Py5Shape.disable_style() on the returned Py5Shape object seems to be necessary for these to be drawable.
This method only works on fonts loaded with create_font().
Underlying Processing method: PFont.getShape
Signatures#
get_shape(
    ch: chr,  # single character
    /,
) -> Py5Shape
get_shape(
    ch: chr,  # single character
    detail: float,  # level of shape detail
    /,
) -> Py5Shape
Updated on March 06, 2023 02:49:26am UTC
