Git Product home page Git Product logo

webfontloader's Introduction

WebFont Loader

WebFont Loader gives you added control when using linked fonts via @font-face. It provides a common interface to loading fonts regardless of the source, then adds a standard set of events you may use to control the loading experience.

Get Started

(These samples use WebFont Loader hosted on Google's AJAX Libraries.)

Link to the WebFont Loader library, then tell it which fonts to load. Here we'll load fonts from Google's Font API.

<script src="http://ajax.googleapis.com/ajax/libs/webfont/1/webfont.js"></script>
<script>
  WebFont.load({
    google: {
      families: ['Droid Sans', 'Droid Serif']
    }
  });
</script>

Alternatively, load fonts from Typekit. Just specify your Kit ID.

<script src="http://ajax.googleapis.com/ajax/libs/webfont/1/webfont.js"></script>
<script>
  WebFont.load({
    typekit: {
      id: 'xxxxxx'
    }
  });
</script>

Learn more about the modules.

Do More

WebFont Loader gives you control over how fonts are loaded. If you're frustrated by the "flash of unstyled text" typically seen in FireFox, try this.

<script src="http://ajax.googleapis.com/ajax/libs/webfont/1/webfont.js"></script>
<script>
  WebFont.load({
    google: {
      families: ['Droid Sans']
    }
  });
</script>
<style>
  h1 {
    font-family: 'Droid Sans';
    visibility: hidden;
  }
  .wf-active h1 {
    visibility: visible;
  }
</style>

<body>
  <h1>This headline will be hidden until Droid Sans is completely loaded.</h1>
</body>

Learn more about events.

A common ground

WebFont Loader aims to provide a common interface for font loading. Today it works with Google, Typekit, and your own CSS. Learn more in transitions.

More to see

A full suite of demo pages is included in this source. Here you can find some live examples using the JS and CSS events.

To view the demos, just boot up our demo server and start browsing.

$ rake demo

You may need a few rubygems to run the server. Get them with Bundler.

$ gem install bundler
$ bundle install

Browse the demos source code.

Problems?

Please open an issue. Sample pages are greatly appreciated.

Developing

Is there something else WebFont Loader should do? Did you find a bug and want to fix it?

Testing

WebFont Loader has an extensive test suite that runs via jsTestDriver. Please add tests for any changes.

To run tests, first boot the test server. This open a browser and start listing for test executions. You can register multiple browsers.

rake test:boot

Then, run the tests.

rake test

Contributing

  • Fork webfontloader
  • Create a topic branch - git checkout -b my_branch
  • Push to your branch - git push origin my_branch
  • Create an issue with a link to your branch
  • That's it!

Authors

License

WebFont Loader is released under the Apache 2.0 license.

webfontloader's People

Contributors

jeremiele avatar paulirish avatar tootallnate avatar

Stargazers

 avatar

Watchers

 avatar James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.