class HexaPDF::Font::TrueType::Table::Name::Record

The string value is converted to UTF-8 if possible, otherwise it stays in BINARY.
Contains the information for a Name Record.

def initialize(text, pid, eid, lid)

Create a new name record.
def initialize(text, pid, eid, lid)
  @platform_id = pid
  @encoding_id = eid
  @language_id = lid
  if platform?(:unicode) ||
      (platform?(:microsoft) && encoding_id == 1 || encoding_id == 10)
    text.encode!(::Encoding::UTF_8, ::Encoding::UTF_16BE)
  elsif platform?(:macintosh) && encoding_id == 0
    text.encode!(::Encoding::UTF_8, ::Encoding::MACROMAN)
  end
  super(text)
end

def platform?(identifier)

:unicode, :macintosh or :microsoft.
Returns +true+ if this record has the given platform identifier which can either be
def platform?(identifier)
  platform_id == case identifier
                 when :unicode then PLATFORM_UNICODE
                 when :macintosh then PLATFORM_MACINTOSH
                 when :microsoft then PLATFORM_MICROSOFT
                 else
                   raise ArgumentError, "Unknown platform identifier: #{identifier}"
                 end
end

def preferred?

* platform_id :microsoft, encoding_id 1 (Unicode) and language_id 1033 (US English).
* platform_id :macintosh, encoding_id 0 (Roman) and language_id 0 (English); or
name in a decodable encoding:
The label "preferred" is set on a name if it represents the US English version of the

Returns +true+ if this record is a "preferred" one.
def preferred?
  (platform_id == PLATFORM_MACINTOSH && encoding_id == 0 && language_id == 0) ||
    (platform_id == PLATFORM_MICROSOFT && encoding_id == 1 && language_id == 1033)
end