Class: Prune::Fonts::Courier

Inherits:
BaseEn show all
Defined in:
lib/prune/fonts/en/courier.rb

Overview

Courier font.

Instance Attribute Summary

Attributes inherited from Base

#font_name

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseEn

#decode

Methods inherited from Base

bold?, #encoding, font_name, #font_sym, italic?, #name, #reference

Methods included from PObjects

pa, pd, ph, pl, pn, ps

Constructor Details

#initialize(document, options = {}) ⇒ Courier

Returns a new instance of Courier.



16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/prune/fonts/en/courier.rb', line 16

def initialize(document, options = {})
  super(document)
  self.name = self.class.key(options)
  if bold?(options) && italic?(options)
    self.base_font = pn("Courier-BoldOblique")
  elsif bold?(options)
    self.base_font = pn("Courier-Bold")
  elsif italic?(options)
    self.base_font = pn("Courier-Oblique")
  else
    self.base_font = pn(:Courier)
  end
end

Class Method Details

.key(options) ⇒ Object



8
9
10
11
12
13
# File 'lib/prune/fonts/en/courier.rb', line 8

def key(options)
  key = font_name
  key << "_bold" if bold?(options)
  key << "_italic" if italic?(options)
  PObjects.pn(key)
end

Instance Method Details

#width(string, font_size) ⇒ Object

Get width of the text.



31
32
33
# File 'lib/prune/fonts/en/courier.rb', line 31

def width(string, font_size)
  string.size * 600 * font_size / 1000
end