In this article I will show you how to use a font that is not installed on the server by loading it at run time!
The obvious immediate use for this is where you are on shared hosting or any other occasion where you can't or don't want to bother your ISP/Server Admin.
This solution is administrator-free, you only need a font and FTP :O)
See it in action
http://authors.aspalliance.com/chrisg/tools/LoadFont.aspx
View Source
- http://authors.aspalliance.com/chrisg/tools/view-LoadFont.vb.aspx
- http://authors.aspalliance.com/chrisg/tools/view-LoadFont.aspx.aspx
The way it works is to create a PrivateFontCollection() from the System.Drawing.Text namespace. This enables us to create a collection of font families outside of the main user fonts.
To this collection we add our font file by pointing to the filesystem path of the .ttf (True Type Font).
After this is loaded we need to from then on use an instance of a font family only from this collection - the effect otherwise is the system selects a match for you so the font displayed would not be the one we loaded.
The remainder of the script deals with displaying the various combinations of style depending on if the style is available using IsStyleAvailable.
If you like the Lazy Dog font I have used it is available from http://www.neave.com/
Download
- http://authors.aspalliance.com/chrisg/tools/download.asp?file=LoadFont.aspx
- http://authors.aspalliance.com/chrisg/tools/download.asp?file=LoadFont.vb