SIGN UP MEMBER LOGIN:    
ARTICLE

Font Embedding in Silverlight 3 Application

Posted by Diptimaya Patra Articles | XAML with C# July 30, 2009
In this article we will see how to use Font Embedding in silverlight 3.
Reader Level:
Download Files:
 

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.

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

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.

Login to add your contents and source code to this article
share this article :
post comment
 

great instructions

Posted by Biswajit Chatterjee Jul 12, 2010
Become a Sponsor
PREMIUM SPONSORS
  • ceTE software specializes in components for dynamic PDF generation and manipulation. The DynamicPDF™ product line allows you to dynamically generate PDF documents, merge PDF documents and new content to existing PDF documents from within your applications. Visit DynamicPDF here
    Finally – a virtual platform that delivers next-generation Windows Server 2008 Hyper-V virtualization technology from a managed hosting partner you can truly depend on. Visit www.maximumasp.com/max for a FREE 30 day trial. Hurry offer ends soon. Climb aboard the MaxV platform and take advantage of High Availability, Intelligent Monitoring, Recurrent Backups, and Scalability – with no hassle or hidden fees. As a managed hosting partner focused solely on Microsoft technologies since 2000, MaximumASP is uniquely qualified to provide the superior support that our business is built on. Unparalleled expertise with Microsoft technologies lead to working directly with Microsoft as first to offer IIS 7 and SQL 2008 betas in a hosted environment; partnering in the Go Live Program for Hyper-V; and product co-launches built on WS 2008 with Hyper-V technology.
Team Foundation Server Hosting
Become a Sponsor