Class: Pdfrb::Font::Metrics
- Inherits:
-
Struct
- Object
- Struct
- Pdfrb::Font::Metrics
- Defined in:
- lib/pdfrb/font/metrics_helper.rb
Overview
Metrics value object + lookup helper. Returns ascent/descent/ cap_height/x_height/line_gap/avg_width for any font (Standard 14 via AFM, embedded TTF/OTF via head/hhea/OS2 tables).
Instance Attribute Summary collapse
-
#ascent ⇒ Object
Returns the value of attribute ascent.
-
#avg_width ⇒ Object
Returns the value of attribute avg_width.
-
#bbox ⇒ Object
Returns the value of attribute bbox.
-
#cap_height ⇒ Object
Returns the value of attribute cap_height.
-
#descent ⇒ Object
Returns the value of attribute descent.
-
#font_name ⇒ Object
Returns the value of attribute font_name.
-
#italic_angle ⇒ Object
Returns the value of attribute italic_angle.
-
#line_gap ⇒ Object
Returns the value of attribute line_gap.
-
#max_width ⇒ Object
Returns the value of attribute max_width.
-
#stem_v ⇒ Object
Returns the value of attribute stem_v.
-
#units_per_em ⇒ Object
Returns the value of attribute units_per_em.
-
#x_height ⇒ Object
Returns the value of attribute x_height.
Instance Method Summary collapse
Instance Attribute Details
#ascent ⇒ Object
Returns the value of attribute ascent
8 9 10 |
# File 'lib/pdfrb/font/metrics_helper.rb', line 8 def ascent @ascent end |
#avg_width ⇒ Object
Returns the value of attribute avg_width
8 9 10 |
# File 'lib/pdfrb/font/metrics_helper.rb', line 8 def avg_width @avg_width end |
#bbox ⇒ Object
Returns the value of attribute bbox
8 9 10 |
# File 'lib/pdfrb/font/metrics_helper.rb', line 8 def bbox @bbox end |
#cap_height ⇒ Object
Returns the value of attribute cap_height
8 9 10 |
# File 'lib/pdfrb/font/metrics_helper.rb', line 8 def cap_height @cap_height end |
#descent ⇒ Object
Returns the value of attribute descent
8 9 10 |
# File 'lib/pdfrb/font/metrics_helper.rb', line 8 def descent @descent end |
#font_name ⇒ Object
Returns the value of attribute font_name
8 9 10 |
# File 'lib/pdfrb/font/metrics_helper.rb', line 8 def font_name @font_name end |
#italic_angle ⇒ Object
Returns the value of attribute italic_angle
8 9 10 |
# File 'lib/pdfrb/font/metrics_helper.rb', line 8 def italic_angle @italic_angle end |
#line_gap ⇒ Object
Returns the value of attribute line_gap
8 9 10 |
# File 'lib/pdfrb/font/metrics_helper.rb', line 8 def line_gap @line_gap end |
#max_width ⇒ Object
Returns the value of attribute max_width
8 9 10 |
# File 'lib/pdfrb/font/metrics_helper.rb', line 8 def max_width @max_width end |
#stem_v ⇒ Object
Returns the value of attribute stem_v
8 9 10 |
# File 'lib/pdfrb/font/metrics_helper.rb', line 8 def stem_v @stem_v end |
#units_per_em ⇒ Object
Returns the value of attribute units_per_em
8 9 10 |
# File 'lib/pdfrb/font/metrics_helper.rb', line 8 def units_per_em @units_per_em end |
#x_height ⇒ Object
Returns the value of attribute x_height
8 9 10 |
# File 'lib/pdfrb/font/metrics_helper.rb', line 8 def x_height @x_height end |
Instance Method Details
#ascender(font_size) ⇒ Object
17 18 19 |
# File 'lib/pdfrb/font/metrics_helper.rb', line 17 def ascender(font_size) (ascent || 800) * font_size.to_f / (units_per_em || 1000) end |
#descender(font_size) ⇒ Object
21 22 23 |
# File 'lib/pdfrb/font/metrics_helper.rb', line 21 def descender(font_size) (descent || -200) * font_size.to_f / (units_per_em || 1000) end |
#line_height(font_size) ⇒ Object
12 13 14 15 |
# File 'lib/pdfrb/font/metrics_helper.rb', line 12 def line_height(font_size) ((ascent || 800) - (descent || -200) + (line_gap || 0)) * font_size.to_f / (units_per_em || 1000) end |