FL.objects.Glyph.Glyph

class FL.objects.Glyph.Glyph(glyph_or_masterscount: Glyph | int = 1, nodes: list[Node] | None = None)

Bases: Copyable, GuideMixin, GuidePropertiesMixin

A glyph

__init__(glyph_or_masterscount: Glyph | int = 1, nodes: list[Node] | None = None) None

Methods

Add(glyph_node_nodelist)

Append a glyph, a node, or a sequence of nodes.

Assign(g)

Copy all information from a glyph.

Audit()

Perform a test of the glyph and return a list of AuditRecord objects.

Autohint([masterindex])

Automatically generate PostScript hints for the glyph.

Badd(glyph_nodelist[, masterindex])

Perform a boolean _Add_ operation with the glyph or list of nodes.

Bintersect(glyph_nodelist[, masterindex])

Perform a boolean _Intersect_ operation with the glyph or list of nodes.

Blend(source, layer1, layer2, amount)

Return a blend of the glyph and source.

Bsubtract(glyph_nodelist[, masterindex])

Perform boolean _Subtract_ operation with the glyph or list of nodes.

Clear()

Remove all nodes.

College(outlinewidth, distance)

_summary_

Decompose()

Paste all components to the glyph outline.

Delete(index0[, index1])

Remove a node or a range of nodes.

DeleteContour(contourindex)

Remove in the specified contour.

DeleteNode(nodeindex)

Remove the specified Node.

DeleteSelected()

Delete all selected nodes.

Distance(width_x, width_y, cornermode[, dest])

_summary_

EditMask()

ExchangeMask()

ExpandLayer(masterindex)

Expand the specified master to all other masters.

Extrude3D(outlinewidth, shift_x, shift_y)

_summary_

FindAnchor(name)

Find an anchor by name.

FindContour(nodeindex)

Return number of contour containing the speficied node.

GetBoundingRect([masterindex])

Return the glyph's bounding box.

GetContourBegin(contourindex)

Return the index of the first node of the speficied contour.

GetContourLength(contourindex)

Return the number of nodes in the specified contour.

GetContoursNumber()

Return the number of contours in the glyph.

GetMetrics([masterindex])

Return the glyph's advance width and advance height as a point.

GetVSB([masterindex])

Return the glyph' bottom sidebearing position.

Gradient(outlinewidth, direction, ...)

_summary_

Insert(node_or_glyph_or_nodelist[, nodeindex])

Insert a node, a glyph, or a sequence of nodes at the beginning of the glyph's nodes, or at the specified node index.

InsertNode(nodeindex[, time, masterindex])

Insert a new node on a contour.

Interpolate(nodes)

__summary__

InvertSelection()

Select unselected nodes and deselect selected nodes.

Iterate(iterator)

Iterate the glyph through an iterator class which must provide the following methods:

JoinAll()

Tries to join all open contours.

Layer(masterindex)

Return a list of Points for all nodes for the selected master.

LoadEPS(filename)

Read an EPS file from filename and return it as a Glyph object.

MakeExtremeNodes([masterindex])

Automatically add nodes at contour extrema.

MoveNode(options)

Moves the node copying Edit tool behavior (see User manual for details).

Present(style)

Return True if a layer or a combination of layers are present in the glyph.

R(points[, force])

Present in the docstring but raises an AttributeError.

Rasterize(image)

_summary_

RemoveHints(mode)

Remove hints and links.

RemoveOverlap([masterindex])

Remove overlaps from the glyph's contours.

ReorderContour(contourindex, newindex)

Reorder the contours in the glyph by moving the specified contour to a new index.

ReverseContour(contourindex)

Reverse the specified contour's path direction.

Rotate3D()

_summary_

SaveEPS(filename[, layer])

Write a glyph master into the EPS file named filename.

Scale(scale, center[, masterindex])

Scale the glyph.

Section(masterindex, pointindex, nodetype)

Return a list of points matching the specified options.

SelectAll()

Select all nodes.

SelectContour(contourindex)

Select all nodes in the specified contour.

SelectRect(r[, masterindex])

Select all nodes that are inside a rectangle.

SelectedCount()

Return the number of selected nodes.

Selection()

Return a list of selected nodes.

SetLayersNumber(mastersnumber)

Change the number of masters.

SetMetrics(p[, masterindex])

Assign new values to the advance width and advance height of the glyph.

SetStartNode(nodeindex)

