5.7. fonteffects

Copyright @ 2013 Mathias Westerdahl

The fonteffects module provides commonly used base functionality for the effects.

fonteffects.ColorFunction(cls)[source]

Registers a class as a color function

class fonteffects.DistanceField(*k, **kw)[source]

Calculates a distance field for each glyph

factor = 4

The number of times the glyph is enlarged before the glyph is rendered.

size = 16

The spread of the “blur” that is applied to the glyphs

class fonteffects.DropShadow(*k, **kw)[source]

Applies a drop shadow to the glyphs

angle = 120

The angle of the shadow (in degrees)

color = (0, 0, 0)

The color of the shadow

distance = 3

The offset of the shadow

opacity = 100

The opacity of the shadow (in percent)

padding[source]

Return the amount of padding needed to fit the effect as a 4 tuple (left, top, right, bottom)

size = 1

The spread of the shadow (in pixels)

fonteffects.EffectFunction(cls)[source]

Registers a class as a effect function

exception fonteffects.FontEffectException[source]

An internal exception class used for font creator exceptions

class fonteffects.GaussianBlur(*k, **kw)[source]

Applies a gaussian blur to the glyph

size = 1

The radius (in pixels) of the kernel

class fonteffects.Gradient(*k, **kw)[source]

Creates a gradient between two or more colors.

Parameters:
  • colors – A list of colors (3 tuples) to interpolate between. [bottom color, ..., top color]
  • angle – The angle of rotation (in degrees)
class fonteffects.Halfsize(*k, **kw)[source]

Down scales the glyph by a factor, using bilinear factoring

class fonteffects.KernelBlur(*k, **kw)[source]

Applies a simple box filter where the middle element has value ‘strength’

size = 1

The radius of the kernel (in pixels). The kernel size is radius*2+1

strength = 1

The center value of the kernel

class fonteffects.Layer(**kw)[source]

A class that helps applying layers on top of each other

class fonteffects.Outline(*k, **kw)[source]

Creates an outline around the glyph

Parameters:
  • color – The color of the outline
  • opacity – The opacity of the color [0,100]
  • width – The width of the outline
  • spread – The radius of the blur of the outline
padding = None

Return the amount of padding needed to fit the effect as a 4 tuple (left, top, right, bottom)

class fonteffects.Solid(*k, **kw)[source]

Creates solid fill with a single color

Parameters:color – A color as (r,g,b) [0,255]
class fonteffects.Stripes(*k, **kw)[source]

Creates stripes with alternating colors

Parameters:
  • width – The width of the stripes
  • offset – The start offset of the stripes
  • angle – The angle of rotation (in degrees)
  • colors – The alternating colors of the stripes. May be more than 2
class fonteffects.Texture(*k, **kw)[source]

Applies a texture as a color function

Parameters:
  • options – The command line options
  • name – The texture name relative to options.datadir.