Class: Pdfrb::Font::Type1::FontMetrics
- Inherits:
-
Object
- Object
- Pdfrb::Font::Type1::FontMetrics
- Defined in:
- lib/pdfrb/font/type1/font_metrics.rb
Overview
Type1 font metrics wrapper. Delegates to AFMParser for the 14 standard fonts; provides glyph-width lookup.
Instance Attribute Summary collapse
-
#font_name ⇒ Object
readonly
Returns the value of attribute font_name.
-
#metrics ⇒ Object
readonly
Returns the value of attribute metrics.
Class Method Summary collapse
Instance Method Summary collapse
- #ascender ⇒ Object
- #bbox ⇒ Object
- #cap_height ⇒ Object
- #descender ⇒ Object
-
#initialize(font_name, metrics) ⇒ FontMetrics
constructor
A new instance of FontMetrics.
- #width_for(glyph_name) ⇒ Object
Constructor Details
#initialize(font_name, metrics) ⇒ FontMetrics
Returns a new instance of FontMetrics.
11 12 13 14 |
# File 'lib/pdfrb/font/type1/font_metrics.rb', line 11 def initialize(font_name, metrics) @font_name = font_name @metrics = metrics end |
Instance Attribute Details
#font_name ⇒ Object (readonly)
Returns the value of attribute font_name.
9 10 11 |
# File 'lib/pdfrb/font/type1/font_metrics.rb', line 9 def font_name @font_name end |
#metrics ⇒ Object (readonly)
Returns the value of attribute metrics.
9 10 11 |
# File 'lib/pdfrb/font/type1/font_metrics.rb', line 9 def metrics @metrics end |
Class Method Details
.for_standard_font(name) ⇒ Object
16 17 18 19 20 21 22 |
# File 'lib/pdfrb/font/type1/font_metrics.rb', line 16 def self.for_standard_font(name) afm_path = File.join(Pdfrb::DataDir.root, "afm", "#{name}.afm") return nil unless File.exist?(afm_path) metrics = AFMParser.from_file(afm_path) new(name, metrics) end |
Instance Method Details
#ascender ⇒ Object
32 33 34 |
# File 'lib/pdfrb/font/type1/font_metrics.rb', line 32 def ascender @metrics.ascender end |
#bbox ⇒ Object
28 29 30 |
# File 'lib/pdfrb/font/type1/font_metrics.rb', line 28 def bbox @metrics.bbox end |
#cap_height ⇒ Object
40 41 42 |
# File 'lib/pdfrb/font/type1/font_metrics.rb', line 40 def cap_height @metrics.cap_height end |
#descender ⇒ Object
36 37 38 |
# File 'lib/pdfrb/font/type1/font_metrics.rb', line 36 def descender @metrics.descender end |
#width_for(glyph_name) ⇒ Object
24 25 26 |
# File 'lib/pdfrb/font/type1/font_metrics.rb', line 24 def width_for(glyph_name) @metrics.width_for(glyph_name) end |