Module: TTFunk::Table::Cmap::Format10

### Home Classes Methods

### In Files

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

### Methods

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

### 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::Format10

### Attributes

code_map[R]
language[R]

### Public Class Methods

encode(charmap) click to toggle source

    # File lib/ttfunk/table/cmap/format10.rb, line 9
    def self.encode(charmap)
      next_id = 0
      glyph_map = { 0 => 0 }

      sorted_chars = charmap.keys.sort
      low_char, high_char = sorted_chars.first, sorted_chars.last
      entry_count = (1+high_char-low_char)
      glyph_indexes = Array.new(entry_count, 0)

      new_map = charmap.keys.sort.inject({}) do |map, code|
        glyph_map[charmap[code]] ||= next_id += 1
        map[code] = { :old => charmap[code], :new => glyph_map[charmap[code]] }
        glyph_indexes[code - low_char] = glyph_map[charmap[code]]
        map
      end

      subtable = [10, 0, 20+entry_count*4, 0, low_char, entry_count, *glyph_indexes].pack('nnN*')

      { :charmap => new_map, :subtable => subtable, :max_glyph_id => next_id+1 }
    end

### Public Instance Methods

[](code) click to toggle source

    # File lib/ttfunk/table/cmap/format10.rb, line 30
    def [](code)
      @code_map[code] || 0
    end

supported?() click to toggle source

    # File lib/ttfunk/table/cmap/format10.rb, line 34
    def supported?
      true
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.