class TTFunk::Table::Post

Attributes

fixed_pitch[R]
format[R]
italic_angle[R]
max_mem_type1[R]
max_mem_type42[R]
min_mem_type1[R]
min_mem_type42[R]
subtable[R]
underline_position[R]
underline_thickness[R]

Public Class Methods

encode(post, mapping) click to toggle source
# File lib/ttfunk/table/post.rb, line 18
def self.encode(post, mapping)
  return nil unless post.exists?
  post.recode(mapping)
end

Public Instance Methods

fixed_pitch?() click to toggle source
# File lib/ttfunk/table/post.rb, line 23
def fixed_pitch?
  @fixed_pitch != 0
end
glyph_for(code) click to toggle source
# File lib/ttfunk/table/post.rb, line 27
def glyph_for(code)
  ".notdef"
end
recode(mapping) click to toggle source
# File lib/ttfunk/table/post.rb, line 31
def recode(mapping)
  return raw if format == 0x00030000

  table = raw[0,32]
  table[0,4] = [0x00020000].pack("N")

  index = []
  strings = []

  mapping.keys.sort.each do |new_id|
    post_glyph = glyph_for(mapping[new_id])
    position = Format10::POSTSCRIPT_GLYPHS.index(post_glyph)
    if position
      index << position
    else
      index << 257 + strings.length
      strings << post_glyph
    end
  end

  table << [mapping.length, *index].pack("n*")
  strings.each do |string|
    table << [string.length, string].pack("CA*")
  end

  return table
end

Private Instance Methods

parse!() click to toggle source
# File lib/ttfunk/table/post.rb, line 61
def parse!
  @format, @italic_angle, @underline_position, @underline_thickness,
    @fixed_pitch, @min_mem_type42, @max_mem_type42, 
    @min_mem_type1, @max_mem_type1 = read(32, "N2n2N*")

  end_of_table = offset + length

  @subtable = case @format
    when 0x00010000 then extend(Post::Format10)
    when 0x00020000 then extend(Post::Format20)
    when 0x00025000 then extend(Post::Format25)
    when 0x00030000 then extend(Post::Format30)
    when 0x00040000 then extend(Post::Format40)
    end

  parse_format!
end
parse_format!() click to toggle source
# File lib/ttfunk/table/post.rb, line 79
def parse_format!
  warn "postscript table format 0x%08X is not supported" % @format
end