Click here to Skip to main content
15,881,882 members
Articles / Web Development / ASP.NET

Using custom fonts with dynamic headings

Rate me:
Please Sign up or sign in to vote.
3.33/5 (9 votes)
16 Sep 2007LGPL37 min read 58.9K   755   17  
Use this control to create dynamic headings on your webpages so you can use custom fonts without needing a designer everytime you want to change a heading!
<?xml version="1.0"?>
<configuration>
	<configSections>
		<section name="dynamicHeadings"	type="TrunkMedia.DynamicHeadings.Configuration.DynamicHeadingsConfig,TrunkMedia.DynamicHeadings" />
	</configSections>
	<dynamicHeadings>
		<fonts>
			<!-- Font locations can be outside of the webroot, in fact his is recommended to protected copyright on the item-->
			<font name="MADFONT" location="C:\Projects\Articles\DynamicHeadings\TrunkMedia.DynamicHeadings.Example\font\MADFONT_.ttf" />
			<!-- All of these fonts are copyrighted and were downloaded from http://www.1001freefonts.com/ -->
			<font name="Calaveras" location="C:\Projects\Articles\DynamicHeadings\TrunkMedia.DynamicHeadings.Example\font\CALAVERA.ttf" />
			<!-- The font name must be exactly as show in a font viewer (not the fonts file name) -->
			<font name="Xerox Malfunction (BRK)" location="C:\Projects\Articles\DynamicHeadings\TrunkMedia.DynamicHeadings.Example\font\xeroxmal.ttf" />
			<font name="My Pager" location="C:\Projects\Articles\DynamicHeadings\TrunkMedia.DynamicHeadings.Example\font\mypager.ttf" />
		</fonts>
		<styles>
			<!-- Colors can be HTML colours if you use preceed the colour with # otherwise you can use standard windows colour names-->
			<style name="skulls" 
				foreColor="#FF0000" 
				backgroundColor="Transparent" 
				fontName="Calaveras"
				fontSize="36px"
				/>
			<!-- Padding is done the same as css: TOP BOTTOM RIGHT LEFT. It can also be done TOP&BOTTOM RIGHT&LEFT-->
			<style name="madness" 
				foreColor="#FF00FF" 
				backgroundColor="#00FF00" 
				padding="0 10"
				fontName="MADFONT"
				fontSize="20px"
				/>
			<!-- You can change the font style to Italics or Bold. The default is regular.-->
			<style name="xerox" 
				foreColor="Black" 
				backgroundColor="Pink" 
				padding="0 20 0 10"
				fontName="Xerox Malfunction (BRK)" 
				fontSize="48"
				fontStyle="Italic"/>
			<!-- All font sizes are in pixels and you do not need the px suffix. You cannot currently use anything else like EM (it won't work and you'll get the default font size)-->
			<style name="digital" 
				foreColor="Lime" 
				backgroundColor="Black" 
				padding="0 0" 
				fontName="My Pager" 
				fontSize="30"
				fontStyle="Regular" />
		</styles>
	</dynamicHeadings>
	<system.web> 
		<httpHandlers> 
			<add verb="GET, POST" path="images/headers/*/*.aspx"		type="TrunkMedia.DynamicHeadings.Handlers.DynamicHeading, TrunkMedia.DynamicHeadings" validate="false" />
		</httpHandlers>
		<compilation debug="false" />
		<authentication mode="None"  />
    </system.web>
</configuration>

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The GNU Lesser General Public License (LGPLv3)


Written By
Web Developer
New Zealand New Zealand
I'm currently technical director at Trunk Media, an Auckland,New Zealand based interactive web agency specialising in accessible and usable web development. I've had several years experience working in London,England working for a top web agency whose clients included several FTSE 100 companies. I've been developing websites for over 8 years now and have a broad range of skills I'm constantly trying to improve.

When I'm not flat out at work I'll be cross country mountain biking, trying to snowboard, swimming in the surf or fiddling with an old car or two.

Comments and Discussions