簡體   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