Outline

class freetype.Outline(outline)

FT_Outline wrapper.

This structure is used to describe an outline to the scan-line converter.

contours

The number of contours in the outline.

decompose(context=None, move_to=None, line_to=None, conic_to=None, cubic_to=None, shift=0, delta=0)

Decompose the outline into a sequence of move, line, conic, and cubic segments.

Parameters:
  • context – Arbitrary contextual object which will be passed as the last parameter of all callbacks. Typically an object to be drawn to, but can be anything.
  • move_to – Callback which will be passed an FT_Vector control point and the context. Called when outline needs to jump to a new path component.
  • line_to – Callback which will be passed an FT_Vector control point and the context. Called to draw a straight line from the current position to the control point.
  • conic_to – Callback which will be passed two FT_Vector control points and the context. Called to draw a second-order Bézier curve from the current position using the passed control points.
  • curve_to – Callback which will be passed three FT_Vector control points and the context. Called to draw a third-order Bézier curve from the current position using the passed control points.
  • shift – Passed to FreeType which will transform vectors via x = (x << shift) - delta and y = (y << shift) - delta
  • delta – Passed to FreeType which will transform vectors via x = (x << shift) - delta and y = (y << shift) - delta
Since:

1.3

flags

A set of bit flags used to characterize the outline and give hints to the scan-converter and hinter on how to convert/grid-fit it. See FT_OUTLINE_FLAGS.

get_bbox()

Compute the exact bounding box of an outline. This is slower than computing the control box. However, it uses an advanced algorithm which returns very quickly when the two boxes coincide. Otherwise, the outline Bezier arcs are traversed to extract their extrema.

get_cbox()

Return an outline’s ‘control box’. The control box encloses all the outline’s points, including Bezier control points. Though it coincides with the exact bounding box for most glyphs, it can be slightly larger in some situations (like when rotating an outline which contains Bezier outside arcs).

Computing the control box is very fast, while getting the bounding box can take much more time as it needs to walk over all segments and arcs in the outline. To get the latter, you can use the ‘ftbbox’ component which is dedicated to this single task.

get_inside_border()

Retrieve the FT_StrokerBorder value corresponding to the ‘inside’ borders of a given outline.

Returns:The border index. FT_STROKER_BORDER_RIGHT for empty or invalid outlines.
get_outside_border()

Retrieve the FT_StrokerBorder value corresponding to the ‘outside’ borders of a given outline.

Returns:The border index. FT_STROKER_BORDER_RIGHT for empty or invalid outlines.
points

The number of points in the outline.

tags

A list of ‘n_points’ chars, giving each outline point’s type.

If bit 0 is unset, the point is ‘off’ the curve, i.e., a Bezier control point, while it is ‘on’ if set.

Bit 1 is meaningful for ‘off’ points only. If set, it indicates a third-order Bezier arc control point; and a second-order control point if unset.

If bit 2 is set, bits 5-7 contain the drop-out mode (as defined in the OpenType specification; the value is the same as the argument to the SCANMODE instruction).

Bits 3 and 4 are reserved for internal purposes.