-
Notifications
You must be signed in to change notification settings - Fork 0
/
MainWindow.xaml.cs
46 lines (38 loc) · 1.64 KB
/
MainWindow.xaml.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
using System.Drawing.Text;
using System.Linq;
using System.Windows;
using DevExpress.Xpf.Printing;
namespace PrivateFontDemo {
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window {
SampleReport report;
PrivateFontCollection privateFonts;
public MainWindow() {
InitializeComponent();
Loaded += MainWindow_Loaded;
DevExpress.XtraPrinting.XamlExport.FontResolver.FamilyNameResolved += FontResolver_FamilyNameResolved;
}
void FontResolver_FamilyNameResolved(object sender, DevExpress.XtraPrinting.XamlExport.FontResolver.FamilyNameResolvedEventArgs e) {
if(useFontResolver.IsChecked != true)
return;
if(e.FamilyName == "Arial Narrow") {
// Packaging Fonts with Applications
// http://msdn.microsoft.com/en-us/library/ms753303(v=vs.100).aspx
e.FamilyName = "./Resources/#" + e.FamilyName;
}
}
void MainWindow_Loaded(object sender, RoutedEventArgs e) {
privateFonts = new PrivateFontCollection();
privateFonts.AddFontFile("./Resources/ARIALN.TTF");
System.Drawing.FontFamily fontFamily = privateFonts.Families.First();
report = new SampleReport();
report.Font = new System.Drawing.Font(fontFamily, 20, System.Drawing.FontStyle.Regular);
preview.Model = new XtraReportPreviewModel(report);
}
private void createDocument_Click(object sender, RoutedEventArgs e) {
report.CreateDocument();
}
}
}