FL.objects.Glyph.Glyph
- class FL.objects.Glyph.Glyph(glyph_or_masterscount: Glyph | int = 1, nodes: list[Node] | None = None)
Bases:
Copyable,GuideMixin,GuidePropertiesMixinA glyph
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
AuditRecordobjects.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_
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.
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.
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__
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
Pointsfor 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.
Select all nodes.
SelectContour(contourindex)Select all nodes in the specified contour.
SelectRect(r[, masterindex])Select all nodes that are inside a rectangle.
Return the number of selected nodes.
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.
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.
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()
Return True if at least one node is selected.
isContourClockwise(contourindex)Return True if direction of contour is clockwise.
set_defaults()Attributes
advance_heightadvance_widthcustomdataend_pointsflagshdmxinstructionsleft_side_bearingmarknamenotenumber_of_contourspointstop_side_bearingy_pelsThe list of the glyph's anchos.
bounding_boxThe list of the glyph's components.
advance height for the first master
The list of the glyph's horizontal guides.
The list of the glyph's horizontal stem hints.
The list of the glyph's horizontal stem links.
imageThe glyph index in the font.
The list of the glyph's kerning pairs.
The number of masters for the glyph.
The mask (background layer) of the glyph.
The list of the glyph's nodes.
The number of nodes in the glyph, same as 'len(Glyph)'.
The glyph's parent object.
The hint replacement program, a list of
Replaceobjects.The first Unicode index as integer.
unicodesThe list of the glyph's vertical guides.
The list of the glyph's vertical stem hints.
The list of the glyph's vertical stem links.
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.
- Audit() list[AuditRecord]
Perform a test of the glyph and return a list of
AuditRecordobjects.- Returns:
The list of potential contour problems.
- Return type:
- 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.
- Bintersect(glyph_nodelist: Glyph | list[Node], masterindex: int = 0) None
Perform a boolean _Intersect_ operation with the glyph or list of nodes.
- Blend(source: Glyph, layer1: int, layer2: int, amount: Point) Glyph
Return a blend of the glyph and source.
- Bsubtract(glyph_nodelist: Glyph | list[Node], masterindex: int = 0) None
Perform boolean _Subtract_ operation with the glyph or list of nodes.
- 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.
- ExpandLayer(masterindex: int) None
Expand the specified master to all other masters.
- Parameters:
masterindex (int) – The master index.
- GetContourBegin(contourindex: int) int
Return the index of the first node of the speficied contour.
- GetMetrics(masterindex: int = 0) Point
Return the glyph’s advance width and advance height as a point.
- Gradient(outlinewidth: int, direction: int, stripes_number: int, start_y: int, finish_y: int) None
_summary_
- 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.
- InsertNode(nodeindex: int, time: float = 0.0, masterindex: int = 0) None
Insert a new node on a contour.
- 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.
- 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.
- MakeExtremeNodes(masterindex: int = 0) None
Automatically add nodes at contour extrema.
- Parameters:
masterindex (int, optional) – The master index. Defaults to 0.
- 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:
- R(points: list[Point], force: float = 0.0) None
Present in the docstring but raises an
AttributeError.- Parameters:
- Raises:
AttributeError – Always.
- 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.
- ReverseContour(contourindex: int) None
Reverse the specified contour’s path direction.
- Parameters:
contourindex (int) – The contour index.
- Section(masterindex: int, pointindex: int, nodetype: int) list[Point]
Return a list of points matching the specified options.
- SelectContour(contourindex: int) None
Select all nodes in the specified contour.
- Parameters:
contourindex (int) – The contour index.
- 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.
- 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.
- Shift(point: Point, masterindex: int = 0) None
Shift the positions of all nodes in the specified master.
- Transform(matrix: Matrix) None
Apply a matrix transformation to the glyph.
- Parameters:
matrix (Matrix) – The transformation to apply.
- property components: ListParent[Component]
The list of the glyph’s components.
- Returns:
The list of components.
- Return type:
- 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
- property hguides: ListParent[Guide]
The list of the glyph’s horizontal guides.
- Returns:
The list of guides.
- Return type:
- property hhints: ListParent[Hint]
The list of the glyph’s horizontal stem hints.
- Returns:
The list of hints.
- Return type:
- property hlinks: ListParent[Link]
The list of the glyph’s horizontal stem links.
- Returns:
The list of links.
- Return type:
- property index: int
The glyph index in the font.
- Returns:
The glyph index or -1 if the glyph has no parent font.
- Return type:
- property kerning: ListParent[KerningPair]
The list of the glyph’s kerning pairs.
- Returns:
The list of kerning pairs.
- Return type:
- property layers_number: int
The number of masters for the glyph.
- Returns:
The number of masters.
- Return type:
- 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:
- property nodes_number: int
The number of nodes in the glyph, same as ‘len(Glyph)’.
- Returns:
The number of nodes.
- Return type:
- property parent: Font | None
The glyph’s parent object.
- Returns:
The parent
Fontor None.- Return type:
Font | None
- 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:
- property vhints: ListParent[Hint]
The list of the glyph’s vertical stem hints.
- Returns:
The list of hints.
- Return type:
- property vlinks: ListParent[Link]
The list of the glyph’s vertical stem links.
- Returns:
The list of links.
- Return type: