
Security News
The Changelog Podcast: Practical Steps to Stay Safe on npm
Learn the essential steps every developer should take to stay secure on npm and reduce exposure to supply chain attacks.
Provides a helper for using Google Webfonts with the Ruby programming language.
Add this line to your application's Gemfile:
gem 'google-webfonts'
And then execute:
$ bundle
Or install it yourself as:
$ gem install google-webfonts
include Google::Webfonts::Helper
google_webfonts_link_tag font_name: [weights]
google_webfonts_link_tag droid_sans: [400, 700], yanone_kaffeesatz: [300, 400]
The weights are optional, and do not have to be in an Array if you are only including one. For example:
# Generate a tag for Droid+Sans without specifying the font weight.
google_webfonts_link_tag :droid_sans
# Generate a tag for Droid+Sans with 400 weight.
google_webfonts_link_tag :droid_sans => 400
# Generate a tag for Droid+Sans with 400 and 700 weights.
google_webfonts_link_tag :droid_sans => [400, 700]
In certain cases it will be necessary to use Strings instead of Symbols for the font names. The helper method titleizes the symbols when converting it to a Google Webfonts compatible name. This does not work for every font name. For example:
# If a Symbol was provided here, the "T" would be lower-case, which would
# result in an invalid link.
google_webfonts_link_tag 'PT Sans'
Require the gem like this in your Gemfile when using with Rails:
gem 'google-webfonts', require: 'google/webfonts/rails'
The google_webfonts_link_tag helper method will automatically be available
to your views. If you need to use it outside of the views, include this module:
include Google::Webfonts::Helper
Here is a simple "Hello World" example for using Google::Webfonts in a Sinatra app:
# app.rb
require 'rubygems'
require 'sinatra'
# This must be required after requiring sinatra.
require 'google/webfonts/sinatra'
get '/' do
erb :index
end
# views/index.erb
<html>
<head>
<%= google_webfonts_link_tag "Droid Sans" %>
</head>
<body>
<p style="font-family: 'Droid+Sans', sans-serif;">
Hello World!
</p>
</body>
</html>
After checking out the repo, run bin/setup to install dependencies. Then,
run rake test to run the tests. You can also run bin/console for an
interactive prompt that will allow you to experiment.
To install this gem onto your local machine, run bundle exec rake install.
Bug reports and pull requests are welcome on GitHub at https://github.com/hi5dev/google-webfonts.
FAQs
Unknown package
We found that google-webfonts demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Learn the essential steps every developer should take to stay secure on npm and reduce exposure to supply chain attacks.

Security News
Experts push back on new claims about AI-driven ransomware, warning that hype and sponsored research are distorting how the threat is understood.

Security News
Ruby's creator Matz assumes control of RubyGems and Bundler repositories while former maintainers agree to step back and transfer all rights to end the dispute.