ActiveReports 19 .NET Edition
MESCIUS.ActiveReports Assembly / GrapeCity.ActiveReports Namespace / SectionReport Class / FontResolver Property
Example

In This Topic
    FontResolver Property (SectionReport)
    In This Topic
    Gets or sets the font resolver.
    Syntax
    'Declaration
     
    Public Property FontResolver As IFontResolver
    public IFontResolver FontResolver {get; set;}

    Property Value

    An object that implements IFontResolver.
    Remarks
    The null value represents the default resolver.
    Example
    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);
    }
    See Also