lib/prawn/font/ttf.rb in prawn-0.13.0 vs lib/prawn/font/ttf.rb in prawn-0.13.1

- old
+ new

@@ -158,21 +158,29 @@ flags |= 0x0004 # assume the font contains at least some non-latin characters end end def normalize_encoding(text) - text.normalize_to_utf8 + begin + text.encode(::Encoding::UTF_8) + rescue => e + puts e + raise Prawn::Errors::IncompatibleStringEncoding, "Encoding " + + "#{text.encoding} can not be transparently converted to UTF-8. " + + "Please ensure the encoding of the string you are attempting " + + "to use is set correctly" + end end def glyph_present?(char) code = char.codepoints.first cmap[code] > 0 end # Returns the number of characters in +str+ (a UTF-8-encoded string). # def character_count(str) - str.unicode_length + str.length end private def cmap