Class: Clef::Engraving::FontManager

Inherits:
Object
  • Object
show all
Defined in:
lib/clef/engraving/font_manager.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(font_path: default_font_path) ⇒ FontManager

Returns a new instance of FontManager.

Parameters:

  • font_path (String) (defaults to: default_font_path)


9
10
11
# File 'lib/clef/engraving/font_manager.rb', line 9

def initialize(font_path: default_font_path)
  @font_path = font_path
end

Instance Attribute Details

#font_pathObject (readonly)

Returns the value of attribute font_path.



6
7
8
# File 'lib/clef/engraving/font_manager.rb', line 6

def font_path
  @font_path
end

Instance Method Details

#font_available?Boolean

Returns:

  • (Boolean)


14
15
16
# File 'lib/clef/engraving/font_manager.rb', line 14

def font_available?
  File.exist?(font_path)
end

#register_with(pdf, family_name: "Bravura") ⇒ String

Parameters:

  • pdf (Prawn::Document)
  • family_name (String) (defaults to: "Bravura")

Returns:

  • (String)


21
22
23
24
25
26
# File 'lib/clef/engraving/font_manager.rb', line 21

def register_with(pdf, family_name: "Bravura")
  return "Helvetica" unless font_available?

  pdf.font_families.update(family_name => {normal: font_path})
  family_name
end