Open BNNorman opened 6 years ago
Hello Brian , did you have time to look at this feature ?
did you have any news ?
I have added the required support for OpenType/FreeType, TrueType and PIL Font files using PIL. Also corrected font colors were incorrect. Also fixed transparent text background was rendered solid black - which gave the black rectangle on TextAnimations.Wait() (See other issue)
When using TrueType etc anti-aliasing is turned off using lineType=LINE_8 or LINE_4. lineType=LINE_AA is the default. The font I tried with anti-aliasing turned off looked horrid but that's probably just a characteristic of the (free) font I selected.
ok brian amazing ! i will test it soon !
thank you
brian can you add some new examples for the new supported Fonts (PIL , ttf , otf ) to help me to know how i can manipulate them ?
Regards , valentin
Is your browser broken LOL?
Try http://www.1001fonts.com/ and http://fonts.webtoolhub.com/?prefix=pil then you can choose whatever you like (Check licensing if intending to use for commercial purposes).
Just pass the filename to LEDAnimator.Font.py. PIL fonts have two files .pil and .pbm - just use the .pil filename (The PBM is a portable bitmap for the font the PIL is the font information).
Is your browser broken LOL?
Try http://www.1001fonts.com/ and http://fonts.webtoolhub.com/?prefix=pil then you can choose whatever you like (Check licensing if intending to use for commercial purposes).
ok thank you i know how to DL .ttf or .otf Fonts but i was speaking about how to integrate them in your library xD
Just pass the filename to LEDAnimator.Font.py. PIL fonts have two files .pil and .pbm - just use the .pil filename (The PBM is a portable bitmap for the font the PIL is the font information).
Ok i understand but when i try with your attached fonts (ComicJensFreePro-Regular.ttf) in my Font object --> ttf=Font("ComicJensFreePro-Regular.ttf",15)
i have the following error :
Can you help me please ?
Regards , Valentin
The error message last line says IOError: cannot open resource - which is computer speak for 'I can't find the font' (in this case)
Since the fonts are in a folder called Fonts and your main.py is invoked from the folder LEDAnimator you need to add '../Fonts' to your font file path.
ttf=Font("../fonts/ComicJensFreePro-Regular.ttf",fontSize) works for me. I get the same error as you if I leave off the ../Fonts/ from the start
ok no exception now but i have absolutely no difference between ComicJensFreePro and FONT_HERSHEY_SIMPLEX
ok my Bad , i haven't change the fontFace in Text object ...
Just what I figured. LOL.
ok i close the issue thank you brian , you're the best 👍
OpenCV appears to only use Hershey fonts. Using PIL it is possible to read and render TrueType and OpenType fonts but requires converting the numpy array to a PIL image and back again.