spriteFont: Use a Sprite-sheet as a Font
Due to "Imaginary Property" issues, fonts aren't allowed to be included in website templates. This makes it very frustrating to use non web-safe fonts for headlines, since every single title has to be saved as a separate image.
This script will use all the characters of a font, rendered as an image and paste together any given title.
Impact Font Example
The font in the title above was created using the generator below. It does not have to be installed on the end-user's computer. The individual characters in the title were rendered as images, cut from a single master image; a sprite-sheet. This sprite-sheet was generated, with the tool below, on a computer with the required font installed.
Helvética
Above the font "Helvetica" is used to the same effect. The "matrix" and "tweaks" parameters in the hidden form element is used to set the kerning of the image elements and fine-tune the font.
Stone Sans ITC Semi Font Example
Stone Sans ITC Semi Font Example
This example shows the same font twice, but the second spritesheet had photoshop filters applied to it and reacts to mouse interaction.
The method even works on menus.
Generating Sprite Map
The tool below positions and measures all the characters of a font. The generated map can be screen-grabbed and used as a spritesheet.
Required Files
-
jQuery Addon Script: jquery.classbehaviours.spritefont.js
- Prerequisite Script: jquery.classbehaviours.js
- Example Markup: spriteFont.html
- Example Stylesheet: spriteFont.css
- Example Image: spriteFont_impact.png
- Example Image: spriteFont_helvetica.png
- Example Image: spriteFont_stonesans.png
- Example Image: spriteFont_stonesans2.png
- Example Image: spriteFont_stonesans3.png
Comments on this Article