Commit e9f5135c0201ae3030e13ac5cdbbb182a33552c3

Authored by Hamad alghanim
1 parent da50df2f
Exists in master

feat(custom font path): added the ability to add a custom font path

CHANGELOG.md
  1 +0.3.8
  2 +-----
  3 +
  4 +- added `LetterAvatar.font` config option.
  5 +
1 6 0.3.7
2 7 -----
3 8  
... ...
README.md
... ... @@ -78,6 +78,16 @@ LetterAvatar.setup do |config|
78 78 end
79 79 ```
80 80  
  81 +##### Custom font definition
  82 +
  83 +You can define your own `custom` palette:
  84 +
  85 +```ruby
  86 +LetterAvatar.setup do |config|
  87 + config.font = File.join(File.expand_path('../../', File.dirname(__FILE__)), 'app/assets/fonts', 'font_name.ext')
  88 +end
  89 +```
  90 +
81 91 ## Usage
82 92  
83 93 ```ruby
... ...
lib/letter_avatar/avatar.rb
... ... @@ -67,7 +67,7 @@ module LetterAvatar
67 67 -size #{FULLSIZE}x#{FULLSIZE}
68 68 xc:#{to_rgb(identity.color)}
69 69 -pointsize #{LetterAvatar.pointsize}
70   - -font #{FONT_FILENAME}
  70 + -font #{LetterAvatar.font}
71 71 -weight #{LetterAvatar.weight}
72 72 -fill '#{LetterAvatar.fill_color}'
73 73 -gravity Center
... ...
lib/letter_avatar/configuration.rb
... ... @@ -8,6 +8,14 @@ module LetterAvatar
8 8 @cache_base_path = v
9 9 end
10 10  
  11 + def font
  12 + @font || Avatar::FONT_FILENAME
  13 + end
  14 +
  15 + def font=(v)
  16 + @font = v
  17 + end
  18 +
11 19 def fill_color
12 20 @fill_color || Avatar::FILL_COLOR
13 21 end
... ...
lib/letter_avatar/version.rb
1 1 module LetterAvatar
2   - VERSION = '0.3.7'
  2 + VERSION = '0.3.8'
3 3 end
... ...