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)
Source Code
lib/ttfunk/table/vorg.rb, line 26
26
def count
27
  @count
28
end

#default_vert_origin_yInteger (readonly)

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

Returns:

  • (Integer)
Source Code
lib/ttfunk/table/vorg.rb, line 22
22
def default_vert_origin_y
23
  @default_vert_origin_y
24
end

#major_versionInteger (readonly)

Table major version.

Returns:

  • (Integer)
Source Code
lib/ttfunk/table/vorg.rb, line 14
14
def major_version
15
  @major_version
16
end

#minor_versionInteger (readonly)

Table minor version.

Returns:

  • (Integer)
Source Code
lib/ttfunk/table/vorg.rb, line 18
18
def minor_version
19
  @minor_version
20
end

Class Method Details

.encode(vorg) ⇒ String

Encode table.

Returns:

  • (String)
Source Code
lib/ttfunk/table/vorg.rb, line 31
31
def self.encode(vorg)
32
  return unless vorg
33
34
  ''.b.tap do |table|
35
    table << [
36
      vorg.major_version, vorg.minor_version,
37
      vorg.default_vert_origin_y, vorg.count,
38
    ].pack('n*')
39
40
    vorg.origins.each_pair do |glyph_id, vert_origin_y|
41
      table << [glyph_id, vert_origin_y].pack('n*')
42
    end
43
  end
44
end

Instance Method Details

#for(glyph_id) ⇒ Integer

Get vertical origina for glyph by ID.

Parameters:

  • glyph_id (Integer)

Returns:

  • (Integer)
Source Code
lib/ttfunk/table/vorg.rb, line 50
50
def for(glyph_id)
51
  @origins.fetch(glyph_id, default_vert_origin_y)
52
end

#originsHash{Integer => Integer}

Origins map.

Returns:

  • (Hash{Integer => Integer})
Source Code
lib/ttfunk/table/vorg.rb, line 64
64
def origins
65
  @origins ||= {}
66
end

#tagString

Table tag.

Returns:

  • (String)
Source Code
lib/ttfunk/table/vorg.rb, line 57
57
def tag
58
  TAG
59
end