Sha256: 610e8d3a73658af5b5ab09cb8539979a9e7aeebefa2624a54447fdc3d67d86d5
Contents?: true
Size: 1.22 KB
Versions: 7
Compression:
Stored size: 1.22 KB
Contents
# frozen_string_literal: true class Prawn::Font::AFM if defined? ::Asciidoctor::Logging include ::Asciidoctor::Logging else include ::Asciidoctor::LoggingShim end FALLBACK_CHARS = { ?\u200b => '', ?\u202f => ?\u00a0, ?\u2009 => ' ', ?\u25e6 => '-', ?\u25aa => ?\u00b7 } remove_method :normalize_encoding # Patch normalize_encoding method to handle conversion more gracefully. # # Any valid utf-8 characters that cannot be encoded to windows-1252 are # replaced with the logic "not" symbol and a warning is issued identifying # the text that cannot be converted. def normalize_encoding text text.encode 'windows-1252', fallback: FALLBACK_CHARS rescue ::Encoding::UndefinedConversionError logger.warn %(The following text could not be fully converted to the Windows-1252 character set: #{text.gsub(/^/, '| ').rstrip}) text.encode 'windows-1252', undef: :replace, replace: ?\u00ac rescue ::Encoding::InvalidByteSequenceError raise Prawn::Errors::IncompatibleStringEncoding, %(Your document includes text which is not compatible with the Windows-1252 character set. If you need full UTF-8 support, use TTF fonts instead of the built-in PDF (AFM) fonts.) end end
Version data entries
7 entries across 7 versions & 1 rubygems