.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Articles >> Silverlight >> Post New Resource Bookmark and Share   

 Subscribe to Articles

Font Embedding In Silverlight Application

Posted By:Diptimaya Patra       Posted Date: March 20, 2010    Points: 25    Category: Silverlight    URL: http://www.dotnetspark.com  

Font Embedding In Silverlight Application. In this article we will see all how we can Embed non-standard fonts in your silverlight application.
 

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.

image1.gif

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.

image2.gif

Now set the Build action to BlendEmbeddedFont.

image3.gif

Now go ahead and add a TextBlock into your application.
 

To use the font you need to use the font in the following format.

Fonts.zip#FontName

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

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

image4.gif

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.

image5.gif

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.
 Subscribe to Articles

     

Further Readings:

Responses

No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More Articles on C#, ASP.Net, Vb.Net, SQL Server and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend