Font Embedding In Silverlight 3 Application

No.of Views850
Bookmarked0 times
Downloads 
Votes0
By  dpatra   On  16 Feb 2010 00:02:01
Tag : Silver Light and XAML , How to
Font Embedding In Silverlight 3 Application
emailbookmarkadd commentsprint

Images in this article missing? We recently lost them in a site migration. We're working to restore these as you read this. Should you need an image in an emergency, please contact us at info@codegain.com

 Introduction
If you want to use non-standard fonts in your application, you can embed them in your application assembly. That way, your application never has a problem finding the font you want to use. In this article we will see all how we can make this happen.

Crating Silverlight Project
Fire up Visual Studio 2008 and create a Silverlight Application. Name it as FontEmbeddingInSL3.


Image Loading...

As you know a Silverlight application always runs in client machine, so based on the client machine settings it will run. If you have installed a font in your machine and used the same font in your application then while running the application in client’s machine the font will not be the same you have used. To make that, we need to embed the font in our Silverlight application.
To begin with, we will add a font to our Silverlight application. Create a folder named “Assets” and keep the font file (with extension *.ttf) inside it.

Image Loading...

Now set the Build action to BlendEmbeddedFont.

Image Laoding....

Now go ahead and add a TextBlock into your application.



{codecitation class="brush: xml; gutter: true;" width="650px"}

<TextBlock Height="40" FontSize="32" Width="Auto" HorizontalAlignment="Center"
Text="This is an Embedded Font" />


{/codecitation}

To use the font you need to use the font in the following format.
Fonts.zip#FontName

{codecitation class="brush: xml; gutter: true;" width="650px"}

<TextBlock Height="40" FontSize="32" Width="Auto" HorizontalAlignment="Center" Text="This is an Embedded Font"
FontFamily="Assets/Fonts.zip#AajaxSurrealFreak" />


{/codecitation}

Now run your application and you will find that the font is embedded to the Application.

Image loading...

You can do the same in Expression Blend also.
Open the application in Blend 3. Select the TextBlock and choose the Font. Usually when you have a resource added to the Solution the Font is available in the fonts dropdown box.
Then Check the box named Embed.

Image Loading...

Now your Font is a part of your Silverlight Application executables.
That’s it. It’s so easy to make the font embedding in your application.
Enjoy Coding.

Thank you


About the Author


Diptimaya Patra

Description :I am a Master in Computer Application (MCA) from SRM University, Chennai. I am MCTS in ASP.Net Web Development, and MOSS 2007 Administration. I have extreme exposure to Microsoft Technologies in recent times like Silverlight 2, Silverlight 3. I am from Cuttack, Orissa. You can reach me using this mail (diptimaya.patra@gmail.com). Currently I am working as a Software Engineer in UST Global Inc in Trivandrum Center.

Occupation :Software Engineer
Company : UST Global.
Location : India
Follow me at twitter : http://twitter.com/dpatra


 
Sign Up to vote for this article
 
About Author
 
dpatra
Occupation-Not Provided
Company-Not Provided
Member Type-Expert
Location-Not Provided
Joined date-13 Jul 2009
Home Page-Not Provided
Blog Page-Not Provided
 
 
Other popularSectionarticles
Comments
There is no comments for this articles.
Leave a Reply
Title:
Display Name:
Email:
(not display in page for the security purphase)
Website:
Message:
Please refresh your screen using Ctrl+F5
If you can't read this number refresh your screen
Please input the anti-spam code that you can read in the image.
^ Scroll to Top