Saucy – use any font on your website
Fonts can be a developer’s nightmare if they’re not one of the ones installed on the user’s machine. There are alternatives such as sIFR and typeface.js but they’re quite resource intensive – we had to remove sIFR for that reason.
What some people end up doing is using images, cutting them up manually; quite a time intensive way of doing things. Saucy is Rails plugin developed by Jonah Fox to generate the text server side, using RMagick, so you can use any font you want.
<%= saucy_tag "h2 tag",
:style => {
:font => { :size => 100, :font => "bauhausl.ttf" }
},
:tag => :h2,
:html => {:id => "myid"} %>

I’ve recently been extending Saucy to support Sprites, so you can do rollover images easily. It’s as simple as this:
<%= saucy_tag("I am a red/blue sprite",
:style => {:font => {:color => 'red'}},
:hover => {:font => {:color => 'blue'}}
) %>
You can get Saucy here until Jonah merges the changes.
Next up is rounded corners (don’t even mention drop shadows) ;)
See also:
- No similar posts
About the author
-
Comments (6)
-
Responses (0)
That’s a pretty cool plugin. I got to try it out soon … I had so horrible nights debugging sifr headlines … Seemingly better times are coming … ;-)
peterlih
December 5, 2008
at 10:47 am
You guys are plugin ma-chines! Thanks!
Daniel
December 12, 2008
at 10:28 am
This is great! I just finally got it working. It should be worth nothing that you need to add the ‘deep_merge’ function to the Hash object for this to work correctly. It should also be noted that the deep_merge gem does not work. I just took the code from here :
http://snippets.dzone.com/posts/show/4706
Added it to a file in lib and the required it in environment.rb.
Thanks!
Jeremy
December 19, 2008
at 6:30 am
Jeremy,
deep_merge is in the latest version of activesupport (2.2.2), you must be using an old version?
alex
December 19, 2008
at 7:49 am
saucy_to_remote ?
ben
February 16, 2009
at 10:55 pm
unable to read font `”{bla…bla…}/vendor/plugins/saucy/lib/saucy/../../fonts/AVENIR02.TTF”‘
it’s working sometimes, not on the server nor my job computer; might be some files rights, but i just can’t find how to get over it.
thanks a lot for any infos.
ben
March 9, 2009
at 10:29 am