【问题标题】:itextsharp's Arial ,courier new font always show italic in windows 8itextsharp 的 Arial ,courier 新字体在 Windows 8 中总是显示斜体
【发布时间】:2013-10-04 06:47:10
【问题描述】:

为什么在windows 8中,我运行下面的代码,设置字体是Arial,字体样式是常规的,

在创建 PDF 之后。 Why Is Arial Black Rendering in Italics? 字体样式变为斜体。快递新字体也有同样的问题。只有这两种字体有问题。

此代码在 Windows 7 中运行良好,字体样式正常。

string path = @"c:\test\";
iTextSharp.text.Rectangle r = new iTextSharp.text.Rectangle(400, 300);
Document doc = new Document(r);
PdfWriter.GetInstance(doc, new FileStream(path + "Blocks.pdf", FileMode.CreateNew));
doc.Open();


BaseFont baseFont = BaseFont.CreateFont("C:\\Windows\\Fonts\\ariali.ttf", BaseFont.CP1252, false);
//set font.style=0;
iTextSharp.text.Font newFont = new iTextSharp.text.Font(baseFont, 16f, 0, iTextSharp.text.BaseColor.BLACK);
Chunk c1 = new Chunk("A chunk represents an isolated string. ", newFont);
doc.Add(c1);
doc.Close();

【问题讨论】:

  • 您使用的是 ariali.ttf,它是 Arial 斜体。因此,您最终会使用斜体也就不足为奇了。

标签: itextsharp


【解决方案1】:

试试它对我的工作。 并确保您使用正确的字体

NormalFont ="C:\\Windows\\Fonts\\ARIAL.ttf";
BaseFont baseFont = BaseFont.CreateFont(fontType, BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED);
Font font = new iTextSharp.text.Font(baseFont, fontSize, fontStyle);
Chunk chunk = new Chunk(str, font);

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-01-15
    • 2011-06-22
    • 1970-01-01
    • 2019-01-10
    • 1970-01-01
    • 2013-06-24
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多