rfil 0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/COPYING +340 -0
- data/README +77 -0
- data/examples/afm2tfm.rb +204 -0
- data/examples/afminfo +305 -0
- data/examples/encodingtable +65 -0
- data/examples/pldiff +295 -0
- data/examples/plinfo +108 -0
- data/examples/rfii +257 -0
- data/examples/rfont +188 -0
- data/lib/rfil/font.rb +722 -0
- data/lib/rfil/font/afm.rb +414 -0
- data/lib/rfil/font/glyph.rb +198 -0
- data/lib/rfil/font/metric.rb +135 -0
- data/lib/rfil/font/truetype.rb +35 -0
- data/lib/rfil/fontcollection.rb +182 -0
- data/lib/rfil/helper.rb +155 -0
- data/lib/rfil/rfi.rb +472 -0
- data/lib/rfil/rfi_plugin_context.rb +90 -0
- data/lib/rfil/rfi_plugin_latex.rb +95 -0
- data/lib/rfil/version.rb +3 -0
- data/lib/tex/enc.rb +223 -0
- data/lib/tex/kpathsea.rb +63 -0
- data/lib/tex/tfm.rb +1198 -0
- data/lib/tex/vf.rb +846 -0
- metadata +86 -0
data/examples/plinfo
ADDED
@@ -0,0 +1,108 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#--
|
3
|
+
# Last Change: Tue May 16 18:14:38 2006
|
4
|
+
#++
|
5
|
+
=begin rdoc
|
6
|
+
== plinfo -- output information about a pl file.
|
7
|
+
|
8
|
+
Usage: plinfo [options] tfmfile.pl [file...]
|
9
|
+
-e, --encoding enc set the encoding for the file
|
10
|
+
-l, --list-chars list all available characters
|
11
|
+
-h, --help Show this help
|
12
|
+
|
13
|
+
|
14
|
+
---
|
15
|
+
Author:: Patrick Gundlach <patrick@gundla.ch>
|
16
|
+
License:: Copyright (c) 2005 Patrick Gundlach.
|
17
|
+
Released under the terms of the GNU General Public License
|
18
|
+
=end
|
19
|
+
|
20
|
+
|
21
|
+
# :enddoc:
|
22
|
+
|
23
|
+
require 'optparse'
|
24
|
+
require 'ostruct'
|
25
|
+
|
26
|
+
require 'tex/tfm'
|
27
|
+
require 'tex/kpathsea'
|
28
|
+
require 'tex/enc'
|
29
|
+
|
30
|
+
include TeX
|
31
|
+
|
32
|
+
kpse=Kpathsea.new
|
33
|
+
|
34
|
+
@options=OpenStruct.new
|
35
|
+
|
36
|
+
ARGV.options { |opt|
|
37
|
+
opt.banner = "Usage: #{File.basename($0)} [options] tfmfile.pl [file...]"
|
38
|
+
opt.on("--encoding enc", "-e", "set the encoding for the file") { |e|
|
39
|
+
kpse.open_file(e,"enc") { |f|
|
40
|
+
@options.encoding = ENC.new(f)
|
41
|
+
}
|
42
|
+
}
|
43
|
+
opt.on("--list-chars", "-l", "list all available characters") {
|
44
|
+
@options.listchars=true }
|
45
|
+
opt.on("--help", "-h", "Show this help") { puts opt; exit 0 }
|
46
|
+
opt.separator ""
|
47
|
+
opt.parse!
|
48
|
+
}
|
49
|
+
|
50
|
+
if ARGV.size < 1
|
51
|
+
puts "#{File.basename($0)}: Need at least one file argument."
|
52
|
+
puts "Try `#{File.basename($0)} --help' for more information."
|
53
|
+
exit 0
|
54
|
+
end
|
55
|
+
|
56
|
+
|
57
|
+
def dump_maininfo(filename)
|
58
|
+
puts "General font information:"
|
59
|
+
puts "========================="
|
60
|
+
print "filename=#{File.basename(filename)} "
|
61
|
+
# puts @isvpl ? "(vpl)" : "(pl)"
|
62
|
+
puts "Family: #{@tfm.fontfamily}"
|
63
|
+
puts "Designsize: #{@tfm.designsize}"
|
64
|
+
puts "Codingscheme: #{@tfm.codingscheme}"
|
65
|
+
puts "Fontdimen:"
|
66
|
+
paramname=%w( SLANT SPACE STRETCH SHRINK XHEIGHT QUAD EXTRASPACE )
|
67
|
+
if @tfm.codingscheme=="TeX math symbols"
|
68
|
+
paramname += %w(NUM1 NUM2 NUM3 DENOM1 DENOM2 SUP1 SUP2 SUP3
|
69
|
+
SUB1 SUB2 SUPDROP)
|
70
|
+
elsif @tfm.codingscheme=="TeX math extension"
|
71
|
+
paramname += %w(DEFAULT_RULE_THICKNESS BIG_OP_SPACING1
|
72
|
+
BIG_OP_SPACING2 BIG_OP_SPACING3 BIG_OP_SPACING4 BIG_OP_SPACING5)
|
73
|
+
end
|
74
|
+
|
75
|
+
(1..@tfm.params.size-1).each {|i|
|
76
|
+
puts " #{paramname[i-1]} = #{@tfm.params[i]}"
|
77
|
+
}
|
78
|
+
end
|
79
|
+
|
80
|
+
def dump_charsinfo
|
81
|
+
stdformat="%9s|"
|
82
|
+
count=0
|
83
|
+
0.upto(255) { |i|
|
84
|
+
if c=@tfm.chars[i]
|
85
|
+
if count % 32 == 0
|
86
|
+
puts "\n slot| width | height | depth | ic |lig/kern?| extra | char"
|
87
|
+
puts "-----|---------|---------|---------|---------|---------|---------|-------"
|
88
|
+
end
|
89
|
+
|
90
|
+
has_krn= c[:lig_kern] ? "yes" : ""
|
91
|
+
extra = ""
|
92
|
+
char = @options.encoding ? @options.encoding[i] : ""
|
93
|
+
puts sprintf("%5s|"+stdformat*6+" %s", "#{i}","#{c[:charwd]}","#{c[:charht]}","#{c[:chardp]}","#{c[:charic]}", has_krn,"",char)
|
94
|
+
count += 1
|
95
|
+
|
96
|
+
end
|
97
|
+
|
98
|
+
}
|
99
|
+
end
|
100
|
+
|
101
|
+
ARGV.each { |plfilename|
|
102
|
+
@tfm=TFM.new()
|
103
|
+
@tfm.read_pl(plfilename)
|
104
|
+
dump_maininfo(plfilename)
|
105
|
+
if @options.listchars
|
106
|
+
dump_charsinfo
|
107
|
+
end
|
108
|
+
}
|
data/examples/rfii
ADDED
@@ -0,0 +1,257 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# :enddoc:
|
4
|
+
|
5
|
+
require 'pp'
|
6
|
+
require 'ostruct'
|
7
|
+
require 'fileutils'
|
8
|
+
|
9
|
+
|
10
|
+
require 'rfil/fontcollection'
|
11
|
+
require 'tex/kpathsea'
|
12
|
+
|
13
|
+
$:.unshift File.dirname($0)
|
14
|
+
require 'rfii.tab'
|
15
|
+
|
16
|
+
|
17
|
+
class RFII # :nodoc:
|
18
|
+
include RFIL
|
19
|
+
include TeX
|
20
|
+
|
21
|
+
def initialize
|
22
|
+
@instructions=[]
|
23
|
+
@known_encodings=Hash.new
|
24
|
+
@fontset=nil
|
25
|
+
@kpse=Kpathsea.new
|
26
|
+
@known_outputfiles=[:vf,:sty,:tfm,:typescript,:fd,:map]
|
27
|
+
@fontfiles_copied=nil
|
28
|
+
@vendor=nil
|
29
|
+
@texencodings=[]
|
30
|
+
@psencoding=[]
|
31
|
+
@fontroot=File.expand_path(Dir.pwd)
|
32
|
+
@options=OpenStruct.new
|
33
|
+
@options.verbose=false
|
34
|
+
@options.dryrun=false
|
35
|
+
@options.tds=true
|
36
|
+
@fc=nil
|
37
|
+
end
|
38
|
+
|
39
|
+
def parse_file(filename)
|
40
|
+
f=File.open(filename)
|
41
|
+
@s=StringScanner.new(f.read)
|
42
|
+
f.close
|
43
|
+
@mode=:normal
|
44
|
+
@line=1
|
45
|
+
yyparse(self,:scan)
|
46
|
+
end
|
47
|
+
|
48
|
+
def on_error(error_token_id,error_value,value_stack)
|
49
|
+
# puts "error"
|
50
|
+
error=token_to_str(error_token_id)
|
51
|
+
p error_value,value_stack
|
52
|
+
puts "parse error near line #@line, exiting, next string: '#{error_value}#{@s.rest[0..20]}...'"
|
53
|
+
exit 1
|
54
|
+
# the default action would be:
|
55
|
+
# raise ParseError
|
56
|
+
end
|
57
|
+
|
58
|
+
def ensure_encoding(enc)
|
59
|
+
unless @known_encodings.has_key?(enc)
|
60
|
+
puts "Unknown encoding #{enc} in line #{@line}"
|
61
|
+
exit 1
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
def get_encodings(symbols)
|
66
|
+
symbols.collect { |encoding|
|
67
|
+
ensure_encoding(encoding)
|
68
|
+
@known_encodings[encoding]
|
69
|
+
}
|
70
|
+
end
|
71
|
+
def get_encoding(symbol)
|
72
|
+
return :none if symbol==:none or symbol==:same_as_texencoding
|
73
|
+
ensure_encoding(symbol)
|
74
|
+
@known_encodings[symbol]
|
75
|
+
end
|
76
|
+
|
77
|
+
def get_fonts(ident)
|
78
|
+
towrite=[]
|
79
|
+
case ident
|
80
|
+
when [:all],nil
|
81
|
+
towrite=@fontset.keys
|
82
|
+
else
|
83
|
+
towrite=ident
|
84
|
+
end
|
85
|
+
fontlist=[]
|
86
|
+
towrite.each{ |font|
|
87
|
+
if @fontset.has_key?(font)
|
88
|
+
fontlist << @fontset[font]
|
89
|
+
else
|
90
|
+
puts "Font for #{ident} in line #{@line} unknown, ignoring"
|
91
|
+
end
|
92
|
+
}
|
93
|
+
fontlist
|
94
|
+
end
|
95
|
+
def run_instructions
|
96
|
+
@instructions.each { |line,i|
|
97
|
+
@line=line
|
98
|
+
instr,*rest=i
|
99
|
+
case instr
|
100
|
+
when :useencoding
|
101
|
+
# this should be in parser:
|
102
|
+
if rest[1]==:none or rest[1]==:same_as_texencoding
|
103
|
+
puts "invalid encoding name"
|
104
|
+
exit 1
|
105
|
+
end
|
106
|
+
@kpse.open_file(rest[0],"enc") { |encfile|
|
107
|
+
@known_encodings[rest[1]]=ENC.new(encfile)
|
108
|
+
}
|
109
|
+
when :psencoding
|
110
|
+
@psencoding=get_encoding(rest[0])
|
111
|
+
when :texencoding
|
112
|
+
@texencodings=get_encodings(rest[0])
|
113
|
+
when :fontroot
|
114
|
+
@fontroot=File.expand_path(rest[0])
|
115
|
+
unless File.exists?(@fontroot) and File.directory?(@fontroot)
|
116
|
+
puts "fontroot (#{@fontroot})is not a valid directory"
|
117
|
+
exit 1
|
118
|
+
end
|
119
|
+
when :fontsource
|
120
|
+
@fontsource=File.expand_path(rest[0])
|
121
|
+
unless File.exists?(@fontsource) and File.directory?(@fontsource)
|
122
|
+
puts "fontsource (#{@fontsource})is not a valid directory"
|
123
|
+
exit 1
|
124
|
+
end
|
125
|
+
when :newfont
|
126
|
+
@fontset={}
|
127
|
+
@fontfiles_copied={}
|
128
|
+
@fc=RFI::FontCollection.new
|
129
|
+
@fc.options[:dryrun]=@options.dryrun
|
130
|
+
@fc.options[:verbose]=@options.verbose
|
131
|
+
@fc.vendor=@vendor
|
132
|
+
@fc.name=rest[0]
|
133
|
+
@fc.set_dirs({:base=>@fontroot, :tds=>@options.tds})
|
134
|
+
@fc.mapenc=@psencoding
|
135
|
+
@fc.texenc=@texencodings
|
136
|
+
@fc.style=rest[1]
|
137
|
+
when :useafm
|
138
|
+
fontfilename=rest[0]
|
139
|
+
ident=rest[1]
|
140
|
+
srcpath=File.join(@fontsource,fontfilename)
|
141
|
+
unless @fontfiles_copied.has_key?(fontfilename) and @options.copyfonts
|
142
|
+
@fontfiles_copied[fontfilename]=true # dummy value, used as Set
|
143
|
+
|
144
|
+
if @options.verbose
|
145
|
+
puts "copy #{srcpath} to #{@fc.dirs[:afm]}"
|
146
|
+
end
|
147
|
+
unless @options.dryrun
|
148
|
+
@fc.ensure_dir(@fc.dirs[:afm])
|
149
|
+
FileUtils.cp(srcpath,@fc.dirs[:afm])
|
150
|
+
end
|
151
|
+
if @options.verbose
|
152
|
+
puts "copy #{srcpath.chomp(".afm")}.pfb to #{@fc.dirs[:type1]}"
|
153
|
+
end
|
154
|
+
unless @options.dryrun
|
155
|
+
@fc.ensure_dir(@fc.dirs[:type1])
|
156
|
+
FileUtils.cp(srcpath.chomp(".afm")+".pfb",@fc.dirs[:type1])
|
157
|
+
end
|
158
|
+
end
|
159
|
+
f=RFI::Font.new(@fc)
|
160
|
+
i=f.load_variant(File.join(@fontsource,fontfilename))
|
161
|
+
@fontset[ident]=f
|
162
|
+
case ident
|
163
|
+
when :italic
|
164
|
+
f.variant=:italic
|
165
|
+
when :slanted
|
166
|
+
f.variant=:slanted
|
167
|
+
when :bold
|
168
|
+
f.weight=:bold
|
169
|
+
when :bolditalic
|
170
|
+
f.variant=:italic
|
171
|
+
f.weight=:bold
|
172
|
+
when :boldslanted
|
173
|
+
f.variant=:slanted
|
174
|
+
f.weight=:bold
|
175
|
+
when :smallcaps
|
176
|
+
f.variant=:smallcaps
|
177
|
+
end
|
178
|
+
when :write
|
179
|
+
# p rest
|
180
|
+
texencodings = if rest[2]
|
181
|
+
get_encodings(rest[2])
|
182
|
+
else
|
183
|
+
@texencodings
|
184
|
+
end
|
185
|
+
|
186
|
+
psencoding = rest[3] ? get_encoding(rest[3]) : @psencoding
|
187
|
+
rest[0].each { |filetype|
|
188
|
+
case filetype
|
189
|
+
when :vf
|
190
|
+
get_fonts(rest[1]).each { |font|
|
191
|
+
font.texenc=texencodings
|
192
|
+
font.mapenc=psencoding
|
193
|
+
font.write_files({:mapfile=>false})
|
194
|
+
}
|
195
|
+
when :map
|
196
|
+
m = get_fonts(rest[1]).collect { |font|
|
197
|
+
font.texenc=texencodings
|
198
|
+
font.mapenc=psencoding
|
199
|
+
font.maplines
|
200
|
+
}
|
201
|
+
mapdir=@fc.get_dir(:map); @fc.ensure_dir(mapdir)
|
202
|
+
mapfilename=File.join(mapdir,@fc.name+".map")
|
203
|
+
if @options.verbose
|
204
|
+
puts "writing mapfile to #{mapfilename}"
|
205
|
+
end
|
206
|
+
unless @options.dryrun
|
207
|
+
File.open(mapfilename, "w") {|file|
|
208
|
+
file.puts m
|
209
|
+
}
|
210
|
+
end
|
211
|
+
when :fd
|
212
|
+
@fc.run_temps(:latex)
|
213
|
+
when :typescript
|
214
|
+
@fc.run_temps(:context)
|
215
|
+
else
|
216
|
+
puts "unknown filetype: #{filetype}, ignoring"
|
217
|
+
end
|
218
|
+
}
|
219
|
+
when :vendor
|
220
|
+
@vendor=rest[0]
|
221
|
+
if @fc and @fc.respond_to?(:vendor=)
|
222
|
+
@fc.vendor=@vendor
|
223
|
+
end
|
224
|
+
when :set
|
225
|
+
kw,values=rest
|
226
|
+
case kw
|
227
|
+
when :verbose,:dryrun,:tds,:copyfonts
|
228
|
+
if [:true,:false].member?(values)
|
229
|
+
@options.send(kw.to_s+"=",values==:true)
|
230
|
+
else
|
231
|
+
puts "Warning: unkown value for '#{kw}' in line #{@line}, must be one of 'true' or 'false'"
|
232
|
+
end
|
233
|
+
end
|
234
|
+
when :apply
|
235
|
+
instr=rest[0]
|
236
|
+
case instr
|
237
|
+
when :slant
|
238
|
+
font=rest[1]
|
239
|
+
# p @fontset.has_key?(font)
|
240
|
+
@fontset[font].slant=0.167
|
241
|
+
else
|
242
|
+
puts "Unknown instruction (#{instr}) for apply in line #{@line}. Exiting."
|
243
|
+
end
|
244
|
+
else
|
245
|
+
puts "Unknown instruction (#{instr}) in line #{@line}. Exiting."
|
246
|
+
exit 1
|
247
|
+
end
|
248
|
+
}
|
249
|
+
# p @psencoding
|
250
|
+
# p @texencodings
|
251
|
+
# pp @fc
|
252
|
+
end
|
253
|
+
end
|
254
|
+
|
255
|
+
parser = RFII.new
|
256
|
+
parser.parse_file("test/inputfile")
|
257
|
+
parser.run_instructions
|
data/examples/rfont
ADDED
@@ -0,0 +1,188 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#--
|
3
|
+
# Last Change: Tue May 23 20:32:20 2006
|
4
|
+
#++
|
5
|
+
=begin rdoc
|
6
|
+
= rfont -- An example font installer
|
7
|
+
|
8
|
+
rfont uses the RFI Library for installing a family of fonts.
|
9
|
+
|
10
|
+
== Command line parameters
|
11
|
+
Usage: rfont [options] vendor/fontname FILE1 FILE2 ...
|
12
|
+
-c, --copy-fonts Also copy the font outlines
|
13
|
+
-d, --directory DIR Set base directory to DIR
|
14
|
+
--dry-run dry run, don't create any files
|
15
|
+
-m, --list-plugin list available macro support methods
|
16
|
+
-p ENCFILE read/download ENCFILE for the PostScript encoding
|
17
|
+
-s, --style STYLE Style of the font, eg. sans, roman, typewriter
|
18
|
+
--tds Put files in a TDS compliant directory hierarchy
|
19
|
+
-t ENCFILE read ENCFILE for the encoding of the vf file
|
20
|
+
multiple encodings can be given (seperated by ',')
|
21
|
+
-T ENCFILE equivalent to -p ENCFILE -t ENCFILE
|
22
|
+
-u, --use-plugin PLUGIN use plugin files PLUGIN, multiple files seperated by ','
|
23
|
+
-v, --no-vf Do not create virtual fonts for reencoding
|
24
|
+
--verbose Print more then needed on stdout
|
25
|
+
--help print this message and exit.
|
26
|
+
--version print version number and exit.
|
27
|
+
|
28
|
+
== Example usage
|
29
|
+
This is the command line I used to install the Bitstream variant of the font 'Syntax' (from the Corel Draw CD)
|
30
|
+
|
31
|
+
./rfont bitstream/syntax ../corel/hum531*afm -t ec,ts1 -p 8r -d ~/rfitexmf/ -u latex -s sans --verbose --tds -c
|
32
|
+
|
33
|
+
It works, but the <tt>.fd</tt>-file is not perfect yet.
|
34
|
+
---
|
35
|
+
Author:: Patrick Gundlach <patrick@gundla.ch>
|
36
|
+
License:: Copyright (c) 2005 Patrick Gundlach.
|
37
|
+
Released under the terms of the GNU General Public License
|
38
|
+
|
39
|
+
=end
|
40
|
+
|
41
|
+
# :enddoc:
|
42
|
+
|
43
|
+
require 'optparse'
|
44
|
+
require 'ostruct'
|
45
|
+
require 'fileutils'
|
46
|
+
|
47
|
+
require 'rfil/fontcollection'
|
48
|
+
|
49
|
+
include RFIL
|
50
|
+
|
51
|
+
options=OpenStruct.new
|
52
|
+
optionswritevf=true
|
53
|
+
fc=RFI::FontCollection.new
|
54
|
+
|
55
|
+
ret= ARGV.options { |opts|
|
56
|
+
opts.banner = "Usage: #{File.basename($0)} [options] vendor/fontname FILE1 FILE2 ..."
|
57
|
+
opts.on("-c", "--copy-fonts", "Also copy the font outlines") {
|
58
|
+
options.copyfonts=true
|
59
|
+
}
|
60
|
+
|
61
|
+
opts.on("-d DIR", "--directory", "Set base directory to DIR") { |d|
|
62
|
+
fc.set_dirs(d)
|
63
|
+
}
|
64
|
+
opts.on("--dry-run", "dry run, don't create any files") {
|
65
|
+
fc.options[:dryrun]=true
|
66
|
+
options.dryrun=true
|
67
|
+
}
|
68
|
+
opts.on("-m", "--list-plugin", "list available plugins") {
|
69
|
+
puts "The following plugins are known:"
|
70
|
+
puts fc.plugins
|
71
|
+
exit 0;
|
72
|
+
}
|
73
|
+
opts.on("-p ENCFILE", String,
|
74
|
+
"read/download ENCFILE for the PostScript encoding") {|e|
|
75
|
+
fc.mapenc = e
|
76
|
+
}
|
77
|
+
opts.on("-s STYLE", "--style", String, "Style of the font, eg. sans, roman, typewriter") { |s|
|
78
|
+
fc.style=s.to_sym
|
79
|
+
}
|
80
|
+
opts.on("--tds", "Put files in a TDS compliant directory hierarchy") {
|
81
|
+
options.tds=true
|
82
|
+
}
|
83
|
+
opts.on("-t ENCFILE",Array, "read ENCFILE for the encoding of the vf file",
|
84
|
+
"multiple encodings can be given (seperated by ',')") {|e|
|
85
|
+
fc.texenc = e
|
86
|
+
}
|
87
|
+
opts.on("-T ENCFILE",String,"equivalent to -p ENCFILE -t ENCFILE") {|e|
|
88
|
+
fc.mapenc = e
|
89
|
+
fc.texenc = e
|
90
|
+
}
|
91
|
+
opts.on("-u PLUGIN","--use-plugin",Array, "use plugin PLUGIN, multiple files seperated by ','") { |m|
|
92
|
+
options.plugin=m
|
93
|
+
}
|
94
|
+
opts.on("-v", "--no-vf", "Do not create virtual fonts for reencoding") {
|
95
|
+
fc.write_vf=false
|
96
|
+
}
|
97
|
+
opts.on("--verbose","Print more then needed on stdout") {
|
98
|
+
options.verbose=true
|
99
|
+
fc.options[:verbose]=true
|
100
|
+
}
|
101
|
+
opts.on_tail("--help","print this message and exit.") { puts opts; exit 0 }
|
102
|
+
opts.on_tail("--version","print version number and exit.") {
|
103
|
+
puts "#{File.basename($0)}: Version 0.1"
|
104
|
+
exit 0
|
105
|
+
}
|
106
|
+
opts.parse!
|
107
|
+
}
|
108
|
+
unless ret
|
109
|
+
puts "See --help for usage information"
|
110
|
+
exit(-1)
|
111
|
+
end
|
112
|
+
|
113
|
+
|
114
|
+
vendor_fontname=ARGV.shift
|
115
|
+
|
116
|
+
if vendor_fontname
|
117
|
+
options.vendor,options.fontname=vendor_fontname.split('/')
|
118
|
+
end
|
119
|
+
if options.vendor==nil or options.fontname==nil
|
120
|
+
puts "You must name vendor and fontname this way: vendor/fontname"
|
121
|
+
puts "See --help for usage information"
|
122
|
+
exit(-1)
|
123
|
+
end
|
124
|
+
|
125
|
+
|
126
|
+
|
127
|
+
fc.name=options.fontname
|
128
|
+
fc.vendor=options.vendor
|
129
|
+
|
130
|
+
fc.set_dirs(:tds=>true) if options.tds
|
131
|
+
|
132
|
+
fonts=[]
|
133
|
+
maplines=""
|
134
|
+
|
135
|
+
if ARGV.empty?
|
136
|
+
puts "No fonts given.\nSee --help for usage information"
|
137
|
+
exit -1
|
138
|
+
end
|
139
|
+
fontoutlinedir=File.dirname(ARGV[0])
|
140
|
+
|
141
|
+
ARGV.each { |fontname|
|
142
|
+
# puts "reading font #{File.basename(fontname)}"
|
143
|
+
f=RFI::Font.new(fc)
|
144
|
+
f.load_variant(fontname)
|
145
|
+
fonts.push f
|
146
|
+
}
|
147
|
+
|
148
|
+
fc.fonts.each { |font|
|
149
|
+
puts "Processing font #{font.defaultfm.fontname}"
|
150
|
+
font.guess_weight_variant
|
151
|
+
font.apply_ligkern_instructions(RFI::STDLIGKERN)
|
152
|
+
font.write_files(:dryrun=>options.dryrun==true,
|
153
|
+
:verbose=>false, :mapfile=>false
|
154
|
+
)
|
155
|
+
maplines << font.maplines.to_s
|
156
|
+
}
|
157
|
+
|
158
|
+
|
159
|
+
if options.copyfonts
|
160
|
+
fc.fonts.each { |font|
|
161
|
+
font.find_used_fonts.each {|varnumber|
|
162
|
+
fontmetric=font.variants[varnumber]
|
163
|
+
destdir=font.get_dir(fontmetric.outlinetype)
|
164
|
+
sourcefile=File.join(fontoutlinedir,fontmetric.fontfilename)
|
165
|
+
destfile=File.join(destdir,fontmetric.fontfilename)
|
166
|
+
puts "Copying #{sourcefile} to #{destfile}" if options.verbose
|
167
|
+
fc.ensure_dir(destdir)
|
168
|
+
unless options.dryrun
|
169
|
+
FileUtils.cp(sourcefile,destfile)
|
170
|
+
end
|
171
|
+
}
|
172
|
+
}
|
173
|
+
end
|
174
|
+
|
175
|
+
mapdir=fc.get_dir(:map)
|
176
|
+
mapfile=File.join(mapdir,options.fontname)
|
177
|
+
puts "Writing mapfile #{mapfile}" if options.verbose
|
178
|
+
unless fc.options[:dryrun]
|
179
|
+
fc.ensure_dir(mapdir)
|
180
|
+
File.open(mapfile + ".map", "w") { |f|
|
181
|
+
f << maplines
|
182
|
+
}
|
183
|
+
end
|
184
|
+
|
185
|
+
if options.plugin
|
186
|
+
options.plugin.each { |m| fc.run_plugin(m.to_sym) }
|
187
|
+
end
|
188
|
+
|