【发布时间】:2012-06-12 09:59:34
【问题描述】:
使用带有私有字体的 RichTextBox 我遇到了以下问题:我可以在文本框中使用我的私有字体编写文本,但是当我选择它时(在我的程序中需要它)文本框返回 MS Sans衬线作为选择字体。
PrivateFontCollection pfc = new PrivateFontCollection(); // font collection
pfc.AddFontFile("..\\..\\Fonts\\infotra1.ttf"); // load font
rtb.Font = new Font(pfc.Families[0], 10.0f, FontStyle.Regular);
rtb.AppendText("lorem ipsum bla bla bla\n");
现在,文本已正确附加到文本框中。
private void rtb_SelectionChanged(object sender, EventArgs e) { var f = rtb.SelectionFont; }
如果我选择文本并检查 rtb.SelectionFont,它会返回 MS Sans Serif。
我知道系统在找不到我的字体时会返回 MS Sans Serif。我是否应该以某种方式告诉 RichTextBox 我也在使用我的私有字体?
【问题讨论】:
标签: c# fonts richtextbox