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
18 19 20 |
# File 'lib/prawn/font/metrics.rb', line 18 def self.[](font) data[font] ||= (font.match(/\.ttf$/i) ? TTF : Adobe).new(font) end |
.data ⇒ Object
22 23 24 |
# File 'lib/prawn/font/metrics.rb', line 22 def self.data @data ||= {} end |
Instance Method Details
#font_height(size) ⇒ Object
40 41 42 |
# File 'lib/prawn/font/metrics.rb', line 40 def font_height(size) (ascender - descender + line_gap) * size / 1000.0 end |
#string_height(string, options = {}) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/prawn/font/metrics.rb', line 26 def string_height(string,={}) Prawn. [:font_size, :spacing, :line_width], do unless [:line_width] raise ArgumentError, ":line_width must be specified." end end line_count = string.lines.to_a.length spacing = ([:spacing] || 0) * line_count string = naive_wrap(string, [:line_width], [:font_size]) line_count * font_height([:font_size]) + spacing end |