UserWarning: cmap value too big/small: -33395
I try to test pyfpdf with outputting Chinese pdf on my Fedora21. Here are the codes:
pdf = FPDF()
pdf.add_page()
pdf.add_font('fireflysung', '', '/usr/share/fonts/fireflysung/fireflysung.ttf', uni=True)
pdf.set_font('fireflysung', '', 16)
pdf.write(10, u'edony\n糯米517吃货节\n')
pdf.ln(10)
pdf.output('test.pdf', 'F')
But the warning comes and the test.pdf seems perfect.
pyfpdf/fpdf/ttfonts.py:671: UserWarning: cmap value too big/small: -33395
warnings.warn("cmap value too big/small: %s" % cm)
pyfpdf/fpdf/ttfonts.py:671: UserWarning: cmap value too big/small: -36119
warnings.warn("cmap value too big/small: %s" % cm)
Personally, this is fireflysung font's problem. I don't know why! What should I do to solve it? I download the font from http://www.study-area.org/apt/firefly-font/fireflysung-1.3.0.tar.gz.
Edony, this is our untilled field. This sometimes happens to Droid font set. Be carefull with displayed charters. And stay tuned with this issue.
Thank you very much. I will try my way to solve this and ,if it works, I will pull request.
Someone has found a solution for this issue? I've the same problem with pdf.write of japanese characters (values less then zero are similar): the final print is fine, but I see in my log warnings about this. Precisely, I use this font: http://www.freejapanesefont.com/kokutetsu-ppoi-font-%E5%9B%BD%E9%89%84%E3%81%A3%E3%81%BD%E3%81%84%E3%83%95%E3%82%A9%E3%83%B3%E3%83%88/ (JNRFont_s.ttf)
Thanks, mauro
I suppose this caused by misreading ttf documentation or some changes in format that are not properly handled. Sonn i'll push few commits in this area.
Thank you RomanKharin.
m
I got the same problem. I try to display Chinese string. The warning occur on some Chinese characters. I found that when the cmap is less than zero, this problem will happen. I don't know what it caused. Sorry. I do a dirty and quick way to remark a few lines from ttfonts.py. Then it works. All my Chinese words can be showed. for cm in cmap: if cm >= 0: cmapstr += pack(">H", cm) '# else: '# try: '# cmapstr += pack(">h", cm) '# except: '# warnings.warn("cmap value too big/small: %s" % cm) '# cmapstr += pack(">H", -cm)
@cometl I've tried your method, but some words still can't be showed, instead [].
Had the same problem with ARIALUNI.TTF. It seems that the length of a range was computed as a negative value in ttfonts.py. Here is a patch. Apply with: >patch -i [name] ttfonts.py ----snip---- 649c649 < idDelta = -(start-subrange[0]) --- > idDelta = start-subrange[0] 668,672c668 < try: < cmapstr += pack(">h", cm) < except: < warnings.warn("cmap value too big/small: %s" % cm) < cmapstr += pack(">H", -cm) --- > warnings.warn("negative cmap value ignored: %s" % cm)`` ----snap----
Does anyone have an idea as to what this number means or where it is in the TTF definition? For example, if it is used in an official font library, it makes total sense to use something like fontTools instead of the port of the php ttf parser (which is clearly causing lots of problems).