I just wanted to let people know I have made a free library available that allows Proportional/TTF/OTF fonts to be displayed on Arduinos. It extends the UTFT library and adds ttf derived font capability. It includes a tool that runs on windows and converts any ttf/otf font into a compact proportional bitmap font for use on TFT displays.
I did it for my own needs, but have made it available in case it's useful to others.
Nice, I'm planning to do a similar program that outputs 8bpp (1 bit for ON/OFF and 7 bits for alpha channel) so I can use anti aliased fonts. Space is not really a problem because I soldered a 4Mb flash chip on the back of the display. Or I could reduce to 4bpp maybe.
So I have no use of your program, but good work anyway, it will help people
Edit: removed stupid comment about The Dot Factory..
The major use for this that I can see, is people wishing to use the BVS fonts included in the Coldtears display font IC, that do not have that ic. So I located Bitstream Vera Sans.ttf and converted it using your ttf2c_vc2003 tool to all the sizes I know about, and this worked flawlessly thankyou!!
However one 'slight' niggle/suggestion if I may? Could you modify the tool slightly to use as the c array name? Such that
ttf2c 112 vera.ttf BVS_112.c
would yield a c array of the same name as the filename in this case BVS_112.c?
I am surprised a thread as old as this, offering the features you do, has not gotten more traffic or comments, so let me say a big thankyou! I for one certainly appreciate your efforts and can definitely see it receiving some use here.
Thanks for the nice words. I'm glad it's useful to you.
To answer your questions:
I don't follow the thread that often, but occasionally check in here. I looked today because someone posted a question to me through my website.
Unfortunately it's a bit of a pain to change the code at the moment. It has to be built with particular (older) compilers to ensure it runs everywhere, and I don't have those on this computer (and I'm overseas for the next year or so). However, the behaviour you are after can be easily done using a script. For those who haven't done it before, a simple dos command line batch script would probably give you and others any specific behaviour they're after.
Something like (untested):
REM ttf2c_2003.exe %1 %2 %3.c
ttf2c_~1.exe %1 %2 %3.c
ren %3.c %3%1.c
Put that in ttf.bat, then instead of calling the exe file directly, call it through "ttf 18 font.ttf outname" (no .c extension on the last parameter).
Alternatively, use a scripting language of your choice for more complex manipulations.
I thought I would also take the opportunity to answer a couple of questions that have been posted to me at my website.
For those who are trying to use the ttf conversion utility, it is a DOS command line utility. So, to run it, you need to start a DOS command prompt, then change to the directory and run it. Doing so will print out the usage text.
Additionally, while I appreciate people taking the time to write comments to me, I don't tend to respond to general usage questions posted on my website. The appropriate place for those types of questions is here, in the forum. That way others can help, as well as other people in the same position as you get to see the answers. Please try your questions here, as Graham has done, and if that fails, by all means post through my website.
Thanks for everyone's interest, and I'm glad people are getting some benefit from this.
arduinodlb:
2) Unfortunately it's a bit of a pain to change the code at the moment. It has to be built with particular (older) compilers to ensure it runs everywhere, and I don't have those on this computer (and I'm overseas for the next year or so). However, the behaviour you are after can be easily done using a script. For those who haven't done it before, a simple dos command line batch script would probably give you and others any specific behaviour they're after.
Something like (untested):
REM ttf2c_2003.exe %1 %2 %3.c
ttf2c_~1.exe %1 %2 %3.c
ren %3.c %3%1.c
Put that in ttf.bat, then instead of calling the exe file directly, call it through "ttf 18 font.ttf outname" (no .c extension on the last parameter).
I tried but did not work (the example of your library).
Thank you!
This library is a "bolt-on" for Henning Karlsen's wonderful UTFT suit of libraries, if your display works with those, then this library will work alongside to provide proportional fonts.
However.... Having looked at the link you provided, it is a modified version of the UTFT libraries, as such, there are incompatibilities. Would it be possible to use the UTFT libraries unmodified directly from Henning Karlsen? One of the modules supported by Henning that could be a suitable candidate is
TFT01_22SP
as the UTFT type which utilises the ILI9341 Controller? If you can make that work, then I suspect this library will work. Otherwise, you are out of luck due to the nature of the modifications in the pantata library.
You can do what Graham suggests if you want particular filenames, or you can just start a windows cmd.exe prompt, change to the directory that contains the "ttf2c_2003.exe" program, and type "ttf2c_2003.exe". It will then print out how to use it. You must do this from a windows command prompt. If you don't know what that is, then you may have to read a little about that on the internet.
Since IDE V1.5.7 we appear to have a problem with ttf2c_2003.exe The generated fonts are now not allowed since font type is uint8_t, whereas it should be const uint8_t.
UTFTDLB_Buttons already exists and can be downloaded from the same website. It also allows for different buttons to be different colours.
Unfortunately changing my program is a bit of a pain, so you'll have to add the const yourself, either using a scripting language like perl or python, or by hand.
I would also like to echo the sentiments of others and thank you for this great library - it makes everything look so much better!!
My question - UTFT_DLB works with the standard UTFT library but does it replace it? I note that you have a 'print' function in your library but there is nothing equivalent to the printNumI or printNumF functions found in the original library. When I try to use these functions nothing is displayed on the screen. I have been able to overcome this issue by converting the number using dtostrf and then using the print function but is this the best way to do it?
I am also using your button library - the original button library allows the use of bitmaps as buttons. Is it possible to use both button types in a sketch i.e. some bitmap buttons and some buttons using your proportional fonts? Or, can I only use one or the other?
UTFT_DLB extends the UTFT library, but I didn't extend every function. I was trying to minimize the size of the additional code and as you discovered, decided that the functionality of printNumF and printNumI could be replicated by converting to a string. Yes, it's slower, but it makes the library smaller and I think in most cases, is a satisfactory solution. Alternatively, you could extend UTFT_DLB and add your own printNumF and printNumI functions, but I'd just do what you're doing. Or add a local printNumF/printNumI that converts it to a string and uses UTFT_DLB. The only disadvantage is slightly slower speed.
Good question about the buttons. My instinct says two things:
You could probably mix them.
More importantly, there is no reason to mix them. Just make them all UTFT_DLB buttons. UTFT_DLB buttons can use standard UTFT bitmaps, UTFT fonts, as well as UTFT_DLB type fonts as far as I can recall. Apart from proportional fonts in buttons, the library also allows the buttons to be different colours, which was important for my application.
Not sure how helpful that is, but my Arduino stuff is currently in another country.
If you test these combinations, please report back here with the results so we know for sure.