Commit 8e4a08bf9805de01e8ff0f80334bba2818f0ef78

Authored by ksz2k
Committed by GitHub
2 parents ffae9239 e9f5135c
Exists in master

Merge pull request #21 from Dreamersoul/master

added the ability to add custom font path
  1 +0.3.8
  2 +-----
  3 +
  4 +- added `LetterAvatar.font` config option.
  5 +
1 0.3.7 6 0.3.7
2 ----- 7 -----
3 8
@@ -78,6 +78,16 @@ LetterAvatar.setup do |config| @@ -78,6 +78,16 @@ LetterAvatar.setup do |config|
78 end 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 ## Usage 91 ## Usage
82 92
83 ```ruby 93 ```ruby
lib/letter_avatar/avatar.rb
@@ -67,7 +67,7 @@ module LetterAvatar @@ -67,7 +67,7 @@ module LetterAvatar
67 -size #{FULLSIZE}x#{FULLSIZE} 67 -size #{FULLSIZE}x#{FULLSIZE}
68 xc:#{to_rgb(identity.color)} 68 xc:#{to_rgb(identity.color)}
69 -pointsize #{LetterAvatar.pointsize} 69 -pointsize #{LetterAvatar.pointsize}
70 - -font #{FONT_FILENAME} 70 + -font #{LetterAvatar.font}
71 -weight #{LetterAvatar.weight} 71 -weight #{LetterAvatar.weight}
72 -fill '#{LetterAvatar.fill_color}' 72 -fill '#{LetterAvatar.fill_color}'
73 -gravity Center 73 -gravity Center
lib/letter_avatar/configuration.rb
@@ -8,6 +8,14 @@ module LetterAvatar @@ -8,6 +8,14 @@ module LetterAvatar
8 @cache_base_path = v 8 @cache_base_path = v
9 end 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 def fill_color 19 def fill_color
12 @fill_color || Avatar::FILL_COLOR 20 @fill_color || Avatar::FILL_COLOR
13 end 21 end
lib/letter_avatar/version.rb
1 module LetterAvatar 1 module LetterAvatar
2 - VERSION = '0.3.7' 2 + VERSION = '0.3.8'
3 end 3 end