Class: Hieroglyph::Font
- Inherits:
-
Object
- Object
- Hieroglyph::Font
- Defined in:
- lib/hieroglyph/font.rb
Instance Attribute Summary collapse
-
#character_sheet ⇒ Object
Returns the value of attribute character_sheet.
-
#characters ⇒ Object
Returns the value of attribute characters.
-
#contents ⇒ Object
Returns the value of attribute contents.
-
#options ⇒ Object
Returns the value of attribute options.
-
#output_path ⇒ Object
Returns the value of attribute output_path.
-
#unicode_values ⇒ Object
Returns the value of attribute unicode_values.
Instance Method Summary collapse
- #add(str) ⇒ Object
- #add_glyphs ⇒ Object
- #finish ⇒ Object
- #include(file) ⇒ Object
-
#initialize(options) ⇒ Font
constructor
A new instance of Font.
- #set_name ⇒ Object
- #setup ⇒ Object
Constructor Details
#initialize(options) ⇒ Font
Returns a new instance of Font.
7 8 9 10 11 12 13 14 15 16 |
# File 'lib/hieroglyph/font.rb', line 7 def initialize() @characters = [] @unicode_values = [] @contents = "" @options = @output_path = File.join(@options[:output_folder], @options[:name] + ".svg") setup add_glyphs finish end |
Instance Attribute Details
#character_sheet ⇒ Object
Returns the value of attribute character_sheet.
5 6 7 |
# File 'lib/hieroglyph/font.rb', line 5 def character_sheet @character_sheet end |
#characters ⇒ Object
Returns the value of attribute characters.
5 6 7 |
# File 'lib/hieroglyph/font.rb', line 5 def characters @characters end |
#contents ⇒ Object
Returns the value of attribute contents.
5 6 7 |
# File 'lib/hieroglyph/font.rb', line 5 def contents @contents end |
#options ⇒ Object
Returns the value of attribute options.
5 6 7 |
# File 'lib/hieroglyph/font.rb', line 5 def @options end |
#output_path ⇒ Object
Returns the value of attribute output_path.
5 6 7 |
# File 'lib/hieroglyph/font.rb', line 5 def output_path @output_path end |
#unicode_values ⇒ Object
Returns the value of attribute unicode_values.
5 6 7 |
# File 'lib/hieroglyph/font.rb', line 5 def unicode_values @unicode_values end |
Instance Method Details
#add(str) ⇒ Object
45 46 47 |
# File 'lib/hieroglyph/font.rb', line 45 def add(str) @contents << str end |
#add_glyphs ⇒ Object
49 50 51 52 53 54 55 56 |
# File 'lib/hieroglyph/font.rb', line 49 def add_glyphs Hieroglyph.header 'Reading glyphs:' Dir.glob(File.join(@options[:glyph_folder], '*.svg')).each do |file| glyph = Glyph.new(file, @options[:glyph_folder], self) @character_sheet.add file add glyph.to_node end end |
#finish ⇒ Object
34 35 36 37 38 39 40 41 42 43 |
# File 'lib/hieroglyph/font.rb', line 34 def finish include "footer" set_name File.open(@output_path, "w") do |file| file.puts @contents file.close end Hieroglyph.header 'Done!' @character_sheet.save end |
#include(file) ⇒ Object
18 19 20 21 |
# File 'lib/hieroglyph/font.rb', line 18 def include(file) path = File.join(File.dirname(__FILE__), "assets/#{file}") add File.open(path).read end |
#set_name ⇒ Object
30 31 32 |
# File 'lib/hieroglyph/font.rb', line 30 def set_name @contents.gsub!("{{NAME}}", @options[:name]) end |
#setup ⇒ Object
23 24 25 26 27 28 |
# File 'lib/hieroglyph/font.rb', line 23 def setup Hieroglyph.header 'Setup:' Hieroglyph.delete @output_path @character_sheet = Hieroglyph.imagemagick_installed? ? CharacterSheet.new(@options) : NoopSheet.new include 'header' end |