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:
