In one of my current projects I did need to use a few custom fonts to represent the customers corporate ID. Usually I would alter my setup script to install the font to %windir%\fonts and use it inside my MCML code like any other pre-installed system font.
But what if you are not allowed to install to the fonts-directory because your customer doesn’t want his fonts to show up in other applications like Word or Fireworks? The solution is easy – simply create an instance of the PrivateFontCollection-class (System.Drawing.Text), call AddFileFont and pass in the full path to the font file.
PrivateFontCollection privateFonts = null;
private void AddPrivateFonts()
{
privateFonts = new PrivateFontCollection();
privateFonts.AddFontFile(@”c:\Tags.ttf”);
}
As soon as you add your font to the collection, it will be available inside your application – just like any other font that is installed.
<Text Color=”White” Font=”TagsFont, 155″ Content=”MCML rocks!” />
Output:

2 responses so far ↓
Eddy Carroll // October 26, 2008 at 10:48 pm |
Very handy tip – thanks! I already have a use for this…
Eddy
Marco // May 18, 2009 at 12:20 pm |
Hi.
I need create a font type encryted.
if i dont have this font in my compyter, the document will show rare charecter.
Do you know about it??