Make the specified node the starting node of its contour.

SetVSB(value[, masterindex])

Assign new values to the bottom sidebearing of the glyph.

Shadow(outlinewidth, shift_x, shift_y)

_summary_

Shift(point[, masterindex])

Shift the positions of all nodes in the specified master.

Transform(matrix)

Apply a matrix transformation to the glyph.

UnselectAll()

Deselect all nodes.

UnselectRect(r[, masterindex])

Deselect all nodes that are inside a rectangle.

Warp(points, force)

_summary_

__init__([glyph_or_masterscount, nodes])

clear()

fake_add_axis()

fake_deserialize(key, data)

Add data from a VFB entry

fake_deserialize_anchor_supp(data)

fake_deserialize_anchors_mm(data)

fake_deserialize_gdef(data)

fake_deserialize_guide_properties(data)

fake_deserialize_guides(data)

fake_deserialize_hints(data)

fake_remove_axis(position)

Remove the last axis from the glyph, interpolating all values to the normalized position given.

fake_serialize()

Serialize the glyph to a dict which resembles the low-level VFB structure

fake_serialize_anchor_supp()

fake_serialize_anchors_mm()

fake_serialize_gdef()

fake_serialize_guide_properties()

fake_serialize_guides()

fake_serialize_hints()

fake_serialize_mask()

fake_update([font, index])

Is called from FontLab.UpdateFont()

isAnySelected()

Return True if at least one node is selected.

isContourClockwise(contourindex)

Return True if direction of contour is clockwise.

set_defaults()

Attributes

advance_height

advance_width

customdata

end_points

flags

hdmx

instructions

left_side_bearing

mark

name

note

number_of_contours

points

top_side_bearing

y_pels

anchors

The list of the glyph's anchos.

bounding_box

components

The list of the glyph's components.

height

advance height for the first master

hguides

The list of the glyph's horizontal guides.

hhints

The list of the glyph's horizontal stem hints.

hlinks

The list of the glyph's horizontal stem links.

image

index

The glyph index in the font.

kerning

The list of the glyph's kerning pairs.

layers_number

The number of masters for the glyph.

mask

The mask (background layer) of the glyph.

nodes

The list of the glyph's nodes.

nodes_number

The number of nodes in the glyph, same as 'len(Glyph)'.

parent

The glyph's parent object.

replace_table

The hint replacement program, a list of Replace objects.

unicode

The first Unicode index as integer.

unicodes

vguides

The list of the glyph's vertical guides.

vhints

The list of the glyph's vertical stem hints.

vlinks

The list of the glyph's vertical stem links.

width

The advance width for the first master.

Add(glyph_node_nodelist: Glyph | Node | Iterable[Node]) None

Append a glyph, a node, or a sequence of nodes.

Parameters:

glyph_node_nodelist (Glyph | Node | Iterable[Node]) – The objects to append.

Assign(g: Glyph) None

Copy all information from a glyph.

Parameters:

g (Glyph) – The source glyph.

Audit() list[AuditRecord]

Perform a test of the glyph and return a list of AuditRecord objects.

Returns:

The list of potential contour problems.

Return type:

list[AuditRecord]

Autohint(masterindex: int = 0) None

Automatically generate PostScript hints for the glyph.

Parameters:

masterindex (int, optional) – The master index. Defaults to 0.

Badd(glyph_nodelist: Glyph | list[Node], masterindex: int = 0) None

Perform a boolean _Add_ operation with the glyph or list of nodes.

Parameters:
  • glyph_nodelist (Glyph | list[Node]) – _description_

  • masterindex (int, optional) – The master index. Defaults to 0.

Bintersect(glyph_nodelist: Glyph | list[Node], masterindex: int = 0) None

Perform a boolean _Intersect_ operation with the glyph or list of nodes.

Parameters:
  • glyph_nodelist (Glyph | list[Node]) – _description_

  • masterindex (int, optional) – The master index. Defaults to 0.

Blend(source: Glyph, layer1: int, layer2: int, amount: Point) Glyph

Return a blend of the glyph and source.

Parameters:
  • source (Glyph) – _description_

  • layer1 (int) – _description_

  • layer2 (int) – _description_

  • amount (Point) – _description_

Returns:

The blended glyph.

Return type:

Glyph

Bsubtract(glyph_nodelist: Glyph | list[Node], masterindex: int = 0) None

Perform boolean _Subtract_ operation with the glyph or list of nodes.

