繁体   English   中英

如何在PDFsharp中使用等宽字体?

[英]How can I use a monospace font with PDFsharp?

我正在尝试将“ Courier”字体与PDFsharp结合使用以使用其等宽字体功能,但是当我在库中使用该字体时,编写的文本不是等宽字体或固定宽度。

这是代码:

// Obtain an XGraphics object to render to
XGraphics gfx = XGraphics.FromPdfPage(page);

// Create a font
double fontHeight = 8;
XFont font = new XFont("Courier", fontHeight, XFontStyle.Regular);
XTextFormatter tf = new XTextFormatter(gfx);

String text = "Hello\r\nMy name is John\r\nMy name, is Peter.";
XRect rect = new XRect(0, 0, 200, 200);
gfx.DrawRectangle(XBrushes.SeaShell, rect);
tf.DrawString(text, font, XBrushes.Black, rect, XStringFormats.TopLeft);

字母“ i”和字符“。” 打破宽度。

使用计算机上安装的字体,例如“ Courier New”而不是“ Courier”。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM