+ -
当前位置:首页 → 问答吧 → PIL、ImageFont、ImageDraw如何显示粗体字????

PIL、ImageFont、ImageDraw如何显示粗体字????

时间:2011-06-27

来源:互联网

Python code

font = ImageFont.truetype("simsun.ttc",24)   #simsun.ttc是宋体字库文件,要和本程序放在一个目录下
img0 = Image.new('L',(24,24),0)
draw = ImageDraw.Draw(img0)
draw.text((0,0),u'',font=font,fill=256)



这样显示的汉字是不加粗的,那如何显示粗体的汉字呢???

作者: XIANXir   发布时间: 2011-06-27

Bold and italic typefaces are usually separate designs from the
"regular" version, so TrueType/OpenType fonts usually consist of a
number of separate font files.

PIL has no support for synthetic font manipulations (and there's
nothing built in to FreeType either, even if you can simulate some
styles using low-level outline transforms).

这是什么意思??是不是说,我只有通过加载粗体字库才能用ImageFont显示粗体的汉字啊????

可是Windows目录下没有专门的粗体的宋体字库啊???

作者: XIANXir   发布时间: 2011-06-27

用雅黑吧。有专门粗体文件。

作者: iambic   发布时间: 2011-06-27