Parameters:
  • glyph_nodelist (Glyph | list[Node]) – _description_

  • masterindex (int, optional) – The master index. Defaults to 0.

Clear() None

Remove all nodes.

College(outlinewidth: int, distance: int) None

_summary_

Parameters:
  • outlinewidth (int) – _description_

  • distance (int) – _description_

Decompose() None

Paste all components to the glyph outline.

Delete(index0: int, index1: int | None = None) None

Remove a node or a range of nodes.

Parameters:
  • index0 (int) – The first node index

  • index1 (int | None, optional) – The last node index. Defaults to None.

DeleteContour(contourindex: int) None

Remove in the specified contour.

Parameters:

contourindex (int) – The contour index.

DeleteNode(nodeindex: int) None

Remove the specified Node.

Parameters:

nodeindex (int) – The node index.

DeleteSelected() None

Delete all selected nodes.

Distance(width_x: int, width_y: int, cornermode: int, dest: Glyph | None = None) None

_summary_

Parameters:
  • width_x (int) – _description_

  • width_y (int) – _description_

  • cornermode (int) – _description_

  • dest (Glyph | None, optional) – _description_. Defaults to None.

ExpandLayer(masterindex: int) None

Expand the specified master to all other masters.

Parameters:

masterindex (int) – The master index.

Extrude3D(outlinewidth: int, shift_x: int, shift_y: int) None

_summary_

Parameters:
  • outlinewidth (int) – _description_

  • shift_x (int) – _description_

  • shift_y (int) – _description_

FindAnchor(name: str) Anchor

Find an anchor by name.

Parameters:

name (str) – The anchor name

Returns:

_description_

Return type:

Anchor

FindContour(nodeindex: int) int

Return number of contour containing the speficied node.

Parameters:

nodeindex (int) – The node index

Returns:

The contour index.

Return type:

int

GetBoundingRect(masterindex: int = 0) Rect

Return the glyph’s bounding box.

Parameters:

masterindex (int, optional) – The master index used for measuring. Defaults to 0.

Returns:

The bounding box of the glyph.

Return type:

Rect

GetContourBegin(contourindex: int) int

Return the index of the first node of the speficied contour.

Parameters:

contourindex (int) – The contour index.

Returns:

The node index.

Return type:

int

GetContourLength(contourindex: int) int

Return the number of nodes in the specified contour.

Parameters:

contourindex (int) – The contour index.

Returns:

The number of nodes.

Return type:

int

GetContoursNumber() int

Return the number of contours in the glyph.

GetMetrics(masterindex: int = 0) Point

Return the glyph’s advance width and advance height as a point.

Parameters:

masterindex (int, optional) – The master index used for measuring. Defaults to 0.

Returns:

The point containing the advance width (x) and heigh (y).

Return type:

Point

GetVSB(masterindex: int = 0) int

Return the glyph’ bottom sidebearing position.

Parameters:

masterindex (int, optional) – The master index used for measuring. Defaults to 0.

Returns:

The bottom sidebearing.

Return type:

int

Gradient(outlinewidth: int, direction: int, stripes_number: int, start_y: int, finish_y: int) None

_summary_

Parameters:
  • outlinewidth (int) – _description_

  • direction (int) – _description_

  • stripes_number (int) – _description_

  • start_y (int) – _description_

  • finish_y (int) – _description_

Insert(node_or_glyph_or_nodelist: Node | Glyph | list[Node], nodeindex: int = 0) None

Insert a node, a glyph, or a sequence of nodes at the beginning of the glyph’s nodes, or at the specified node index.

Parameters:
  • node_or_glyph_or_nodelist (Node | Glyph | list[Node]) – The nodes to insert.

  • nodeindex (int, optional) – The place to insert. Defaults to 0.

InsertNode(nodeindex: int, time: float = 0.0, masterindex: int = 0) None

Insert a new node on a contour.

Parameters:
  • nodeindex (int) – _description_

  • time (float, optional) – The time on the segment. Start is 0.0, end is 1.0. Defaults to 0.0.

  • masterindex (int, optional) – The master index used for measuring. Defaults to 0.

Interpolate(nodes: list[tuple[int, Point]]) list[tuple[int, Point]]

__summary__

Parameters:

nodes (list[tuple[int, Point]]) – _description_

Returns:

_description_

Return type:

list[tuple[int, Point]]

InvertSelection() None

Select unselected nodes and deselect selected nodes.

