[reportlab-users] Fonts / positioning different on Windows vs Linux

12 views
Skip to first unread message

Mike Driscoll

unread,
Jan 8, 2014, 4:38:13 PM1/8/14
to reportlab-users
Hi,

I was wondering why the standard font is different on Linux versus Windows. Also, I noticed that the actual positioning of the text / elements are slightly different. The latter may be partially a function of the font difference, although I'm not sure of that.

Anyway, I created a simple example where I have a barcode and an address underneath it. You'll notice that the first line of the address is slightly closer to the barcode when the code is run on Linux versus when it's run on Windows.

This might not seem like a big deal, but I discovered that it matters when you are trying to position MICR marks on a check...I would get it working on one OS to find out it was broken on another. And I've had code where it will look great on Windows, then when I run it on Linux, the first line of the address is buried in the barcode.

I am testing on CentOS and Windows 7.

-------------------
Mike Driscoll

Blog:   http://blog.pythonlibrary.org
test_linux.pdf
pdf_test.py
test_win.pdf

Andy Robinson

unread,
Jan 8, 2014, 4:47:19 PM1/8/14
to reportlab-users
Mike, if you use the standard font names supported by PDF (Helvetica,
Times and Courier), you are not actually using a standard font. Your
PDF viewer software or operating system decides what to substitute,
and there are many subtle variations of Helvetica and Times - it all
comes down to who licensed what for those big platforms many years
ago.

If you need reproducibility, the best thing is to select a TrueType
font and explicitly include the font file in your code under version
control. The glyphs will be embedded in the PDF, and as far as I
know, it will render identically across platforms. Our font chapter
shows how to do this. You can choose from a ton of fonts in the
Google fonts repository.

Hope this helps,


Andy
> _______________________________________________
> reportlab-users mailing list
> reportl...@lists2.reportlab.com
> http://two.pairlist.net/mailman/listinfo/reportlab-users
>



--
Andy Robinson
Managing Director
ReportLab Europe Ltd.
Thornton House, Thornton Road, Wimbledon, London SW19 4NG, UK
Tel +44-20-8405-6420
_______________________________________________
reportlab-users mailing list
reportl...@lists2.reportlab.com
http://two.pairlist.net/mailman/listinfo/reportlab-users

Mike Driscoll

unread,
Jan 8, 2014, 5:02:14 PM1/8/14
to reportl...@googlegroups.com, reportlab-users
Hi Andy,


On Wednesday, January 8, 2014 3:47:19 PM UTC-6, Andy Robinson wrote:
Mike, if you use the standard font names supported by PDF (Helvetica,
Times and Courier), you are not actually using a standard font.  Your
PDF viewer software or operating system decides what to substitute,
and there are many subtle variations of Helvetica and Times - it all
comes down to who licensed what for those big platforms many years
ago.

If you need reproducibility, the best thing is to select a TrueType
font and explicitly include the font file in your code under version
control.  The glyphs will be embedded in the PDF, and as far as I
know, it will render identically across platforms.  Our font chapter
shows how to do this.    You can choose from a ton of fonts in the
Google fonts repository.

Hope this helps,


Andy

Ah. I misunderstood the documentation. I thought the "fonts" included in Reportlab were standard, not using OS fonts. I know how to embed custom fonts. I'll have to ask my superiors about actually including something specific font.

Thanks for the info. Hopefully that will solve the issue.

Mike
 
Reply all
Reply to author
Forward
0 new messages