如何在ReportLab Python中设置字体kerning?
我将字体添加到ReportLab,然后生成PDF,但文本已关闭Kerning。例如,在HTML中它可以按预期工作。如何在ReportLab中启用字体kerning?我尝试在段落方向上更改设置
和textobject.setcharspace
,但没有任何理想的效果。以下是我的示例代码和预期结果。还可以在我的github上提供示例: https://github.com/czubikik.888805/reportlabkerning
from reportlab.pdfbase import pdfmetrics
from reportlab.pdfbase.ttfonts import TTFont
from reportlab.pdfgen import canvas
pdfmetrics.registerFont(
TTFont(
'arial',
'arial.ttf')
)
c = canvas.Canvas("hello.pdf")
c.setFont('arial', 32)
c.drawString(10, 450, "Toned Avenue")
c.showPage()
c.save()
=“ https://i.sstatic.net/w2eax.png” rel =“ nofollow noreferrer”> reportlab(无kerning)的
文本。
I add font to reportlab, then it generates pdf, but text has kerning turned off. For example in html it works as expected. How to enable font kerning in reportlab ? I have tried changing settings in ParagraphStyle
and textObject.setCharSpace
but nothing has the desired effect. Below is my sample code and the expected results. Example is available also on my github: https://github.com/czubik8805/ReportLabKerning
from reportlab.pdfbase import pdfmetrics
from reportlab.pdfbase.ttfonts import TTFont
from reportlab.pdfgen import canvas
pdfmetrics.registerFont(
TTFont(
'arial',
'arial.ttf')
)
c = canvas.Canvas("hello.pdf")
c.setFont('arial', 32)
c.drawString(10, 450, "Toned Avenue")
c.showPage()
c.save()
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论