Class: JotPDF::Document::FontManager
- Inherits:
-
Object
- Object
- JotPDF::Document::FontManager
- Defined in:
- lib/jot_pdf/document.rb
Instance Attribute Summary collapse
-
#default_font ⇒ Object
writeonly
Sets the attribute default_font.
Instance Method Summary collapse
-
#initialize(default_font:) ⇒ FontManager
constructor
A new instance of FontManager.
- #load_font(path) ⇒ Object
- #loaded_fonts ⇒ Object
- #require(spec = nil) ⇒ Object
Constructor Details
#initialize(default_font:) ⇒ FontManager
Returns a new instance of FontManager.
53 54 55 56 |
# File 'lib/jot_pdf/document.rb', line 53 def initialize(default_font:) @fonts = {} @default_font = default_font end |
Instance Attribute Details
#default_font=(value) ⇒ Object (writeonly)
Sets the attribute default_font
51 52 53 |
# File 'lib/jot_pdf/document.rb', line 51 def default_font=(value) @default_font = value end |
Instance Method Details
#load_font(path) ⇒ Object
58 59 60 61 62 |
# File 'lib/jot_pdf/document.rb', line 58 def load_font(path) font = TTFunk::File.open(path) name = font.name.postscript_name @fonts[name] = NonstandardFont.new(font) end |
#loaded_fonts ⇒ Object
73 74 75 |
# File 'lib/jot_pdf/document.rb', line 73 def loaded_fonts @fonts end |
#require(spec = nil) ⇒ Object
64 65 66 67 68 69 70 71 |
# File 'lib/jot_pdf/document.rb', line 64 def require(spec = nil) spec ||= @default_font if spec.is_a? Symbol @fonts[spec] ||= StandardFont.new(spec) else @fonts.fetch(spec) end end |