Skip to content

fontlab.PaintBrush

PaintBrush

Brush settings for drawing tools.

What is PaintBrush?

The PaintBrush defines the shape of the brush used by FontLab's scribble and colour-font drawing tools. It controls how thick the brush stroke is, whether it is circular or elliptical, and at what angle. You can script brush settings to create consistent stroke effects programmatically.

Tutorial

from fontlab import PaintBrush

# A calligraphic-style brush at 45 degrees:
brush = PaintBrush()
brush.init()
brush.size     = 40.0
brush.flatness = 0.2      # very flat, like a broad-nib pen
brush.angle    = 45.0     # classic calligraphic angle
brush.render(1.0)

print(f"Brush: {brush.toString()}")

# A round brush:
round_brush = PaintBrush()
round_brush.init()
round_brush.size = 20.0
round_brush.flatness = 1.0
round_brush.angle = 0.0

Common Scripting Patterns

Set up a calligraphic brush

from fontlab import PaintBrush

brush = PaintBrush()
brush.init()
brush.size     = 60.0    # overall diameter in glyph units
brush.flatness = 0.15    # very flat → calligraphic nib effect
brush.angle    = 30.0    # nib rotation angle in degrees
print(f"Brush: size={brush.size}  flatness={brush.flatness}  angle={brush.angle}°")
print(brush.toString())

Apply a brush to the workspace

import fontlab as fl
from fontlab import PaintBrush

ws = fl.flWorkspace.instance()
brush = PaintBrush()
brush.init()
brush.size     = 40.0
brush.flatness = 0.2
brush.angle    = 15.0
ws.paintBrush = brush
fl.Update()
print("Brush applied to workspace.")

Constructors:

Native bases: object

Captured native MRO: PaintBrush, object

Native new allocation evidence (not an init overload): (args, *kwargs) Create and return a new object. See help(type) for accurate signature.

Supplemental documentation: A paint brush described by angle, flatness and size (all double) and a shape attribute. The captured declaration exposes assign, init, render and toString. Consult the retained constructor documentation for the supported creation forms.

Source: FontLab Proteus API documentation

Source: generated/fontlab.py: PaintBrush captured declaration

Complete member index

Every captured member retains its own identity. Identical captured declaration text is linked once; this does not establish native inheritance or interchangeable objects.

Member Kind Signature Summary
__init__ function (self, /, *args: Any, **kwargs: Any) -> None Initialize self. (shared captured text)
angle attribute Any The rotation angle of the brush in degrees.
assign function (self, PaintBrush: Any) -> None Copies all properties from another PaintBrush into this one.
flatness attribute Any The aspect ratio of the brush.
init function (self) -> None Resets the brush to its default settings: size 50, flatness 0.5, angle 30 degrees.
render function (self, scale: float) -> None Pre-renders the brush outline at the given canvas zoom scale.
shape attribute Any The custom PaintBrushShape profile value.
size attribute Any The brush diameter in glyph units.
toString function (self) -> str Returns a string representation of the brush settings.