I'm writing this text layer on my image using ImageResizer's Watermark plugin. Works fine! But now I want use a specific font. If I specify an existing font on my system, works fine!
My problem occurs because I was to use this custom .TTF font. I'm running locally for the moment, so I installed the fonts in my Windows 7. The font looks like it's correctly installed, when I open up Outlook I can use the font there to style my text.
If I reboot though, the font appears uninstalled. When I try to install it again, Windows says it's already installed.
Eventually I tried unblocking the .ttf file and re-installing, did not help. Since I'm using this through my c# code running in IIS I also tried giving the font file (once inside my Windows/Fonts folder) Full Control for "Network service" user (which my application pool is running under).
I checked in InstalledFontCollection installedFonts = new System.Drawing.Text.InstalledFontCollection();, ran with debugger and tried to find my font, was not in there. Tried to load it directly with PrivateFontCollection, I get a file not found exception.
So... I'm running out of ideas here! What should I be looking for to find out what's the problem? Thanks!
Below is the code I'm running to watermark my image:
var c = Config.Current;
// Name layer
var userNameLayerA = new TextLayer();
userNameLayerA.Text = firstName + " " + lastName;
userNameLayerA.TextColor = System.Drawing.Color.Black;
// userNameLayerA.Font = "Verdana"; // --> Works fine!
userNameLayerA.Font = "Headline Two"; // --> Does not work!
userNameLayerA.FontSize = 16;
userNameLayerA.Style = FontStyle.Bold;
userNameLayerA.Align = ContentAlignment.MiddleCenter;
userNameLayerA.Top = new DistanceUnit(295, DistanceUnit.Units.Pixels);
// Register layer
var wp = c.Plugins.Get<WatermarkPlugin>();
wp.NamedWatermarks["userNameLayerA"] = new Layer[] { userNameLayerA };
// Build image
c.CurrentImageBuilder.Build(posterAEnFilePath, posterAEnDestinationFilePath, new ResizeSettings("watermark=userNameLayerA;"));