2 f = File.open(file,'r')
3 buf = f.readlines.map {|x| x.chomp}
27 attr_reader :glyphs, :header, :glyph_ref
28 def initialize(filename = false)
33 if filename.is_a? String
34 buf = open_bdf(filename)
35 glyph_processing = false
37 items = buf.line.split(/ /)
38 if items[0] == 'STARTCHAR'
39 glyph_processing = true
42 @glyph_ref[g.name] = g
44 glyph_processing ? @footer << buf.line : @header << buf.line
59 glyphs = @glyph_ref.values.sort {|x,y| x.encoding <=> y.encoding}
60 @header.each {|h| io.puts h =~ /^CHARS / ? "CHARS #{glyphs.length}" : h}
61 glyphs.each {|g| g.write(io) }
62 @footer.each {|h| io.puts h}
85 0x1EA4 => 'Acircumflex',
86 0x1EA5 => 'acircumflex',
87 0x1EA6 => 'Acircumflex',
88 0x1EA7 => 'acircumflex',
89 0x1EA8 => 'Acircumflex',
90 0x1EA9 => 'acircumflex',
91 0x1EAA => 'Acircumflex',
92 0x1EAB => 'acircumflex',
93 0x1EAC => 'Acircumflex',
94 0x1EAD => 'acircumflex',
110 0x1EBE => 'Ecircumflex',
111 0x1EBF => 'ecircumflex',
112 0x1EC0 => 'Ecircumflex',
113 0x1EC1 => 'ecircumflex',
114 0x1EC2 => 'Ecircumflex',
115 0x1EC3 => 'ecircumflex',
116 0x1EC4 => 'Ecircumflex',
117 0x1EC5 => 'ecircumflex',
118 0x1EC6 => 'Ecircumflex',
119 0x1EC7 => 'ecircumflex',
129 0x1ED0 => 'Ocircumflex',
130 0x1ED1 => 'ocircumflex',
131 0x1ED2 => 'Ocircumflex',
132 0x1ED3 => 'ocircumflex',
133 0x1ED4 => 'Ocircumflex',
134 0x1ED5 => 'ocircumflex',
135 0x1ED6 => 'Ocircumflex',
136 0x1ED7 => 'ocircumflex',
137 0x1ED8 => 'Ocircumflex',
138 0x1ED9 => 'ocircumflex',
176 def copy_glyph(name,bdf)
177 if bdf.glyph_ref[name].nil?
178 STDERR.puts "Glyph #{name} not found"
180 g = bdf.glyph_ref[name].dup
181 @glyph_ref[g.name] = g
185 def copy_glyph_by_id(name,bdf)
187 self.copy_glyph(name,bdf)
190 name.each {|x| self.copy_glyph_by_id(x,bdf) }
195 def dup_glyph(name,newname,newencoding,bdf = nil)
196 g = bdf.nil? ? @glyph_ref[name].dup : bdf.glyph_ref[name].dup
198 g.encoding = newencoding
199 @glyph_ref[g.name] = g
202 def dup_glyph_by_id(id,bdf = nil)
204 return unless REFS.key? id
205 name = NAMES[id] || "uni#{id.to_s(16).upcase}"
206 self.dup_glyph(REFS[id],name,id,bdf)
209 id.each {|x| self.dup_glyph_by_id(x,bdf) }
215 self.copy_glyph_by_id(REFS.keys.map {|x| NAMES[x] || "uni#{x.to_s(16).upcase}"} ,bdf)
218 def dup_all(bdf = nil)
219 #$bdf.dup_glyph_by_id([416, 417, 431, 432, 7922, 7923,
220 #0x1EA0, 0x1EA1, 0x1EA2, 0x1EA3,
221 #0x1EA4, 0x1EA5, 0x1EA6, 0x1EA7, 0x1EA8, 0x1EA9, 0x1EAA, 0x1EAB, 0x1EAC, 0x1EAD,
222 #0x1EAE, 0x1EAF, 0x1EB0, 0x1EB1, 0x1EB2, 0x1EB3, 0x1EB4, 0x1EB5, 0x1EB6, 0x1EB7,
224 #0x1EBE, 0x1EBF, 0x1EC0, 0x1EC1, 0x1EC2, 0x1EC3, 0x1EC4, 0x1EC5, 0x1EC6, 0x1EC7,
225 #0x1EC8, 0x1EC9, 0x1ECA, 0x1ECB,
227 #0x1ED0, 0x1ED1, 0x1ED2, 0x1ED3, 0x1ED4, 0x1ED5, 0x1ED6, 0x1ED7, 0x1ED8, 0x1ED9,
228 #0x1EDA, 0x1EDB, 0x1EDC, 0x1EDD, 0x1EDE, 0x1EDF, 0x1EE0, 0x1EE1, 0x1EE2, 0x1EE3,
229 #0x1EE4, 0x1EE5, 0x1EE6, 0x1EE7,
230 #0x1EE8, 0x1EE9, 0x1EEA, 0x1EEB, 0x1EEC, 0x1EED, 0x1EEE, 0x1EEF, 0x1EF0, 0x1EF1,
231 #0x1EF4, 0x1EF5, 0x1EF6, 0x1EF7])
232 self.dup_glyph_by_id(REFS.keys,bdf)
237 attr_reader :swidth, :dwidth, :bbx, :bitmap
238 attr_accessor :encoding, :name
243 while (!buf.empty && !done) do
244 items = buf.line.split(/ /)
246 if items[0] == 'ENDCHAR'
252 @name = items[1].dup if items[0] == 'STARTCHAR'
253 @encoding = items[1].to_i if items[0] == 'ENCODING'
254 @swidth = items.dup if items[0] == 'SWIDTH'
255 @dwidth = items.dup if items[0] == 'DWIDTH'
256 @bbx = items.dup if items[0] == 'BBX'
257 bitmap_phase = true if buf.line == 'BITMAP'
265 io.puts "STARTCHAR #@name"
266 io.puts "ENCODING #@encoding"
267 io.puts @swidth.join(' ')
268 io.puts @dwidth.join(' ')
269 io.puts @bbx.join(' ')
271 @bitmap.each {|b| io.puts b}
276 #$buf = open_bdf('ter-u16n.bdf')
277 #$bdf = BDF.new($buf)
281 #b = BDF.new('ter-u12n.bdf')
283 #c = File.open('zzo','w')