• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1"""fontTools.ttLib -- a package for dealing with TrueType fonts.
2
3This package offers translators to convert TrueType fonts to Python
4objects and vice versa, and additionally from Python to TTX (an XML-based
5text format) and vice versa.
6
7Example interactive session:
8
9Python 1.5.2c1 (#43, Mar  9 1999, 13:06:43)  [CW PPC w/GUSI w/MSL]
10Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
11>> from fontTools import ttLib
12>> tt = ttLib.TTFont("afont.ttf")
13>> tt['maxp'].numGlyphs
14242
15>> tt['OS/2'].achVendID
16'B&H\000'
17>> tt['head'].unitsPerEm
182048
19>> tt.saveXML("afont.ttx")
20Dumping 'LTSH' table...
21Dumping 'OS/2' table...
22Dumping 'VDMX' table...
23Dumping 'cmap' table...
24Dumping 'cvt ' table...
25Dumping 'fpgm' table...
26Dumping 'glyf' table...
27Dumping 'hdmx' table...
28Dumping 'head' table...
29Dumping 'hhea' table...
30Dumping 'hmtx' table...
31Dumping 'loca' table...
32Dumping 'maxp' table...
33Dumping 'name' table...
34Dumping 'post' table...
35Dumping 'prep' table...
36>> tt2 = ttLib.TTFont()
37>> tt2.importXML("afont.ttx")
38>> tt2['maxp'].numGlyphs
39242
40>>
41
42"""
43
44from fontTools.misc.loggingTools import deprecateFunction
45import logging
46
47
48log = logging.getLogger(__name__)
49
50class TTLibError(Exception): pass
51
52@deprecateFunction("use logging instead", category=DeprecationWarning)
53def debugmsg(msg):
54	import time
55	print(msg + time.strftime("  (%H:%M:%S)", time.localtime(time.time())))
56
57from fontTools.ttLib.ttFont import *
58from fontTools.ttLib.ttCollection import TTCollection
59