May 2009 - Posts

How To: Font Embedding In Silverlight

Silverlight includes nine basic core fonts (these fonts can be rendered correctly on any browser and operating system Silverlight supports):

  • Arial
  • Arial Black
  • Comic Sans MS
  • Courier New
  • Georgia
  • Lucida Grande / Lucida Sans Unicode
  • Times New Roman
  • Trebuchet MS
  • Verdana

But what can you do when you like to use another font which is not included in the core fonts list?

The answer is embedding the desired font in your Silverlight application:

  1. Add the font file to your application and set the Build Action to Resource:
    image
  2. Set the FontFamily property in the following format: FontFileName#FontName
<TextBlock Text="This is Calibri Font" FontFamily="CALIBRI.TTF#Calibri" FontSize="20"> </TextBlock>

Or you can achieve the same effect in the code behind:

StreamResourceInfo sri = Application.GetResourceStream( new Uri("SilverlightApplication1;component/CALIBRI.TTF", UriKind.Relative)); TextBlock1.FontSource = new FontSource(sri.Stream); TextBlock1.FontFamily = new FontFamily("Calibri");

And here’s the result:

image

Hope you find it useful.

Posted by itai | 2 comment(s)
תגים:,

And the Emmy goes to… Silverlight!

NBC Olympics wins an Emmy for its online coverage of 2008 Summer Olympics where Silverlight took a major part in “Outstanding New Approaches Sport Event Coverage”.

This should boost up Silverlight reputation..

Posted by itai | with no comments
תגים:,

Azure Design Patterns Site

I came across this Azure Design Patterns site which I found very interesting and worth sharing.

Posted by itai | with no comments
תגים:,