### Getting an Option Value Source: https://fonttools.readthedocs.io/en/latest/_modules/fontTools/misc/configTools.html Provides an example of the `get` method for retrieving the value of a configuration option. It specifies how the method resolves the value, prioritizing provided defaults over global defaults. ```python def get( self, option_or_name: Union[Option, str], default: Any = _USE_GLOBAL_DEFAULT ) -> Any: """ Get the value of an option. The value which is returned is the first provided among: ``` -------------------------------- ### DiscreteAxisDescriptor Initialization and Setup Source: https://fonttools.readthedocs.io/en/latest/_modules/fontTools/designspaceLib.html Example of creating and configuring a DiscreteAxisDescriptor for a non-interpolating axis like 'Italic'. It demonstrates setting values, default, name, tag, mapping, and labels. ```python a2 = DiscreteAxisDescriptor() a2.values = [0, 1] a2.default = 0 a2.name = "Italic" a2.tag = "ITAL" a2.labelNames['fr'] = "Italique" a2.map = [(0, 0), (1, -11)] a2.axisOrdering = 2 a2.axisLabels = [ AxisLabelDescriptor(name="Roman", userValue=0, elidable=True) ] doc.addAxis(a2) ``` -------------------------------- ### Compute STAT Names for an Instance Source: https://fonttools.readthedocs.io/en/latest/_modules/fontTools/designspaceLib/statNames.html This example demonstrates how to get STAT-based names for an instance using its full user location. It prints the computed style names. ```python instance = doc.instances[0] names = getStatNames(doc, instance.getFullUserLocation(doc)) print(names.styleNames) ``` -------------------------------- ### TFM Class Initialization and Example Usage Source: https://fonttools.readthedocs.io/en/latest/_modules/fontTools/tfmLib.html Demonstrates how to instantiate the TFM class with a file path and print various attributes of the parsed TFM data. This serves as a basic example for using the module. ```python if __name__ == "__main__": import sys tfm = TFM(sys.argv[1]) print( "\n".join( x for x in [ f"tfm.checksum={tfm.checksum}", f"tfm.designsize={tfm.designsize}", f"tfm.codingscheme={tfm.codingscheme}", f"tfm.fonttype={tfm.fonttype}", f"tfm.family={tfm.family}", f"tfm.seven_bit_safe_flag={tfm.seven_bit_safe_flag}", f"tfm.face={tfm.face}", f"tfm.extraheader={tfm.extraheader}", f"tfm.fontdimens={tfm.fontdimens}", f"tfm.right_boundary_char={tfm.right_boundary_char}", f"tfm.left_boundary_char={tfm.left_boundary_char}", f"tfm.kerning={tfm.kerning}", f"tfm.ligatures={tfm.ligatures}", f"tfm.chars={tfm.chars}", ] ) ) print(tfm) ``` -------------------------------- ### OnCurveFirstPointPen Example Source: https://fonttools.readthedocs.io/en/latest/_modules/fontTools/pens/filterPen.html Demonstrates how OnCurveFirstPointPen ensures closed contours start with an on-curve point by rotating points if necessary. Includes an example of a contour starting with an off-curve point. ```python >>> from fontTools.pens.recordingPen import RecordingPointPen >>> rec = RecordingPointPen() >>> pen = OnCurveFirstPointPen(rec) >>> # Closed contour starting with off-curve - will be rotated >>> pen.beginPath() >>> pen.addPoint((0, 0), None) # off-curve >>> pen.addPoint((100, 100), "line") # on-curve - will become start >>> pen.addPoint((200, 0), None) # off-curve >>> pen.addPoint((300, 100), "curve") # on-curve >>> pen.endPath() >>> # The contour should now start with (100, 100) "line" >>> rec.value[0] ('beginPath', (), {}) >>> rec.value[1] ('addPoint', ((100, 100), 'line', False, None), {}) >>> rec.value[2] ('addPoint', ((200, 0), None, False, None), {}) >>> rec.value[3] ('addPoint', ((300, 100), 'curve', False, None), {}) >>> rec.value[4] ('addPoint', ((0, 0), None, False, None), {}) ``` -------------------------------- ### RecordingPen Example Source: https://fonttools.readthedocs.io/en/latest/pens/recordingPen.html Demonstrates how to use RecordingPen to capture and print the drawing commands of a glyph. ```python from fontTools.ttLib import TTFont from fontTools.pens.recordingPen import RecordingPen glyph_name = 'dollar' font_path = 'MyFont.otf' font = TTFont(font_path) glyphset = font.getGlyphSet() glyph = glyphset[glyph_name] pen = RecordingPen() glyph.draw(pen) print(pen.value) ``` -------------------------------- ### TreeBuilder start method Source: https://fonttools.readthedocs.io/en/latest/misc/etree.html Opens a new element. ```python start(_self_ , _tag_ , _attrs_ , _nsmap =None_) ``` -------------------------------- ### Full Axes and Labels Example Source: https://fonttools.readthedocs.io/en/latest/_sources/designspaceLib/xml.rst.txt An example demonstrating the structure of the element, including nested , , and with