We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

PdfTrueTypeFont not working

Hi - we have a number a .ttf font files that are part of our project that we need to use, the client requirement is the fonts cannot be installed on the machine so we need to load them from the project folder. I've attempted to do this without success, in the instance below the font remains on the default and doesn't change to use our .ttf. Can you take a look at our code and let us know what the issue is, thanks.

var installationFolder = Windows.ApplicationModel.Package.Current.InstalledLocation;
var assetFolder = await installationFolder.GetFolderAsync("Assets");
var fontFolder = await assetFolder.GetFolderAsync("Fonts");
var stagMediumFontFile = await fontFolder.GetFileAsync(Constants.StagSansMediumPath);
var stagMediumFontFileStream = await stagMediumFontFile.OpenStreamForReadAsync();

PdfTextElement element = new PdfTextElement("Test Text);
var stagMediumFont = new PdfTrueTypeFont(stagMediumFontFileStream, 70);
element.Font = stagMediumFont;
element.Brush = new PdfSolidBrush(new PdfColor(32, 2, 78));
PdfLayoutResult result = element.Draw(page, new RectangleF(115, 260, page.Graphics.ClientSize.Width / 2, 200));

As you can see above, we are just getting a stream of the font file from the installation directory, then using that stream to create a PdfTrueTypeFont .. when I inspect the stagMediumFont variable it seems as the the font has been read correctly as the name and properties appear, but when the text is drawn on the screen it is not using the specified font.

3 Replies

PH Praveenkumar H Syncfusion Team September 9, 2014 04:23 AM UTC

Hi Nick,

Thank you for using syncfusion products,

Could you please send us the font file, it will help us to investigate further in this.

With Regards,

Praveen



NR Nick Randolph September 9, 2014 04:35 AM UTC

Praveen, here's the font file that's causing us issues.

Thanks


Attachment: StagMedium_95d8774.zip


GL George Livingston Syncfusion Team September 10, 2014 05:32 AM UTC

Hi Nick,

Thank you for you reply.

We could see that same query followed up in the incident 129376. Please follow up in the incident for the solution.

Regards,
George

Loader.
Live Chat Icon For mobile
Up arrow icon