Iterate(iterator: Any) None

Iterate the glyph through an iterator class which must provide the following methods:

  • Start()

  • ClosePath()

  • StartPath(Node)()

  • LineTo(Node)()

  • CurveTo(Node)()

  • SplineTo(Node)()

  • Finish()

Parameters:

iterator (Any) – The iterator object.

JoinAll() None

Tries to join all open contours.

Layer(masterindex: int) list[Point]

Return a list of Points for all nodes for the selected master.

Parameters:

masterindex (int) – The master index

Returns:

The list of each node’s last point.

Return type:

list[Point]

LoadEPS(filename: str) Glyph

Read an EPS file from filename and return it as a Glyph object.

Use the Assign() method to replace current the glyph with the imported outline.

Parameters:

filename (str) – The path and file name.

Returns:

The imported glyph.

Return type:

Glyph

MakeExtremeNodes(masterindex: int = 0) None

Automatically add nodes at contour extrema.

Parameters:

masterindex (int, optional) – The master index. Defaults to 0.

MoveNode(options) None

Moves the node copying Edit tool behavior (see User manual for details).

Present(style) bool

Return True if a layer or a combination of layers are present in the glyph.

Parameters:

style (_type_) – _description_

Returns:

Whether the specified combination of layers is present.

Return type:

bool

R(points: list[Point], force: float = 0.0) None

Present in the docstring but raises an AttributeError.

Parameters:
  • points (list[Point]) – A list of points.

  • force (float, optional) – The force. Defaults to 0.0.

Raises:

AttributeError – Always.

Rasterize(image: Image) None

_summary_

Parameters:

image (Image) – _description_

RemoveHints(mode: int) None

Remove hints and links.

Parameters:

mode (int) – _description_

RemoveOverlap(masterindex: int = 0) None

Remove overlaps from the glyph’s contours.

Parameters:

masterindex (int, optional) – The master index. Defaults to 0.

ReorderContour(contourindex: int, newindex: int) None

Reorder the contours in the glyph by moving the specified contour to a new index.

Parameters:
  • contourindex (int) – The contour index.

  • newindex (int) – The new contour index.

ReverseContour(contourindex: int) None

Reverse the specified contour’s path direction.

Parameters:

contourindex (int) – The contour index.

Rotate3D() None

_summary_

SaveEPS(filename: str, layer: int = 0) None

Write a glyph master into the EPS file named filename.

Parameters:
  • filename (str) – The path and file name.

  • layer (int, optional) – The master index. Defaults to 0.

Scale(scale: Point, center: Point, masterindex: int = 0) None

Scale the glyph.

Parameters:
  • scale (Point) – The point specifying the x and y scale factor.

  • center (Point) – The center of the scale transformation.

  • masterindex (int, optional) – The master to scale. Defaults to 0.

Section(masterindex: int, pointindex: int, nodetype: int) list[Point]

Return a list of points matching the specified options.

Parameters:
  • masterindex (int) – The master index.

  • pointindex (int) – The point index.

  • nodetype (int) – The node type (nLINE, nMOVE, nCURVE, nOFF).

Returns:

The list of points.

Return type:

list[Point]

SelectAll() None

Select all nodes.

SelectContour(contourindex: int) None

Select all nodes in the specified contour.

Parameters:

contourindex (int) – The contour index.

SelectRect(r: Rect, masterindex: int = 0) None

Select all nodes that are inside a rectangle.

Parameters:
  • r (Rect) – The rectangle.

  • masterindex (int, optional) – The master index used for measuring. Defaults to 0.

SelectedCount() int

Return the number of selected nodes.

Selection() list[Node]

Return a list of selected nodes.

Returns:

The list of nodes.

Return type:

list[Node]

SetLayersNumber(mastersnumber: int) None

Change the number of masters. Only applicable to glyphs that have no parent.

Parameters:

mastersnumber (int) – The new number of masters.

SetMetrics(p: Point, masterindex: int = 0) None

Assign new values to the advance width and advance height of the glyph.

Parameters:
  • p (Point) – The point containing the advance width (x) and heigh (y).

  • masterindex (int, optional) – The master index. Defaults to 0.

SetStartNode(nodeindex: int) None

Make the specified node the starting node of its contour.

Parameters:

nodeindex (int) – The node index.

SetVSB(value: int, masterindex: int = 0) None

Assign new values to the bottom sidebearing of the glyph.

