lib/prawn/font/afm.rb in prawn-1.0.0 vs lib/prawn/font/afm.rb in prawn-1.1.0

- old
+ new

@@ -155,11 +155,11 @@ "Couldn't find the font: #{file} in any of:\n" + self.class.metrics_path.join("\n") end def parse_afm(file_name) - data = {:glyph_widths => {}, :bounding_boxes => {}, :kern_pairs => {}, :attributes => {}} + data = {:glyph_widths => {}, :bounding_boxes => {}, :kern_pairs => {}, :attributes => {}} section = [] File.foreach(file_name) do |line| case line when /^Start(\w+)/ @@ -185,11 +185,11 @@ next else parse_generic_afm_attribute(line, data) end end - + # process data parsed from AFM file to build tables which # will be used when measuring and kerning text data[:glyph_table] = (0..255).map do |i| data[:glyph_widths][Encoding::WinAnsi::CHARACTERS[i]].to_i end @@ -232,12 +232,12 @@ kerned.map { |e| e = (Array === e ? e.pack("C*") : e) e.respond_to?(:force_encoding) ? e.force_encoding(::Encoding::Windows_1252) : e } end - + private - + def unscaled_width_of(string) string.bytes.inject(0) do |s,r| s + @glyph_table[r] end end