From 21d04842f8f9f51ea24c05f1fc3626f3b111fd2d Mon Sep 17 00:00:00 2001 From: Nathan Williis Date: Tue, 3 Sep 2024 17:55:02 +0100 Subject: [PATCH] Docs: fix code-example blocks in ttLib. --- Lib/fontTools/ttLib/sfnt.py | 5 +++-- Lib/fontTools/ttLib/ttFont.py | 26 +++++++++++++------------- 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/Lib/fontTools/ttLib/sfnt.py b/Lib/fontTools/ttLib/sfnt.py index b1569423c..6cc867a4d 100644 --- a/Lib/fontTools/ttLib/sfnt.py +++ b/Lib/fontTools/ttLib/sfnt.py @@ -1,8 +1,9 @@ """ttLib/sfnt.py -- low-level module to deal with the sfnt file format. Defines two public classes: - SFNTReader - SFNTWriter + +- SFNTReader +- SFNTWriter (Normally you don't have to use these classes explicitly; they are used automatically by ttLib.TTFont.) diff --git a/Lib/fontTools/ttLib/ttFont.py b/Lib/fontTools/ttLib/ttFont.py index f4a539678..ad8756a05 100644 --- a/Lib/fontTools/ttLib/ttFont.py +++ b/Lib/fontTools/ttLib/ttFont.py @@ -28,34 +28,34 @@ class TTFont(object): Example usage:: - >> from fontTools import ttLib - >> tt = ttLib.TTFont("afont.ttf") # Load an existing font file - >> tt['maxp'].numGlyphs + >>> from fontTools import ttLib + >>> tt = ttLib.TTFont("afont.ttf") # Load an existing font file + >>> tt['maxp'].numGlyphs 242 - >> tt['OS/2'].achVendID + >>> tt['OS/2'].achVendID 'B&H\000' - >> tt['head'].unitsPerEm + >>> tt['head'].unitsPerEm 2048 For details of the objects returned when accessing each table, see :ref:`tables`. To add a table to the font, use the :py:func:`newTable` function:: - >> os2 = newTable("OS/2") - >> os2.version = 4 - >> # set other attributes - >> font["OS/2"] = os2 + >>> os2 = newTable("OS/2") + >>> os2.version = 4 + >>> # set other attributes + >>> font["OS/2"] = os2 TrueType fonts can also be serialized to and from XML format (see also the :ref:`ttx` binary):: - >> tt.saveXML("afont.ttx") + >>> tt.saveXML("afont.ttx") Dumping 'LTSH' table... Dumping 'OS/2' table... [...] - >> tt2 = ttLib.TTFont() # Create a new font object - >> tt2.importXML("afont.ttx") - >> tt2['maxp'].numGlyphs + >>> tt2 = ttLib.TTFont() # Create a new font object + >>> tt2.importXML("afont.ttx") + >>> tt2['maxp'].numGlyphs 242 The TTFont object may be used as a context manager; this will cause the file