class TTFunk::Table::Vorg

Vertical Origin (‘VORG`) table.

Constants

TAG

Table tag.

Attributes

count[R]

Number of vertical origin metrics. @return [Integer]

default_vert_origin_y[R]

The default y coordinate of a glyph’s vertical origin. @return [Integer]

major_version[R]

Table major version. @return [Integer]

minor_version[R]

Table minor version. @return [Integer]

Public Class Methods

encode(vorg) click to toggle source

Encode table.

@return [String]

# File lib/ttfunk/table/vorg.rb, line 31
def self.encode(vorg)
  return unless vorg

  ''.b.tap do |table|
    table << [
      vorg.major_version, vorg.minor_version,
      vorg.default_vert_origin_y, vorg.count,
    ].pack('n*')

    vorg.origins.each_pair do |glyph_id, vert_origin_y|
      table << [glyph_id, vert_origin_y].pack('n*')
    end
  end
end

Public Instance Methods

for(glyph_id) click to toggle source

Get vertical origina for glyph by ID.

@param glyph_id [Integer] @return [Integer]

# File lib/ttfunk/table/vorg.rb, line 50
def for(glyph_id)
  @origins.fetch(glyph_id, default_vert_origin_y)
end
origins() click to toggle source

Origins map.

@return [Hash{Integer => Integer}]

# File lib/ttfunk/table/vorg.rb, line 64
def origins
  @origins ||= {}
end
tag() click to toggle source

Table tag.

@return [String]

# File lib/ttfunk/table/vorg.rb, line 57
def tag
  TAG
end

Private Instance Methods

parse!() click to toggle source
# File lib/ttfunk/table/vorg.rb, line 70
def parse!
  @major_version, @minor_version = read(4, 'n*')
  @default_vert_origin_y = read_signed(1).first
  @count = read(2, 'n').first

  count.times do
    glyph_id = read(2, 'n').first
    origins[glyph_id] = read_signed(1).first
  end
end