@@ -32,6 +32,30 @@ def getDefaultRanges():
32
32
33
33
class TTF2Web :
34
34
def __init__ (self , fontfile , uranges , assetdir = "assets" , fontstyle = None , fontweight = None ):
35
+ """
36
+ Parameters
37
+ ----------
38
+ fontfile : str
39
+ Path to a ttf file.
40
+ uranges : [[str]]
41
+ Array of pairs -- name of the unicode range and the range itself.
42
+ These will be used to suffix the names of generated woff2 files.
43
+ E.g. [['greek', 'U+0370-03FF,U+1F00-1FFF'], ['thumbs', 'U+01F44D']]
44
+ If fontfile='/path/to/fontfile.ttf' and assetdir='assets'
45
+ then 'assets/fontfile.greek.woff2' and
46
+ 'assets/fontfile.thumbs.woff2'
47
+ will be generated when the generateWoff2 method is called.
48
+ assetdir : str
49
+ Path to which woff2 files should be generated.
50
+ fontstyle : str
51
+ The CSS3 font-style property. If not specified, an appropriate one
52
+ will be generated based on the subfamily property[1].
53
+ fontweight : str
54
+ The CSS3 font-weight property. If not specified, an appropriate one
55
+ will be generated based on the subfamily property[1].
56
+
57
+ [1]: https://www.microsoft.com/typography/otspec/name.htm#nameIDs
58
+ """
35
59
self .fontfile = fontfile
36
60
self .basename = os .path .splitext (os .path .basename (fontfile ))[0 ]
37
61
self .urdict = _intoURDict (uranges )
@@ -101,10 +125,14 @@ def main():
101
125
parser = argparse .ArgumentParser ()
102
126
parser .add_argument ("fontfile" ,
103
127
help = "ttf file to split into woff2 files" )
104
- parser .add_argument ("--unicode-ranges" , dest = "urfile" , default = None ,
105
- help = "the file containing the desired unicode ranges" )
106
128
parser .add_argument ("-v" , "--verbose" , action = "store_true" ,
107
129
help = "print more details" )
130
+ parser .add_argument ("--unicode-ranges" , dest = "urfile" , default = None ,
131
+ help = "the file specifying the desired unicode ranges. " +
132
+ "Each line of the file should contain 2 fields " +
133
+ "separated by one or more spaces. The first field " +
134
+ "should be a name given to the unicode range " +
135
+ "specified in the second field." )
108
136
args = parser .parse_args ()
109
137
if args .urfile :
110
138
uranges = readURFile (args .urfile )
0 commit comments