lib/prawn/svg/font.rb in prawn-svg-0.9.1.10 vs lib/prawn/svg/font.rb in prawn-svg-0.9.1.11

- old
+ new

@@ -1,7 +1,5 @@ -require 'iconv' - class Prawn::Svg::Font BUILT_IN_FONTS = ["Courier", "Helvetica", "Times-Roman", "Symbol", "ZapfDingbats"] GENERIC_CSS_FONT_MAPPING = { "serif" => "Times-Roman", @@ -57,11 +55,11 @@ end def self.font_information(filename) File.open(filename, "r") do |f| x = f.read(12) - table_count = x[4] * 256 + x[5] + table_count = x[4].ord * 256 + x[5].ord tables = f.read(table_count * 16) offset, length = table_count.times do |index| start = index * 16 if tables[start..start+3] == 'name' @@ -84,10 +82,15 @@ offset += string_offset field = data[offset..offset+length-1] names[name_id] = if platform_id == 0 begin - Iconv.iconv('UTF-8', 'UTF-16', field) + if field.respond_to?(:encode) + field.encode(Encoding::UTF16) + else + require "iconv" + Iconv.iconv('UTF-8', 'UTF-16', field) + end rescue field end else field