Skip to main content
Home Forums Silverlight Programming Programming with .NET - General Embedding fonts.
3 replies. Latest Post by epascales on October 3, 2008.
(0)
DJA01
Member
67 points
45 Posts
08-28-2008 11:15 AM |
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";}
Mark Rid...
Contributor
2357 points
273 Posts
08-28-2008 2:52 PM |
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.
-markSilverlight Program ManagerMicrosoftThis post is provided "as-is"
08-28-2008 4:05 PM |
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.
epascales
6 points
5 Posts
10-03-2008 3:29 PM |
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" />