Debian Codegraph @

tools/generate/OpenType

raw
1 # vim: set filetype=python :
2 from __future__ import print_function
3 __license__ = """
4 This file is part of GNU FreeFont.
5
6 GNU FreeFont is free software: you can redistribute it and/or modify it under
7 the terms of the GNU General Public License as published by the Free Software
8 Foundation, either version 3 of the License, or (at your option) any later
9 version.
10
11 GNU FreeFont is distributed in the hope that it will be useful, but WITHOUT
12 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13 FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License along with
16 GNU FreeFont. If not, see <http://www.gnu.org/licenses/>.
17 """
18 __author__ = "Stevan White"
19 __email__ = "[email protected]"
20 __copyright__ = "Copyright 2009, 2010, 2012, 2013, 2018 Stevan White"
21 __date__ = "$Date:: 2018-06-03 21:57:09 +0200#$"
22 __version__ = "$Revision: 3914 $"
23 __doc__ = """
24 Convert fonts from FontForge's native SFD format to OpenType format
25
26 Issues: Currently, FontForge does not include gasp tables in OpenType fonts.
27 However, in Windows, that functionality is clearly present in other fonts.
28 The result, I think, is that hinting is applied to small font sizes when
29 it is inappropriate.
30
31 Therefore, hinting is presently turned off
32 """
33
34 import fontforge
35 from sys import argv
36 from buildutils import *
37 #import uglify
38
39 def build_otf_file( sfd_filename ):
40 f = fontforge.open( sfd_filename )
41 otfile = f.fontname + '.otf'
42 vstr = trim_version_str( f )
43 print( 'Generating OpenType file', otfile, vstr )
44 # Wanted to set to 'UniocdeBmp' if there were no high unicodes
45 # but all attemtps to determine that from Python failed.
46 f.encoding = 'UnicodeFull'
47 f.selection.all()
48 f.autoHint() # because without gasp table, small sizes ugly
49 # 'old-kern' and 'dummy-dsig' are work-arounds for Windows
50 f.generate( otfile, flags=('opentype','round') )
51 f.close()
52
53 scriptname = argv[0];
54 argc = len( argv )
55
56 if argc > 1:
57 for i in range( 1, argc ):
58 build_otf_file( argv[i] )
59 else:
60 print( 'Usage:', scriptname, 'font.sfd [font.sfd ...]' )