Class: Prawn::Font::Metrics
- Inherits:
-
Object
- Object
- Prawn::Font::Metrics
- Includes:
- Wrapping
- Defined in:
- lib/prawn/font/metrics.rb
Overview
:nodoc:
Defined Under Namespace
Class Method Summary collapse
Instance Method Summary collapse
Methods included from Wrapping
Class Method Details
.[](font) ⇒ Object
20 21 22 |
# File 'lib/prawn/font/metrics.rb', line 20 def self.[](font) data[font] ||= (font.match(/\.ttf$/i) ? TTF : Adobe).new(font) end |
.data ⇒ Object
24 25 26 |
# File 'lib/prawn/font/metrics.rb', line 24 def self.data @data ||= {} end |
Instance Method Details
#font_height(size) ⇒ Object
33 34 35 |
# File 'lib/prawn/font/metrics.rb', line 33 def font_height(size) (ascender - descender + line_gap) * size / 1000.0 end |
#string_height(string, options = {}) ⇒ Object
28 29 30 31 |
# File 'lib/prawn/font/metrics.rb', line 28 def string_height(string,={}) string = naive_wrap(string, [:line_width], [:font_size]) string.lines.to_a.length * font_height([:font_size]) end |