class TTFunk::Encoding::Windows1252

Constants

FROM_UNICODE
POSTSCRIPT_GLYPH_MAPPING

Maps Windows-1252 codes to their corresponding index in the Postscript glyph table (see TTFunk::Table::Post::Format10). If any entry in this array is a string, it is a postscript glyph that is not in the standard list, and which should be emitted specially in the TTF postscript table ('post', see format 2). rubocop: disable Metrics/LineLength,Style/AlignArray,Style/IndentArray

TO_UNICODE

rubocop: disable Style/ExtraSpacing

Public Class Methods

covers?(character) click to toggle source

rubocop: enable Style/AlignArray,Metrics/LineLength,Style/ExtraSpacing,Style/IndentArray

# File lib/ttfunk/encoding/windows_1252.rb, line 47
def self.covers?(character)
  !FROM_UNICODE[character].nil?
end
from_unicode(string) click to toggle source
# File lib/ttfunk/encoding/windows_1252.rb, line 63
def self.from_unicode(string)
  from_unicode_codepoints(string.unpack('n*')).pack('C*')
end
from_unicode_codepoints(array) click to toggle source
# File lib/ttfunk/encoding/windows_1252.rb, line 71
def self.from_unicode_codepoints(array)
  array.map { |code| FROM_UNICODE[code] || 0 }
end
from_utf8(string) click to toggle source
# File lib/ttfunk/encoding/windows_1252.rb, line 59
def self.from_utf8(string)
  from_unicode_codepoints(string.unpack('U*')).pack('C*')
end
to_unicode(string) click to toggle source
# File lib/ttfunk/encoding/windows_1252.rb, line 55
def self.to_unicode(string)
  to_unicode_codepoints(string.unpack('C*')).pack('n*')
end
to_unicode_codepoints(array) click to toggle source
# File lib/ttfunk/encoding/windows_1252.rb, line 67
def self.to_unicode_codepoints(array)
  array.map { |code| TO_UNICODE[code] }
end
to_utf8(string) click to toggle source
# File lib/ttfunk/encoding/windows_1252.rb, line 51
def self.to_utf8(string)
  to_unicode_codepoints(string.unpack('C*')).pack('U*')
end