mugmuggy / pyfpdf

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

Support for non-BMP glyphs 0x100000-0x10FFFF #39

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Use font with non-BMP glyps (e.g. DroidSansFallback.ttf, see Issue 37 how to 
use this font)
2. Try to create PDF with non-BMP (0x100000-0x10FFFF) chars (0x010400, 
0x010428, 0x01044d, 0x01044e, 0x01044f, 0x01d30c in DroidSansFallback.ttf)

What is the expected output? What do you see instead?
PDF with non-BMP charters (DESERET code plane in this example)

INsted
Traceback (most recent call last):
  File "charmap.py", line 46, in <module>
    pdf.output(fn,'F')
  File "../tests/fpdf/fpdf.py", line 971, in output
    self.close()
  File "../tests/fpdf/fpdf.py", line 240, in close
    self._enddoc()
  File "../tests/fpdf/fpdf.py", line 1526, in _enddoc
    self._putresources()
  File "../tests/fpdf/fpdf.py", line 1473, in _putresources
    self._putfonts()
  File "../tests/fpdf/fpdf.py", line 1275, in _putfonts
    cidtogidmap[cc*2] = chr(glyph >> 8)
IndexError: list assignment index out of range

Please use labels and text to provide additional information.

Non BMP code planes lay in range 0x100000 .. 0x10FFFF.
This issue applied only in python with UCS-4 support or all python platforms >= 
3.3 (see PEP-393 http://www.python.org/dev/peps/pep-0393)

Original issue reported on code.google.com by romiq...@gmail.com on 8 Jan 2013 at 10:28

Attachments:

GoogleCodeExporter commented 9 years ago
Sorry, I don't fully understand ... is this a python error?
Does it throw an excepction or it is a workaround?

Original comment by reingart@gmail.com on 8 Jan 2013 at 4:34

GoogleCodeExporter commented 9 years ago
My opinion cause is assumption

fpdf.py:1273  cidtogidmap = ["\x00"] * 256*256*2 (64k words)

but index can be up to 0x20FFFF. Should be fixed next to Issue 37

Original comment by romiq...@gmail.com on 8 Jan 2013 at 5:10

GoogleCodeExporter commented 9 years ago
Ok, if you double the space at cidtogidmap it does work?

Could you detect the font and double the space only if needed?

If it fixes the issue, go ahead ;-)

Original comment by reingart@gmail.com on 8 Jan 2013 at 5:50

GoogleCodeExporter commented 9 years ago
Increase buffer to 0x220000 bytes (2.2 Mb) allow script to work, but then 
output failed

001) 10400 - [] []

It should be glyph (or at least one []). Seems to be UTF-16 conversion or 
something like this. Investigating...

Original comment by romiq...@gmail.com on 8 Jan 2013 at 6:25

Attachments: