FontResolver Property (SectionReport)
Gets or sets the font resolver.
Property Value
An object that implements
IFontResolver.
public sealed class DirectoryFontResolver : GrapeCity.ActiveReports.IFontResolver
{
static readonly GrapeCity.Documents.Text.FontCollection _fonts = new GrapeCity.Documents.Text.FontCollection();
static DirectoryFontResolver()
{
_fonts.RegisterDirectory(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Fonts));
_fonts.DefaultFont = _fonts.FindFamilyName("Arial");
}
public static GrapeCity.ActiveReports.IFontResolver Instance = new DirectoryFontResolver();
private DirectoryFontResolver() { }
GrapeCity.Documents.Text.FontCollection GrapeCity.ActiveReports.IFontResolver.GetFonts(string familyName, bool isBold, bool isItalic)
{
var fonts = new GrapeCity.Documents.Text.FontCollection();
var font = _fonts.FindFamilyName(familyName, isBold, isItalic);
if (font != null) fonts.Add(font);
fonts.Add(_fonts.DefaultFont);
return fonts;
}
}
void InitReport()
{
var sectionReport = new GrapeCity.ActiveReports.SectionReport();
sectionReport.LoadLayout(reportFilePath);
sectionReport.Document.Printer.PrinterName = String.Empty;
sectionReport.FontResolver = new DirectoryFontResolver();
viewer.LoadDocument(sectionReport);
}