java 导入字体,如何使用java将新字体添加到Itext

when I want to use a font is iText I do the following:

protected final static Font FONT_SIZE_11_BOLD = new Font(Font.HELVETICA, 11f, Font.BOLD);

and then I can use it whereever I want, as follows:

monthSize11 = new Chunk(month, FONT_SIZE_11_BOLD);

I want to use Arial instead of HELVETICA, but Arial is not directly available.

I mean, I cannot do

new Font(Font.ARIAL, 11f, Font.BOLD);

because Arial is not defined at the Font class, but the Arial.ttf file is at my System under C:\WINDOWS\Fonts.

The question is how I can bind the Arial.ttf file to iText and how can I use it.

Many thnaks in advance.

EDIT: I would like to use own fonts. I mean, I have a file called "myCompany.ttf" where own fonts have been defined and at some places I must use. The problem is not only with Arial.

解决方案

BaseFont base = BaseFont.createFont("c:/windows/fonts/arial.ttf", BaseFont.WINANSI);

Font font = new Font(base, 11f, Font.BOLD);

....

Read more here.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值