Class: TTFunk::Table::Cmap::Subtable

### Home Classes Methods

### In Files

- lib/ttfunk/table/cmap/subtable.rb

### Parent

Object

### Methods

- ::encode
- ::new
- #[]
- #supported?
- #unicode?

### Included Modules

- TTFunk::Reader

### Class/Module Index

Quicksearch

- TTFunk
- TTFunk::Directory
- TTFunk::Encoding
- TTFunk::Encoding::MacRoman
- TTFunk::Encoding::Windows1252
- TTFunk::File
- TTFunk::Reader
- TTFunk::ResourceFile
- TTFunk::Subset
- TTFunk::Subset::Base
- TTFunk::Subset::MacRoman
- TTFunk::Subset::Unicode
- TTFunk::Subset::Unicode8Bit
- TTFunk::Subset::Windows1252
- TTFunk::SubsetCollection
- TTFunk::Table
- TTFunk::Table::Cmap
- TTFunk::Table::Cmap::Format00
- TTFunk::Table::Cmap::Format04
- TTFunk::Table::Cmap::Format06
- TTFunk::Table::Cmap::Format10
- TTFunk::Table::Cmap::Format12
- TTFunk::Table::Cmap::Subtable
- TTFunk::Table::Glyf
- TTFunk::Table::Glyf::Compound
- TTFunk::Table::Glyf::Simple
- TTFunk::Table::Head
- TTFunk::Table::Hhea
- TTFunk::Table::Hmtx
- TTFunk::Table::Kern
- TTFunk::Table::Kern::Format0
- TTFunk::Table::Loca
- TTFunk::Table::Maxp
- TTFunk::Table::Name
- TTFunk::Table::Name::String
- TTFunk::Table::OS2
- TTFunk::Table::Post
- TTFunk::Table::Post::Format10
- TTFunk::Table::Post::Format20
- TTFunk::Table::Post::Format30
- TTFunk::Table::Post::Format40
- TTFunk::Table::Sbix
- TTFunk::Table::Simple

No matching classes.

# TTFunk::Table::Cmap::Subtable

### Constants

ENCODING_MAPPINGS

### Attributes

encoding_id[R]
format[R]
platform_id[R]

### Public Class Methods

encode(charmap, encoding) click to toggle source

    # File lib/ttfunk/table/cmap/subtable.rb, line 20
    def self.encode(charmap, encoding)
      case encoding
      when :mac_roman
        result = Format00.encode(charmap)
      when :unicode
        result = Format04.encode(charmap)
      when :unicode_ucs4
        result = Format12.encode(charmap)
      else
        raise NotImplementedError, "encoding #{encoding.inspect} is not supported"
      end

      mapping = ENCODING_MAPPINGS[encoding]

      # platform-id, encoding-id, offset
      result[:subtable] = [mapping[:platform_id], mapping[:encoding_id],
        12, result[:subtable]].pack("nnNA*")

      return result
    end

new(file, table_start) click to toggle source

    # File lib/ttfunk/table/cmap/subtable.rb, line 41
    def initialize(file, table_start)
      @file = file
      @platform_id, @encoding_id, @offset = read(8, "nnN")
      @offset += table_start

      parse_from(@offset) do
        @format = read(2, "n").first

        case @format
          when 0  then extend(TTFunk::Table::Cmap::Format00)
          when 4  then extend(TTFunk::Table::Cmap::Format04)
          when 6  then extend(TTFunk::Table::Cmap::Format06)
          when 10 then extend(TTFunk::Table::Cmap::Format10)
          when 12 then extend(TTFunk::Table::Cmap::Format12)
        end

        parse_cmap!
      end
    end

### Public Instance Methods

[](code) click to toggle source

    # File lib/ttfunk/table/cmap/subtable.rb, line 70
    def [](code)
      raise NotImplementedError, "cmap format #{@format} is not supported"
    end

supported?() click to toggle source

    # File lib/ttfunk/table/cmap/subtable.rb, line 66
    def supported?
      false
    end

unicode?() click to toggle source

    # File lib/ttfunk/table/cmap/subtable.rb, line 61
    def unicode?
      platform_id == 3 && (encoding_id == 1 || encoding_id == 10) && format != 0 ||
      platform_id == 0 && format != 0
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.