Class: TTFunk::Table::Vorg

Inherits:
TTFunk::Table show all
Defined in:
lib/ttfunk/table/vorg.rb

Overview

Vertical Origin (‘VORG`) table.

Constant Summary collapse

TAG =

Table tag.

'VORG'

Instance Attribute Summary collapse

Attributes inherited from TTFunk::Table

#file, #length, #offset

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from TTFunk::Table

#exists?, #initialize, #raw

Constructor Details

This class inherits a constructor from TTFunk::Table

Instance Attribute Details

#countInteger (readonly)

Number of vertical origin metrics.

Returns:

  • (Integer)


26
27
28
# File 'lib/ttfunk/table/vorg.rb', line 26

def count
  @count
end

#default_vert_origin_yInteger (readonly)

The default y coordinate of a glyph’s vertical origin.

Returns:

  • (Integer)


22
23
24
# File 'lib/ttfunk/table/vorg.rb', line 22

def default_vert_origin_y
  @default_vert_origin_y
end

#major_versionInteger (readonly)

Table major version.

Returns:

  • (Integer)


14
15
16
# File 'lib/ttfunk/table/vorg.rb', line 14

def major_version
  @major_version
end

#minor_versionInteger (readonly)

Table minor version.

Returns:

  • (Integer)


18
19
20
# File 'lib/ttfunk/table/vorg.rb', line 18

def minor_version
  @minor_version
end

Class Method Details

.encode(vorg) ⇒ String

Encode table.

Returns:

  • (String)


31
32
33
34
35
36
37
38
39
40
41
42
43
44
# 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

Instance Method Details

#for(glyph_id) ⇒ Integer

Get vertical origina for glyph by ID.

Parameters:

  • glyph_id (Integer)

Returns:

  • (Integer)


50
51
52
# File 'lib/ttfunk/table/vorg.rb', line 50

def for(glyph_id)
  @origins.fetch(glyph_id, default_vert_origin_y)
end

#originsHash{Integer => Integer}

Origins map.

Returns:

  • (Hash{Integer => Integer})


64
65
66
# File 'lib/ttfunk/table/vorg.rb', line 64

def origins
  @origins ||= {}
end

#tagString

Table tag.

Returns:

  • (String)


57
58
59
# File 'lib/ttfunk/table/vorg.rb', line 57

def tag
  TAG
end