Page view counter
Embedding fonts. Subscribe to this thread
Last post 10-03-2008 3:29 PM by epascales. 3 replies.
Sort Posts:
08-28-2008 11:15 AM
Embedding fonts.

I am developing a Silverlight Application that embeds fonts so as to be able to display non-supported fonts (such as Helvetica).  The code works quite well but for some unusual reason I cannot embed some Adobe fonts that I actually have licenses for.  They are OpenType fonts but whenever I specify them in my JavaScript code it uses the default font (which is Lucida Grande I do believe).  Also note that if I download free fonts off of the Internet (either OpenType or TrueType) everything works just fine.  The problem seems to be related to the Adobe fonts.

Anyone have any idea why this might be the case?  I can tried everything that I can think of but they just wont show.

Thanks

 

     // Executing the appropriate code in order to download the Fonts needed for the Silverlight Canvas.

    var spiContent = document.getElementById("mySilverlightPlugin");        // Holds a Reference to the Silverlight Plugin.
    var downloader = spiContent.createObject("downloader");
    downloader.addEventListener("Completed", onFontDownloadComplete);
    downloader.open("GET", "Fonts/Fonts.zip");
    downloader.send();


function onFontDownloadComplete(sender, eventArgs)
{

    var testBlock1;
    var testBlock2;
    var testBlock3;
 
    testBlock1 = sender.findName("textBlock1");
    testBlock2 = sender.findName("textBlock2");
    testBlock3 = sender.findName("textBlock3");

    testBlock1.setFontSource(sender);
    testBlock2.setFontSource(sender);
    testBlock3.setFontSource(sender);

    testBlock1.fontFamily = "Helvetica LT Std";
    testBlock2.fontFamily = "Helvetica LT Std";
    testBlock3.fontFamily = "Helvetica LT Std";

}

DJA01

Loading...
Joined on 02-01-2008
Posts 45
08-28-2008 2:52 PM
Marked as Answer
Re: Embedding fonts.

Silverlight only support TrueType (TTF) and OpenType (OTF) fonts that contain TrueType outlines. There are plenty of fonts that contain postscript outlines which Silverlight does not support. In some cases you can convert open type/postscript fonts to TrueType outlines using a converter such as:
http://www.fontlab.com/font-converter/transtype/

Also, feel free to send me the font (markri@microsoft.com) and I can tell you if it is a supported font.

-mark
Silverlight Program Manager
Microsoft
This post is provided "as-is"

Mark Rideout

Loading...
Joined on 01-03-2006
Redmond, WA
Posts 268
08-28-2008 4:05 PM
Re: Embedding fonts.

 Thanks for the help.  I've spent at least a couple of days over this problem and its good to know whats going on behind the scenes.  Your response did in fact answer my question so I do really appreciate the help.

Thanks again.

DJA01

Loading...
Joined on 02-01-2008
Posts 45
10-03-2008 3:29 PM
Re: Embedding fonts.

 If we are taking about Silverlight Application in Silverlight 2 beta 2 I'm sure that both font underline: tt and ps are suported by Sl2B2. The best way to embedding fonts is:

1. Add font file to project tree.

2. In font file properties you should set Build Action as Resource and set Copy to output directory as: Do not copy.

3. In xaml file ? 9case font file is in Fonts directory in root directory

<TextBlock FontFamily="fontFilePath#outlinesFontName" />

<TextBlock FontFamily="../Fonts/fontFile.ttf#outlinesFontName" />

 

epascales

Loading...
Joined on 06-11-2008
Posts 5
Microsoft Communities