Skip to content
Browse files

Backwards compatibility for Ruby 1.8.

  • Loading branch information...
1 parent 4f6861f commit 5ba8354e46d2991a80fc98a921c756c7c640f610 @rolftimmermans committed Apr 13, 2012
Showing with 8 additions and 3 deletions.
  1. +8 −3 lib/prawn/svg/font.rb
View
11 lib/prawn/svg/font.rb
@@ -56,8 +56,8 @@ def self.installed_fonts
def self.font_information(filename)
File.open(filename, "r") do |f|
- x = f.read(12).ord
- table_count = x[4] * 256 + x[5]
+ x = f.read(12)
+ table_count = x[4].ord * 256 + x[5].ord
tables = f.read(table_count * 16)
offset, length = table_count.times do |index|
@@ -84,7 +84,12 @@ def self.font_information(filename)
field = data[offset..offset+length-1]
names[name_id] = if platform_id == 0
begin
- field.encode(Encoding::UTF16)
+ if field.respond_to?(:encode)
+ field.encode(Encoding::UTF16)
+ else
+ require "iconv"
+ Iconv.iconv('UTF-8', 'UTF-16', field)
+ end
rescue
field
end

0 comments on commit 5ba8354

Please sign in to comment.
Something went wrong with that request. Please try again.