getPen()

naked()

addImage(path=None, data=None, scale=None, position=None, color=None)

Set the image in the glyph. This will return the
assigned BaseImage. The image data can be
defined via path to an image file:

>>>image=glyph.addImage(path="/path/to/my/image.png")

The image data can be defined with raw image data
via data.

>>>image=glyph.addImage(data=someImageData)

If path and data are both provided, a
FontPartsError will be raised. The supported
image formats will vary across environments. Refer
to BaseImage for complete details.

scale indicates the x and y scale values that should be
applied to the image. It must be a type-scale value
or None.

>>>image=glyph.addImage(path="/p/t/image.png",scale=(0.5,1.0))

position indicates the x and y location of the lower left
point of the image.

>>>image=glyph.addImage(path="/p/t/image.png",position=(10,20))

color indicates the color to be applied to the image. It must
be a color or None.

>>>image=glyph.addImage(path="/p/t/image.png",color=(1,0,0,0.5))

appendAnchor(name=None, position=None, color=None, anchor=None)

Append an anchor to this glyph.

>>>anchor=glyph.appendAnchor("top",(10,20))

This will return a BaseAnchor object representing
the new anchor in the glyph. name indicated the name to
be assigned to the anchor. It must be a string
or None. position indicates the x and y location
to be applied to the anchor. It must be a
coordinate value. color indicates the color
to be applied to the anchor. It must be a color
or None.

>>>anchor=glyph.appendAnchor("top",(10,20),color=(1,0,0,1))

anchor may be a BaseAnchor object from which
attribute values will be copied. If name, position
or color are specified as arguments, those values will
be used instead of the values in the given anchor object.

This will return a BaseComponent object representing
the new component in the glyph. offset indicates the x and
y shift values that should be applied to the appended component.
It must be a coordinate value or None. If
None is given, the offset will be (0,0).

>>>component=glyph.appendComponent("A",offset=(10,20))

scale indicates the x and y scale values that should be
applied to the appended component. It must be a
type-scale value or None. If None is given,
the scale will be (1.0,1.0).

>>>component=glyph.appendComponent("A",scale=(1.0,2.0))

component may be a BaseComponent object from which
attribute values will be copied. If baseGlyph, offset
or scale are specified as arguments, those values will be used
instead of the values in the given component object.

appendContour(contour, offset=None)

Append a contour containing the same data as contour
to this glyph.

>>>contour=glyph.appendContour(contour)

This will return a BaseContour object representing
the new contour in the glyph. offset indicates the x and
y shift values that should be applied to the appended data.
It must be a coordinate value or None. If
None is given, the offset will be (0,0).

>>>contour=glyph.appendContour(contour,(100,0))

appendGlyph(other, offset=None)

Append the data from other to new objects in this glyph.
This will append:

contours

components

anchors

guidelines

glyph.appendGlyph(otherGlyph)

offset indicates the x and y shift values that should
be applied to the appended data. It must be a coordinate
value or None. If None is given, the offset will be (0,0).

This will return a BaseGuideline object representing
the new guideline in the glyph. position indicates the
x and y location to be used as the center point of the anchor.
It must be a coordinate value. angle indicates
the angle of the guideline, in degrees. This must be a
integer/float between 0 and 360. name indicates
an name to be assigned to the guideline. It must be a
string or None.

>>>guideline=glyph.appendGuideline((100,0),90,name="left")

color indicates the color to be applied to the guideline.
It must be a color or None.

>>>guideline=glyph.appendGuideline((100,0),90,color=(1,0,0,1))

guideline may be a BaseGuideline object from which
attribute values will be copied. If position, angle, name
or color are specified as arguments, those values will be used
instead of the values in the given guideline object.

autoContourOrder()

Automatically order the contours based on heuristics.

>>>glyph.autoContourOrder()

The results of this may vary across environments.

autoUnicodes()

Use heuristics to set the Unicode values in the glyph.

>>>glyph.autoUnicodes()

Environments will define their own heuristics for
automatically determining values.

minGlyph must be a BaseGlyph and will be located at 0.0
in the interpolation range. maxGlyph must be a BaseGlyph
and will be located at 1.0 in the interpolation range. If round
is True, the contents of the glyph will be rounded to integers
after the interpolation is performed.

>>>glyph.interpolate(0.5,otherGlyph1,otherGlyph2,round=True)

This method assumes that minGlyph and maxGlyph are completely
compatible with each other for interpolation. If not, any errors
encountered will raise a FontPartsError. If suppressError
is True, no exception will be raised and errors will be silently
ignored.

isCompatible(other)

Evaluate the interpolation compatibility of this glyph
and other.

>>>compatible,report=self.isCompatible(otherGlyph)>>>compatibleFalse

This will return a type-bool indicating if this glyph is
compatible with other and a GlyphCompatibilityReporter
containing a detailed report about compatibility errors.

loadFromGLIF(glifData)

Reads glifData, in
GLIFformat<http://unifiedfontobject.org/versions/ufo3/glyphs/glif/>_,
into this glyph.

pointInside(point)

removeAnchor(anchor)

anchor may be an BaseAnchor or an
type-int representing an anchor index.

removeComponent(component)

Remove component from the glyph.

>>>glyph.removeComponent(component)

component may be a BaseComponent or an
type-int representing a component index.

removeContour(contour)

Remove contour from the glyph.

>>>glyph.removeContour(contour)

contour may be a BaseContour or an type-int
representing a contour index.

removeGuideline(guideline)

Remove guideline from the glyph.

>>>glyph.removeGuideline(guideline)

guideline may be a BaseGuideline or an
type-int representing an guideline index.

removeLayer(layer)

Remove layer from this glyph.

>>>glyph.removeLayer("background")

Layer can be a type-glyph-layer or a string
representing a layer name.

round()

Round coordinates to the nearest integer.

>>>glyph.round()

This applies to the following:

width

height

contours

components

anchors

guidelines

scaleBy(value, origin=None, width=False, height=False)

Scale the object.

>>>obj.transformBy(2.0)>>>obj.transformBy((0.5,2.0),origin=(500,500))

value must be an iterable containing two
integer/float values defining the x and y
values to scale the object by. origin defines the
point at with the scale should originate. It must be
a coordinate or None. The default is
(0,0).

width indicates if the glyph’s width should be scaled.
height indicates if the glyph’s height should be scaled.

The origin must not be specified when scaling the width or height.

toMathGlyph()

Returns the glyph as an object that follows the
MathGlyphprotocol<https://github.com/typesupply/fontMath>_.

>>>mg=glyph.toMathGlyph()

moveBy(value)

Move the object.

>>>obj.transformBy((10,0))

value must be an iterable containing two
integer/float values defining the x and y
values to move the object by.

rotateBy(value, origin=None)

Rotate the object.

>>>obj.transformBy(45)>>>obj.transformBy(45,origin=(500,500))

value must be a integer/float values
defining the angle to rotate the object by. origin
defines the point at with the rotation should originate.
It must be a coordinate or None.
The default is (0,0).