I'm wanting to use a different font with MigraDoc, but I'm having a hard time getting it to stick. Currently, I'm working with the following code:
I have this as a class-wide variable:
String tPdfFont = "MonospaceTyperwriter";
Then the MigraDoc code itself:
Document tDoc = new Document();
MigraDoc.DocumentObjectModel.Style style = tDoc.Styles["Normal"];
style.Font.Name = tPdfFont;
That particular font is installed on the machine, but it doesn't seem to work. I feel like I'm missing something terribly obvious or am just completley misunderstanding font usage.
Make sure you write the font name as it appears in the Font list in the Control Panel.
Are you sure it's "MonospaceTyperwriter" and not "Monospace Typewriter"?
Code looks OK.
Often it can help to check the DDL file to see if all settings are at the right places.
http://www.pdfsharp.net/wiki/MigraDocDDL.ashx
Feel free to upload a DDL file if you cannot solve the problem and cannot read it yourself.
来源:https://stackoverflow.com/questions/19275073/migradoc-setting-font-for-a-document