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) ;)

6 comments

Author: peterlih peterlih

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 … ;-)

Author: Daniel Daniel

You guys are plugin ma-chines! Thanks!

Author: Jeremy Jeremy

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

http://snippets.dzone.com/posts/show/4706

Added it to a file in lib and the required it in environment.rb.


Thanks!

Author: alex alex

Jeremy,
deep_merge is in the latest version of activesupport (2.2.2), you must be using an old version?


Author: ben ben

saucy_to_remote ?

Author: ben ben

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.