class TTFunk::Table::Cff

Compact Font Format (‘CFF `) table

Constants

TAG

Table tag. The extra space is important.

Attributes

global_subr_index[R]

Global subroutine index. @return [TTFunk::Table::Cff::SubrIndex]

header[R]

Table header. @return [TTFunk::Table::Cff::Header]

name_index[R]

Name index. @return [TTFunk::Table::Cff::Index]

string_index[R]

Strings index. @return [TTFunk::Table::Cff::OneBasedIndex]

top_index[R]

Top dict index. @return [TTFunk::Table::Cff::TopIndex]

Public Instance Methods

encode(subset) click to toggle source

Encode table.

@param subset [TTFunk::Subset::MacRoman, TTFunk::Subset::Windows1252,

TTFunk::Subset::Unicode, TTFunk::Subset::Unicode8Bit]

@return [TTFunk::EncodedString]

# File lib/ttfunk/table/cff.rb, line 60
def encode(subset)
  # Make sure TopDict has an entry for encoding so it could be properly replaced
  top_index[0][TopDict::OPERATORS[:encoding]] = 0

  EncodedString.new do |result|
    result.concat(
      header.encode,
      name_index.encode,
      top_index.encode,
      string_index.encode,
      global_subr_index.encode,
    )

    charmap = subset.new_cmap_table[:charmap]
    top_index[0].finalize(result, charmap)
  end
end
tag() click to toggle source

Table tag. @return [String]

# File lib/ttfunk/table/cff.rb, line 51
def tag
  TAG
end

Private Instance Methods

parse!() click to toggle source
# File lib/ttfunk/table/cff.rb, line 80
def parse!
  @header = Header.new(file, offset)
  @name_index = Index.new(file, @header.table_offset + @header.length)
  @top_index = TopIndex.new(file, @name_index.table_offset + @name_index.length)
  @string_index = OneBasedIndex.new(file, @top_index.table_offset + @top_index.length)
  @global_subr_index = SubrIndex.new(file, @string_index.table_offset + @string_index.length)
end