Class: TTFunk::Table::Glyf::PathBased
- Inherits:
-
Object
- Object
- TTFunk::Table::Glyf::PathBased
- Defined in:
- lib/ttfunk/table/glyf/path_based.rb
Overview
TrueType-compatible representation of a CFF glyph.
Instance Attribute Summary collapse
-
#horizontal_metrics ⇒ TTFunk::Table::Hmtx::HorizontalMetric
readonly
Glyph horizontal metrics.
-
#left_side_bearing ⇒ Integer, Float
readonly
Left side bearing.
-
#path ⇒ TTFunk::Table::Cff::Path
readonly
Glyph outline.
-
#right_side_bearing ⇒ Integer, Float
readonly
Rigth side bearing.
-
#x_max ⇒ Integer, Float
readonly
Maximum X.
-
#x_min ⇒ Integer, Float
readonly
Minimum X.
-
#y_max ⇒ Integer, Float
readonly
Maximum Y.
-
#y_min ⇒ Integer, Float
readonly
Minimum Y.
Instance Method Summary collapse
-
#compound? ⇒ false
Is this glyph compound?.
-
#initialize(path, horizontal_metrics) ⇒ PathBased
constructor
A new instance of PathBased.
-
#number_of_contours ⇒ Integer
Number of contour.
Constructor Details
#initialize(path, horizontal_metrics) ⇒ PathBased
Returns a new instance of PathBased.
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/ttfunk/table/glyf/path_based.rb', line 42 def initialize(path, horizontal_metrics) @path = path @horizontal_metrics = horizontal_metrics @x_min = 0 @y_min = 0 @x_max = horizontal_metrics.advance_width @y_max = 0 path.commands.each do |command| cmd, x, y = command next if cmd == :close @x_min = x if x < @x_min @x_max = x if x > @x_max @y_min = y if y < @y_min @y_max = y if y > @y_max end @left_side_bearing = horizontal_metrics.left_side_bearing @right_side_bearing = horizontal_metrics.advance_width - @left_side_bearing - (@x_max - @x_min) end |
Instance Attribute Details
#horizontal_metrics ⇒ TTFunk::Table::Hmtx::HorizontalMetric (readonly)
Glyph horizontal metrics.
14 15 16 |
# File 'lib/ttfunk/table/glyf/path_based.rb', line 14 def horizontal_metrics @horizontal_metrics end |
#left_side_bearing ⇒ Integer, Float (readonly)
Left side bearing.
34 35 36 |
# File 'lib/ttfunk/table/glyf/path_based.rb', line 34 def left_side_bearing @left_side_bearing end |
#path ⇒ TTFunk::Table::Cff::Path (readonly)
Glyph outline.
10 11 12 |
# File 'lib/ttfunk/table/glyf/path_based.rb', line 10 def path @path end |
#right_side_bearing ⇒ Integer, Float (readonly)
Rigth side bearing.
38 39 40 |
# File 'lib/ttfunk/table/glyf/path_based.rb', line 38 def right_side_bearing @right_side_bearing end |
#x_max ⇒ Integer, Float (readonly)
Maximum X.
26 27 28 |
# File 'lib/ttfunk/table/glyf/path_based.rb', line 26 def x_max @x_max end |
#x_min ⇒ Integer, Float (readonly)
Minimum X.
18 19 20 |
# File 'lib/ttfunk/table/glyf/path_based.rb', line 18 def x_min @x_min end |
#y_max ⇒ Integer, Float (readonly)
Maximum Y.
30 31 32 |
# File 'lib/ttfunk/table/glyf/path_based.rb', line 30 def y_max @y_max end |
#y_min ⇒ Integer, Float (readonly)
Minimum Y.
22 23 24 |
# File 'lib/ttfunk/table/glyf/path_based.rb', line 22 def y_min @y_min end |
Instance Method Details
#compound? ⇒ false
Is this glyph compound?
78 79 80 |
# File 'lib/ttfunk/table/glyf/path_based.rb', line 78 def compound? false end |
#number_of_contours ⇒ Integer
Number of contour.
71 72 73 |
# File 'lib/ttfunk/table/glyf/path_based.rb', line 71 def number_of_contours path.number_of_contours end |