Parameters:
  • value (int) – The bottom sidebearing.

  • masterindex (int, optional) – The master index. Defaults to 0.

Shadow(outlinewidth: int, shift_x: int, shift_y: int) None

_summary_

Parameters:
  • outlinewidth (int) – _description_

  • shift_x (int) – _description_

  • shift_y (int) – _description_

Shift(point: Point, masterindex: int = 0) None

Shift the positions of all nodes in the specified master.

Parameters:
  • point (Point) – The point specifying the x and y shift.

  • masterindex (int, optional) – The master to shift. Defaults to 0.

Transform(matrix: Matrix) None

Apply a matrix transformation to the glyph.

Parameters:

matrix (Matrix) – The transformation to apply.

UnselectAll() None

Deselect all nodes.

UnselectRect(r: Rect, masterindex: int = 0) None

Deselect all nodes that are inside a rectangle.

Parameters:
  • r (Rect) – The rectangle.

  • masterindex (int, optional) – The master index used for measuring. Defaults to 0.

Warp(points: list[Point], force: float) None

_summary_

Parameters:
  • points (list[Point]) – _description_

  • force (float) – _description_

property anchors: list[Anchor]

The list of the glyph’s anchos.

Returns:

The anchors.

Return type:

list[Anchor]

property components: ListParent[Component]

The list of the glyph’s components.

Returns:

The list of components.

Return type:

ListParent[Component]

fake_deserialize(key: int, data: Any) None

Add data from a VFB entry

Parameters:
  • name (str) – The name of the entry.

  • data (_type_) – The entry data.

fake_remove_axis(position: float) None

Remove the last axis from the glyph, interpolating all values to the normalized position given.

Parameters:

position (float) – The position in normalized space (0.0 to 1.0).

fake_serialize() dict[int, Any]

Serialize the glyph to a dict which resembles the low-level VFB structure

Returns:

The serialized glyph.

Return type:

dict[str, Any]

fake_update(font: Font | None = None, index: int = -1) None

Is called from FontLab.UpdateFont()

property height: int

advance height for the first master

Returns:

_description_

Return type:

int

property hguides: ListParent[Guide]

The list of the glyph’s horizontal guides.

Returns:

The list of guides.

Return type:

ListParent[Guide]

property hhints: ListParent[Hint]

The list of the glyph’s horizontal stem hints.

Returns:

The list of hints.

Return type:

ListParent[Hint]

The list of the glyph’s horizontal stem links.

Returns:

The list of links.

Return type:

ListParent[Link]

property index: int

The glyph index in the font.

Returns:

The glyph index or -1 if the glyph has no parent font.

Return type:

int

isAnySelected() bool

Return True if at least one node is selected.

isContourClockwise(contourindex: int) bool

Return True if direction of contour is clockwise.

Parameters:

contourindex (int) – The contour index.

Returns:

True if the path direction is clockwise.

Return type:

bool

property kerning: ListParent[KerningPair]

The list of the glyph’s kerning pairs.

Returns:

The list of kerning pairs.

Return type:

ListParent[KerningPair]

property layers_number: int

The number of masters for the glyph.

Returns:

The number of masters.

Return type:

int

property mask: Glyph | None

The mask (background layer) of the glyph.

Returns:

The mask glyph if present.

Return type:

Glyph | None

property nodes: ListParent[Node]

The list of the glyph’s nodes.

Returns:

The nodes.

Return type:

ListParent[Node]

property nodes_number: int

The number of nodes in the glyph, same as ‘len(Glyph)’.

Returns:

The number of nodes.

Return type:

int

property parent: Font | None

The glyph’s parent object.

Returns:

The parent Font or None.

Return type:

Font | None

property replace_table: list[Replace]

The hint replacement program, a list of Replace objects.

Returns:

The list of replace objects.

Return type:

list[Replace]

property unicode: int | None

The first Unicode index as integer.

Returns:

The Unicode codepoint.

Return type:

int | None

property vguides: ListParent[Guide]

The list of the glyph’s vertical guides.

Returns:

The list of guides.

Return type:

ListParent[Guide]

property vhints: ListParent[Hint]

The list of the glyph’s vertical stem hints.

Returns:

The list of hints.

Return type:

ListParent[Hint]

The list of the glyph’s vertical stem links.

Returns:

The list of links.

Return type:

ListParent[Link]

property width: int

The advance width for the first master.

Returns:

_description_

Return type:

int