Debian Codegraph @

fontforgeexe/fontimage.pe

raw
1
2 if ( Strtol($version)<20080616 )
3 Error( "Please upgrade to a more recent version of fontforge" )
4 endif
5
6 lines=[]
7 width = -1
8 height = -1
9 outfile = ""
10 pixelsize = 24
11 foundfont = 0
12
13 while ( $argc > 1 )
14 if ( Strsub($1,0,1)!='-' )
15 if ( foundfont )
16 Print("Warning: Multiple font files have been given. Only the last will be used." )
17 endif
18 foundfont = 1
19 Open($1,1)
20 else
21 temp = $1
22 if ( Strsub(temp,1,2)=='-' )
23 temp = Strsub(temp,1)
24 endif
25
26 if ( temp=="-width" && $argc>2 )
27 shift
28 width = Strtol($1)
29 elseif ( temp=="-height" && $argc>2 )
30 shift
31 height = Strtol($1)
32 elseif ( temp=="-pixelsize" && $argc>2 )
33 shift
34 pixelsize = Strtol($1)
35 elseif ( temp=="-o" && $argc>2 )
36 shift
37 if ( outfile!="" )
38 Print("Multiple output files given; only the last will be used")
39 endif
40 outfile = $1
41 elseif ( temp=="-fontname" )
42 lines = lines + [ pixelsize, 0 ]
43 elseif ( temp=="-text" && $argc>2 )
44 shift
45 lines = lines + [ pixelsize, $1 ]
46 elseif ( temp=="-version" )
47 Print( "Version 1.0" )
48 return(0)
49 else
50 Print( "fontimage: [--version] [--width num] [--height num] [--pixelsize num] [--fontname] [--text str] [-o outputfilename] fontfile" )
51 Print( " Produces an image containing representative glyphs of the font" )
52 Print( " --width num Specifies the number of pixels wide to make the" )
53 Print( " output image. If this is omitted (or specified as -1) then" )
54 Print( " the image will be made as wide as it needs to be." )
55 Print( " --height num Specifies the number of pixels high to make the" )
56 Print( " output image. If this is omitted (or specified as -1) then" )
57 Print( " the image will be made as high as it needs to be." )
58 Print( " --fontname Include the fontname as a line of text." )
59 Print( " --text str Specifies a line of text to be printed on the image." )
60 Print( " This may be specified multiple times to get multiple lines." )
61 Print( " If this is omitted fontimage will chose a default set of strings" )
62 Print( " based on what characters it thinks are likely to be interesting." )
63 Print( " --pixelsize num Specifies the size at which the next piece(s) of" )
64 Print( " text will be printed. This may also be specified multiple times." )
65 Print( " --o outputfilename Specifies the name of the output image file." )
66 Print( " It must have an extension of either '.png' or '.bmp'." )
67 Print( " The image format will be determined by the extension." )
68 Print( " If omitted fontimage will choose a filename based on the font name." )
69 Print( " (png files are only supported if fontforge were compiled with png" )
70 Print( " support and has access to a png library)" )
71 return( 0 )
72 endif
73 endif
74 shift
75 endloop
76
77 if ( !foundfont )
78 Error( "You must specify a font." )
79 endif
80
81 if ( SizeOf(lines)==0 )
82 # I used to have the script generate default lines, but have moved that logic
83 # into fontforge
84 lines = [ pixelsize ];
85 else
86 i=1;
87 while ( i<SizeOf(lines))
88 if ( TypeOf(lines[i])=="Integer" && lines[i]==0 )
89 lines[i] = " " + $fontname + " ";
90 endif
91 i=i+2;
92 endloop
93 endif
94
95 if ( outfile=="" )
96 outfile = $fontname + ".png"
97 endif
98
99 FontImage(outfile,lines,width,height)