seqdiag font

375 views
Skip to first unread message

Ricardo Mancera

unread,
Apr 26, 2014, 2:46:36 AM4/26/14
to blockdia...@googlegroups.com
Hello,

I want to draw a pdf using DiagramDraw and need an example, this gives me error:

from seqdiag import parser, builder, drawer

tree = parser.parse_string(text)
diagram = builder.ScreenNodeBuilder.build(tree)
draw = drawer.DiagramDraw('pdf', diagram, filename="c:\\Results\\diagram.pdf")
draw.draw()
draw.save()

===> RuntimeError: Could not detect fonts, use --font opiton


-How do i include the font option in the function drawer.DiagramDraw ?

thank you

Komiya Takeshi

unread,
Apr 26, 2014, 4:45:02 AM4/26/14
to blockdia...@googlegroups.com
Hi Recard,

>-How do i include the font option in the function drawer.DiagramDraw ?

Outputting PDF requires truetype font.
You should give fontmap argument to DiagramDraw().

blockdiag.utils.bootstrap:create_fontmap() will help you to create
fontmap object.

Thanks,
> --
> このメールは Google グループのグループ「blockdiag-discuss」に登録しているユーザーに送られています。
> このグループから退会し、グループからのメールの配信を停止するには
> blockdiag-disc...@googlegroups.com にメールを送信してください。
> その他のオプションについては https://groups.google.com/d/optout にアクセスしてください。

varvar debianvarvar

unread,
Jul 18, 2016, 12:06:50 AM7/18/16
to blockdiag-discuss
Hi, 
    is there any example code about how to add truetype font use python scripts?
Thanks for your help!

varvar debianvarvar

unread,
Jul 18, 2016, 10:45:14 PM7/18/16
to blockdiag-discuss
after reading the code, I fixed it.

For those who also met problems in change fontmap, 

here is the sample code:

options = dict()
options['fontmap'] = ''
options['font'] = list()
options['font'].append('/usr/font/DejaVuSerif.ttf:1')
options = utils.dotdict(options)
fm = create_fontmap(options)
pdfdraw = drawer.DiagramDraw('PDF', diagram, filename=pdfname, debug=True, fontmap=fm)
pdfdraw.draw()
pdfdraw.save()

Komiya Takeshi

unread,
Jul 18, 2016, 11:05:16 PM7/18/16
to blockdiag-discuss
Hi,

Sorry for late response.
You can do it using following code. (I don't test it. but it will work fine)

from blockdiag.utils.fontmap import FontMap

fm
= FontMap()
fm
.set_default_font('/usr/font/DejaVuSerif.ttf:1')

Thanks,
Takeshi KOMIIYA


2016年7月19日火曜日 11時45分14秒 UTC+9 varvar debianvarvar:
Reply all
Reply to author
Forward
0 new messages