bitmap2ttf icon indicating copy to clipboard operation
bitmap2ttf copied to clipboard

ValueError: not enough image data

Open polyrhythmatic opened this issue 7 years ago • 1 comments

Just wanted to start by thanking you for making this. Very cool utility.

I've successfully used this to convert a .pcf font from gohufont into a ttf.

However I am now trying to convert from a fontforge file New York.sfd into a non bitmapped ttf.

My workflow is to save out a .bdf from the .sfd. I then use bdftopcf to convert the bdf file into pcf.

Unfortunately, there is something wrong with the resulting pcf. I can open it with fontforge and view all the glyphs - everything looks fine. But I get this error when running your script.

Traceback (most recent call last):
  File "pcftottf.py", line 88, in <module>
    p = PcfFontFileUnicode(file(filename))
  File "pcftottf.py", line 38, in __init__
    bitmaps = self._load_bitmaps(metrics)
  File "/usr/local/lib/python2.7/site-packages/PIL/PcfFontFile.py", line 225, in _load_bitmaps
    Image.frombytes("1", (x, y), data[b:e], "raw", mode, pad(x))
  File "/usr/local/lib/python2.7/site-packages/PIL/Image.py", line 2100, in frombytes
    im.frombytes(data, decoder_name, args)
  File "/usr/local/lib/python2.7/site-packages/PIL/Image.py", line 742, in frombytes
    raise ValueError("not enough image data")
ValueError: not enough image data

Any idea what is going on here? I have no clue where to start writing my own loader, so any tips on converting the type would be greatly appreciated.

thanks!

polyrhythmatic avatar Apr 13 '17 16:04 polyrhythmatic

This ended up being due to empty glyphs in the bdf font I was using. I got this to run by manually editing the BDF file but then the script wouldn't respect spacing, kerning etc. so I had to give up.

If you're looking to convert fonts from any bitmap format to true type, this package works great

https://github.com/kreativekorp/bitsnpicas

polyrhythmatic avatar Apr 27 '17 20:04 polyrhythmatic