alexandrettio / pyfpdf

Automatically exported from code.google.com/p/pyfpdf
GNU Lesser General Public License v3.0
0 stars 0 forks source link

Error when calculating dimensions in inches #36

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Thanks for the great tool.

What steps will reproduce the problem?

import fpdf
doc = fpdf.FPDF('P', 'in', 'Letter')
doc.set_font('Arial','B',32)
print doc.w
print doc.get_string_width("text")

What is the expected output? What do you see instead?
The expected output for doc.w is 8.5 but I get 8.
The expected out put for get_string_width is 0.790222222222 but I get 0.0

I have two suggested ways to fix the problem.  One is to use from __future__ 
import division (attached at 158.patch).  The second is to change the scale 
factors to be floats (attached as 159.patch).  

Original issue reported on code.google.com by monso...@gmail.com on 2 Jan 2013 at 3:45

Attachments:

GoogleCodeExporter commented 9 years ago
At a first sight, I prefer the second patch (159.patch).

Please check it doesn't break any test, and bear in mind that romiq.kh is 
working on a py3k branch that will be merged.

I've gave you commit access if you want to apply the patch, thanks for you 
collaboration!

Original comment by reingart@gmail.com on 2 Jan 2013 at 4:21

GoogleCodeExporter commented 9 years ago
My preference would be for enabling true division, as in 158.patch. This is the 
only mode in which Python 3 works, and would go halfway to fixing another 
possible bug I noticed with set_display_mode(<integer>).

Original comment by vadm...@gmail.com on 2 Jan 2015 at 12:37

GoogleCodeExporter commented 9 years ago
If true division is available and works ok in older python versions (2.4 & 
2.5), I have no objection.

vadimium: do you want to take the ownership of this ticket to propose and test 
the final patch?

(I don't have too much time to see this right now, if you can check the 
previous comments and assure nothing is wrong/broken, that would be great!)

Original comment by reingart@gmail.com on 2 Jan 2015 at 11:41

GoogleCodeExporter commented 9 years ago
Issue 78 has been merged into this issue.

Original comment by reingart@gmail.com on 2 Jan 2015 at 11:43

GoogleCodeExporter commented 9 years ago
Hi Reingart, true division has apparently been available since Python 2.2, so 
it should be fine; see the table at the bottom of 
<https://docs.python.org/2/library/__future__.html>.

I’m actually working on some Python 3 fixes and cleanups at the moment. When 
I get the tests working smoothly I can verify that nothing is broken by the 
patch here.

Original comment by vadm...@gmail.com on 3 Jan 2015 at 2:02

GoogleCodeExporter commented 9 years ago
This should be fixed in v1.7.2, due to my change at 
<https://github.com/reingart/pyfpdf/pull/9> that enabled true division.

Original comment by vadm...@gmail.com on 17 Mar 2015 at 7:39