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.
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_metrics ⇒ TTFunk::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_bearing ⇒ Integer, Float (readonly)
Left side bearing.
Source Code
lib/ttfunk/table/glyf/path_based.rb, line 34
34 | def left_side_bearing |
35 | @left_side_bearing
|
36 | end
|
#path ⇒ TTFunk::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_bearing ⇒ Integer, Float (readonly)
Rigth side bearing.
Source Code
lib/ttfunk/table/glyf/path_based.rb, line 38
38 | def right_side_bearing |
39 | @right_side_bearing
|
40 | end
|
#x_max ⇒ Integer, Float (readonly)
Maximum X.
Source Code
lib/ttfunk/table/glyf/path_based.rb, line 26
26 | def x_max |
27 | @x_max
|
28 | end
|
#x_min ⇒ Integer, Float (readonly)
Minimum X.
Source Code
lib/ttfunk/table/glyf/path_based.rb, line 18
18 | def x_min |
19 | @x_min
|
20 | end
|
#y_max ⇒ Integer, Float (readonly)
Maximum Y.
Source Code
lib/ttfunk/table/glyf/path_based.rb, line 30
30 | def y_max |
31 | @y_max
|
32 | end
|
#y_min ⇒ Integer, Float (readonly)
Minimum Y.
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?
Source Code
lib/ttfunk/table/glyf/path_based.rb, line 78
78 | def compound? |
79 | false
|
80 | end
|
#number_of_contours ⇒ Integer
Number of contour.
Source Code
lib/ttfunk/table/glyf/path_based.rb, line 71
71 | def number_of_contours |
72 | path.number_of_contours |
73 | end
|