FontResolver Property (SectionDocument)
Gets or sets a value representing the implementation of the resolution of the font resources required to render a document in the
CompatibilityModes.CrossPlatform compatibility mode.
Property Value
An object that implements
GrapeCity.ActiveReports.IFontResolver.
Custom font resolver implementation Set font resolver
public sealed class CustomFontResolver : GrapeCity.ActiveReports.IFontResolver
{
static readonly GrapeCity.Documents.Text.FontCollection _fonts = new GrapeCity.Documents.Text.FontCollection();
static CustomFontResolver()
{
_fonts.RegisterDirectory(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Fonts));
_fonts.RegisterDirectory(System.IO.Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.LocalApplicationData), "Microsoft/Windows/Fonts"));
// required reference to DS.Documents.Imaging.Windows
GrapeCity.Documents.Text.Windows.FontLinkHelper.UpdateFontLinks(_fonts, true);
_fonts.DefaultFont = _fonts.FindFamilyName("Arial");
}
public static readonly GrapeCity.ActiveReports.IFontResolver Instance = new CustomFontResolver();
private CustomFontResolver() { }
GrapeCity.Documents.Text.FontCollection GrapeCity.ActiveReports.IFontResolver.GetFonts(string familyName, bool isBold, bool isItalic)
{
// suggested to cache values
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;
}
}
var sectionDocument = new GrapeCity.ActiveReports.Document.SectionDocument();
sectionDocument.Load("Document.rdf");
sectionDocument.CompatibilityMode = GrapeCity.ActiveReports.Document.CompatibilityModes.CrossPlatform;
sectionDocument.FontResolver = CustomFontResolver.Instance;