Class: TTFunk::Table::Glyf::PathBased

Inherits:
Object
  • Object
show all
Defined in:
lib/ttfunk/table/glyf/path_based.rb

Overview

TrueType-compatible representation of a CFF glyph.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path, horizontal_metrics) ⇒ PathBased

Returns a new instance of PathBased.

Parameters:

Source Code
lib/ttfunk/table/glyf/path_based.rb, line 42
42
def initialize(path, horizontal_metrics)
43
  @path = path
44
  @horizontal_metrics = horizontal_metrics
45
46
  @x_min = 0
47
  @y_min = 0
48
  @x_max = horizontal_metrics.advance_width
49
  @y_max = 0
50
51
  path.commands.each do |command|
52
    cmd, x, y = command
53
    next if cmd == :close
54
55
    @x_min = x if x < @x_min
56
    @x_max = x if x > @x_max
57
    @y_min = y if y < @y_min
58
    @y_max = y if y > @y_max
59
  end
60
61
  @left_side_bearing = horizontal_metrics.left_side_bearing
62
  @right_side_bearing =
63
    horizontal_metrics.advance_width -
64
    @left_side_bearing -
65
    (@x_max - @x_min)
66
end

Instance Attribute Details

#horizontal_metricsTTFunk::Table::Hmtx::HorizontalMetric (readonly)

Glyph horizontal metrics.

Source Code
lib/ttfunk/table/glyf/path_based.rb, line 14
14
def horizontal_metrics
15
  @horizontal_metrics
16
end

#left_side_bearingInteger, Float (readonly)

Left side bearing.

Returns:

  • (Integer, Float)
Source Code
lib/ttfunk/table/glyf/path_based.rb, line 34
34
def left_side_bearing
35
  @left_side_bearing
36
end

#pathTTFunk::Table::Cff::Path (readonly)

Glyph outline.

Source Code
lib/ttfunk/table/glyf/path_based.rb, line 10
10
def path
11
  @path
12
end

#right_side_bearingInteger, Float (readonly)

Rigth side bearing.

Returns:

  • (Integer, Float)
Source Code
lib/ttfunk/table/glyf/path_based.rb, line 38
38
def right_side_bearing
39
  @right_side_bearing
40
end

#x_maxInteger, Float (readonly)

Maximum X.

Returns:

  • (Integer, Float)
Source Code
lib/ttfunk/table/glyf/path_based.rb, line 26
26
def x_max
27
  @x_max
28
end

#x_minInteger, Float (readonly)

Minimum X.

Returns:

  • (Integer, Float)
Source Code
lib/ttfunk/table/glyf/path_based.rb, line 18
18
def x_min
19
  @x_min
20
end

#y_maxInteger, Float (readonly)

Maximum Y.

Returns:

  • (Integer, Float)
Source Code
lib/ttfunk/table/glyf/path_based.rb, line 30
30
def y_max
31
  @y_max
32
end

#y_minInteger, Float (readonly)

Minimum Y.

Returns:

  • (Integer, Float)
Source Code
lib/ttfunk/table/glyf/path_based.rb, line 22
22
def y_min
23
  @y_min
24
end

Instance Method Details

#compound?false

Is this glyph compound?

Returns:

  • (false)
Source Code
lib/ttfunk/table/glyf/path_based.rb, line 78
78
def compound?
79
  false
80
end

#number_of_contoursInteger

Number of contour.

Returns:

  • (Integer)
Source Code
lib/ttfunk/table/glyf/path_based.rb, line 71
71
def number_of_contours
72
  path.number_of_contours
73
end