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)
29 buf = open_bdf(filename)
34 glyph_processing = false
36 items = buf.line.split(/ /)
37 if items[0] == 'STARTCHAR'
38 glyph_processing = true
41 @glyph_ref[g.name] = g
43 glyph_processing ? @footer << buf.line : @header << buf.line
57 glyphs = @glyph_ref.values.sort {|x,y| x.encoding <=> y.encoding}
58 @header.each {|h| io.puts h =~ /^CHARS / ? "CHARS #{glyphs.length}" : h}
59 glyphs.each {|g| g.write(io) }
60 @footer.each {|h| io.puts h}
83 0x1EA4 => 'Acircumflex',
84 0x1EA5 => 'acircumflex',
85 0x1EA6 => 'Acircumflex',
86 0x1EA7 => 'acircumflex',
87 0x1EA8 => 'Acircumflex',
88 0x1EA9 => 'acircumflex',
89 0x1EAA => 'Acircumflex',
90 0x1EAB => 'acircumflex',
91 0x1EAC => 'Acircumflex',
92 0x1EAD => 'acircumflex',
108 0x1EBE => 'Ecircumflex',
109 0x1EBF => 'ecircumflex',
110 0x1EC0 => 'Ecircumflex',
111 0x1EC1 => 'ecircumflex',
112 0x1EC2 => 'Ecircumflex',
113 0x1EC3 => 'ecircumflex',
114 0x1EC4 => 'Ecircumflex',
115 0x1EC5 => 'ecircumflex',
116 0x1EC6 => 'Ecircumflex',
117 0x1EC7 => 'ecircumflex',
127 0x1ED0 => 'Ocircumflex',
128 0x1ED1 => 'ocircumflex',
129 0x1ED2 => 'Ocircumflex',
130 0x1ED3 => 'ocircumflex',
131 0x1ED4 => 'Ocircumflex',
132 0x1ED5 => 'ocircumflex',
133 0x1ED6 => 'Ocircumflex',
134 0x1ED7 => 'ocircumflex',
135 0x1ED8 => 'Ocircumflex',
136 0x1ED9 => 'ocircumflex',
174 def copy_glyph(name,bdf)
175 g = bdf.glyph_ref[name].dup
176 @glyph_ref[g.name] = g
179 def copy_glyph_by_id(name,bdf)
181 self.copy_glyph(name,bdf)
184 name.each {|x| self.copy_glyph_by_id(x,bdf) }
189 def dup_glyph(name,newname,newencoding,bdf = nil)
190 g = bdf.nil? ? @glyph_ref[name].dup : bdf.glyph_ref[name].dup
192 g.encoding = newencoding
193 @glyph_ref[g.name] = g
196 def dup_glyph_by_id(id,bdf = nil)
198 return unless REFS.key? id
199 name = NAMES[id] || "uni#{id.to_s(16).upcase}"
200 self.dup_glyph(REFS[id],name,id,bdf)
203 id.each {|x| self.dup_glyph_by_id(x,bdf) }
209 self.copy_glyph_by_id(REFS.keys.map {|x| NAMES[x] || "uni#{x.to_s(16).upcase}"} ,bdf)
212 def dup_all(bdf = nil)
213 #$bdf.dup_glyph_by_id([416, 417, 431, 432, 7922, 7923,
214 #0x1EA0, 0x1EA1, 0x1EA2, 0x1EA3,
215 #0x1EA4, 0x1EA5, 0x1EA6, 0x1EA7, 0x1EA8, 0x1EA9, 0x1EAA, 0x1EAB, 0x1EAC, 0x1EAD,
216 #0x1EAE, 0x1EAF, 0x1EB0, 0x1EB1, 0x1EB2, 0x1EB3, 0x1EB4, 0x1EB5, 0x1EB6, 0x1EB7,
218 #0x1EBE, 0x1EBF, 0x1EC0, 0x1EC1, 0x1EC2, 0x1EC3, 0x1EC4, 0x1EC5, 0x1EC6, 0x1EC7,
219 #0x1EC8, 0x1EC9, 0x1ECA, 0x1ECB,
221 #0x1ED0, 0x1ED1, 0x1ED2, 0x1ED3, 0x1ED4, 0x1ED5, 0x1ED6, 0x1ED7, 0x1ED8, 0x1ED9,
222 #0x1EDA, 0x1EDB, 0x1EDC, 0x1EDD, 0x1EDE, 0x1EDF, 0x1EE0, 0x1EE1, 0x1EE2, 0x1EE3,
223 #0x1EE4, 0x1EE5, 0x1EE6, 0x1EE7,
224 #0x1EE8, 0x1EE9, 0x1EEA, 0x1EEB, 0x1EEC, 0x1EED, 0x1EEE, 0x1EEF, 0x1EF0, 0x1EF1,
225 #0x1EF4, 0x1EF5, 0x1EF6, 0x1EF7])
226 self.dup_glyph_by_id(REFS.keys,bdf)
231 attr_reader :swidth, :dwidth, :bbx, :bitmap
232 attr_accessor :encoding, :name
237 while (!buf.empty && !done) do
238 items = buf.line.split(/ /)
240 if items[0] == 'ENDCHAR'
246 @name = items[1].dup if items[0] == 'STARTCHAR'
247 @encoding = items[1].to_i if items[0] == 'ENCODING'
248 @swidth = items.dup if items[0] == 'SWIDTH'
249 @dwidth = items.dup if items[0] == 'DWIDTH'
250 @bbx = items.dup if items[0] == 'BBX'
251 bitmap_phase = true if buf.line == 'BITMAP'
259 io.puts "STARTCHAR #@name"
260 io.puts "ENCODING #@encoding"
261 io.puts @swidth.join(' ')
262 io.puts @dwidth.join(' ')
263 io.puts @bbx.join(' ')
265 @bitmap.each {|b| io.puts b}
270 #$buf = open_bdf('ter-u16n.bdf')
271 #$bdf = BDF.new($buf)
275 #b = BDF.new('ter-u12n.bdf')
277 #c = File.open('zzo','w')