Skip to content

Commit

Permalink
feat(custom font path): added the ability to add a custom font path
Browse files Browse the repository at this point in the history
  • Loading branch information
Dreamersoul committed Apr 3, 2020
1 parent da50df2 commit e9f5135
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 2 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
0.3.8
-----

- added `LetterAvatar.font` config option.

0.3.7
-----

Expand Down
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,16 @@ LetterAvatar.setup do |config|
end
```

##### Custom font definition

You can define your own `custom` palette:

```ruby
LetterAvatar.setup do |config|
config.font = File.join(File.expand_path('../../', File.dirname(__FILE__)), 'app/assets/fonts', 'font_name.ext')
end
```

## Usage

```ruby
Expand Down
2 changes: 1 addition & 1 deletion lib/letter_avatar/avatar.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def generate_fullsize(identity)
-size #{FULLSIZE}x#{FULLSIZE}
xc:#{to_rgb(identity.color)}
-pointsize #{LetterAvatar.pointsize}
-font #{FONT_FILENAME}
-font #{LetterAvatar.font}
-weight #{LetterAvatar.weight}
-fill '#{LetterAvatar.fill_color}'
-gravity Center
Expand Down
8 changes: 8 additions & 0 deletions lib/letter_avatar/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,14 @@ def cache_base_path=(v)
@cache_base_path = v
end

def font
@font || Avatar::FONT_FILENAME
end

def font=(v)
@font = v
end

def fill_color
@fill_color || Avatar::FILL_COLOR
end
Expand Down
2 changes: 1 addition & 1 deletion lib/letter_avatar/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module LetterAvatar
VERSION = '0.3.7'
VERSION = '0.3.8'
end

0 comments on commit e9f5135

Please sign in to comment.