Adding system fonts to a Windows Metro app

34 views
Skip to first unread message

Jon Hoffman

unread,
Apr 25, 2014, 2:46:49 PM4/25/14
to dot-net-...@googlegroups.com
I am trying to get started with Siberix but the one thing I am stuck on is how to add a font.  I am looking thought the User Guide that comes with the evaluation download but I am not failing to see how to load a font.  I believe I should be using the GetFontDelegate() but not sure how to get it to work within a metro app.
Thanks,

siberix

unread,
Apr 25, 2014, 3:10:04 PM4/25/14
to dot-net-...@googlegroups.com
Hi Jon,

Please read below:

1. Siberix Report Writer requires TTF font data. We parse the data on the fly to retrieve all the required information about the font (metrics, glyphs, etc.) and also need it to provide the support for embedding and subsetting (when allowed by the creator of the font).

2. Unfortunately, WinRT / WinStore runtime doesn't provide methods to retrieve this font data directly from the available system fonts. This is why you'd need to supply required font files (somefont.ttf files) all together with your app. Please use only fonts that are permitted to be embedded and redistributed by the creator of the font.

3. To reference a TTF font file from within your app: You need to copy this font file into the project folder of your app and set their "Build Action" to "Content" and "Copy to Output Directory" to "Copy always". Then you may use our helper PackageResource class to get the access to the underlying font data stream

// Resources and Fonts (some private class members)
private PackageResource Arial;
private Siberix.Graphics.Font font1;

...

Arial = new PackageResource("arial.ttf");

font1 = new Siberix.Graphics.Font(await Arial.GetDataAsync(), 80);

// Report
Siberix.Report.Report report = new Siberix.Report.Report();

// Section
Siberix.Report.Section.ISection section = report.AddSection();
section.Size = Siberix.Report.PageSize.Letter;
section.Spacings.All = 35;

// Styles
Siberix.Report.Text.Style style1 = new Siberix.Report.Text.Style(font1, Siberix.Graphics.Brushes.DarkBlue);

Siberix.Report.Text.IText text = section.AddText();
text.Style = style1;
text.Width = new Siberix.Report.RelativeWidth(100);
text.AddContent("Hello PDF");

4. Please also take a look at the examples (HelloPDF and Elements) available for the download as a part of the evaluation package for the Report Writer for WinStore at our web site (http://www.siberix.com).

Thank You,
Victor
Reply all
Reply to author
Forward
0 new messages