question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Font rendering scripts fail to execute.

See original GitHub issue

The scripts which use fonts from the “fonts” folder included in examples, fail to execute. It raises IOError - unknown file format.

Display: pcd8544
Interface: spi
Dimensions: 128 x 64
----------------------------------------
Traceback (most recent call last):
  File "welcome.py", line 233, in <module>
    main()
  File "welcome.py", line 198, in main
    fonts = [make_font("code2000.ttf", sz) for sz in range(24, 8, -2)]
  File "welcome.py", line 121, in make_font
    return ImageFont.truetype(font_path, size)
  File "/usr/local/lib/python2.7/dist-packages/PIL/ImageFont.py", line 238, in truetype
    return FreeTypeFont(font, size, index, encoding)
  File "/usr/local/lib/python2.7/dist-packages/PIL/ImageFont.py", line 127, in __init__
    self.font = core.getfont(font, size, index, encoding)
IOError: unknown file format

It seems, imagefont is unable to load fonts from anywhere else except the default folders, i.e - “/usr/share/fonts/truetype/freefont/” After copying the individual fonts to the above mentioned folder, the script works flawlessly, also the provided “code2000.ttf” font is corrupt, I downloaded a fresh copy of the “code2000.ttf” from internet , after copying to the default folder , it works.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:13 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
ghostcommented, Mar 22, 2017

Thanks a lot!, it works after getting the fresh repository. I downloaded the zip file instead of cloning this time(seems like some connection problem or git problem) , and everything works correctly. Also I had to install the pygame through apt-get : $ sudo apt-get install python-pygame Installing through the default installer script generates error, “sdl-config” not found.

Also in pcd8544.conf the default SPI speed is 32Mhz , but with this setting the display remains blank , it works upto a max of 8Mhz.

1reaction
thijstriemstracommented, Mar 22, 2017

Hmm… Ubuntu 16.04, latest git master for examples:

$ ls -l ../luma.examples/examples/fonts/
total 8700
-rw-rw-r-- 1 thijs thijs   49432 feb 27 23:59 C&C Red Alert [INET].ttf
-rw-rw-r-- 1 thijs thijs 8377000 feb 27 23:59 code2000.ttf
-rw-rw-r-- 1 thijs thijs   85484 feb 27 23:59 creep.bdf
-rw-rw-r-- 1 thijs thijs  165548 mrt 15 21:37 fontawesome-webfont.ttf
-rw-rw-r-- 1 thijs thijs   64880 feb 27 23:59 FreePixel.ttf
-rw-rw-r-- 1 thijs thijs   23280 feb 27 23:59 miscfs_.ttf
-rwxrwxr-x 1 thijs thijs   22184 feb 27 23:59 pixelmix.ttf
-rw-rw-r-- 1 thijs thijs   35656 feb 27 23:59 ProggyTiny.ttf
-rw-rw-r-- 1 thijs thijs    2847 feb 27 23:59 README [INET].txt
-rw-rw-r-- 1 thijs thijs    6656 feb 27 23:59 tiny.ttf
-rw-rw-r-- 1 thijs thijs   55580 feb 27 23:59 Volter__28Goldfish_29.ttf
Read more comments on GitHub >

github_iconTop Results From Across the Web

Font rendering fails when code runs under IIS 7.0 - Super User
When the code from the ASP page is run as a VBScript file under an Administrator account the rendering does use the correct...
Read more >
The external text renderer plugin failed to render the text string ...
Hi, I'm running Psychtoolbox on Matlab2018b on a Windows machine. When trying to print text to the screen using either DrawText or ...
Read more >
messed up indic script rendering in browsers, Any better ...
I tried to willfuly mess up hindi rendering in fedora but failed, i changed every font i can, in fedora but still the...
Read more >
Script crashing every other time I initialize it when trying to ...
When I run the script, it either works, or the window just stays black for a few seconds and exits. No error message,...
Read more >
Render font error example( text - Designer - Alteryx Community
Changing fonts and scripts in report text tools did not succeed. Can you upload a successful file? ※ According to the survey, arial...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found