Page 1 of 7
text rendering
Posted: Wed Jun 13, 2012 7:17 pm
by Tectu
Am I the only one who gets a rectangle with fontColor when using lcdSetFontColor(font_Small); ?
The two other fonts do work.
UPDATE: This works with enabled text transparency.
P.S. Thanks at Abhishek for writting our current text rendering engine.
~ Tectu
Re: text rendering
Posted: Thu Jun 14, 2012 11:26 am
by Abhishek
There was a bug in the current text rendering. In solid mode, it didn't work properly, and was very slow...(took > 1sec to print 'Hello World'! when in solid text rendering mode) I figured out it was drawing a lot of extra pixels.
It is fixed now.
Re: text rendering
Posted: Thu Jun 14, 2012 11:43 am
by Tectu
Thanks for fixing!
Can you please pull request that single fix, without anything else?
~ Tectu
Re: text rendering
Posted: Thu Jun 14, 2012 3:01 pm
by Tectu
Okay, I just had some time to fully check the text rendering. It seems to work great!
I have two questions:
1. Does the transparency mode use much more calculating power? I think we could just make it ALWAYS be transparent and remove the background color of the lcdDrawString parameter then. Is there some reasond against that?
2. @Abhishek: The fonts you are using - did you generate them with a font generator? When yes, could you please make a few more fonts? I'd like to see some larger and very larger fonts for title bars etc. We could also think of having of EACH font in the library the same font in bold. Then we could go like lcdSetFont(LeFont, Bold);
What do you think?
~ Tectu
Re: text rendering
Posted: Fri Jun 15, 2012 7:14 am
by Abhishek
Tectu wrote:1. Does the transparency mode use much more calculating power? I think we could just make it ALWAYS be transparent and remove the background color of the lcdDrawString parameter then. Is there some reasond against that?
I did a quick check using the HAL counter today. Here's the output from the serial port:
Code: Select all
Time taken 1: 2500757, Time taken 2: 830283
2500757=14.88 ms, 830283=4.94ms (168MHz - M4)
As you can see, one is 3 times the other...
The time taken is measured by drawing 95 characters, from 32 (space) to 126 (~) for a particular font. Guess who is who? (Hint: more pixels, more time)
We really need to make the LLD fill area work.
But overwriting transparent text can some times mess things up (e.g. When I was doing my project, I displayed the MEMS (LIS302DL on the STM32F4Discovery) output every 0.1 second, with transparent text rendering, the readings soon became gibberish as items weren't being cleared.. Solid text rendering helps then. Of course, I could have cleared the area. But then 'clearing on demand' (solid text rendering) looks better.
Tectu wrote:2. @Abhishek: The fonts you are using - did you generate them with a font generator? When yes, could you please make a few more fonts? I'd like to see some larger and very larger fonts for title bars etc. We could also think of having of EACH font in the library the same font in bold. Then we could go like lcdSetFont(LeFont, Bold);
What do you think?
Yes, fonts are generated with an application. What kind of fonts do you need?
Though I'm afraid, maximum font size is 16 pixels only (each column is a uint16_t)! And that includes descenders, thus making maximum available size maybe 13 or 14 pixels. And the fonts I've contributed are all bold: regular fonts don't look good on small displays (in your previous text model, which font looked better: System or MS Gothic ?).
If we really need to pack in a lot of fonts, we'll have to implement fonts as a packed bit array, so that it won't occupy much space. Of course rendering code would be more complex, but then we have a 32bit processor at hand!
Re: text rendering
Posted: Fri Jun 15, 2012 10:24 am
by Tectu
I see, I see....
I just wish that we could have some Fonts with over 20 pixel height. And I am sure that we can do that. Why aren't we using uint32_t instead? The "rendering calulcation" inside the MCU shouldn't be that heavy and beside that, big fonts are mostly just used for titlebars etc, which do not get refreshed that often...
Any ideas?
~ Tectu
Re: text rendering
Posted: Fri Jun 15, 2012 10:40 am
by Abhishek
I guess we'll have to write a new text rendering engine,or look for a new solution then.
I also had this problem in mind. Anyway Let's bear with it for now.
If we used uint32_t for all the fonts, we'll have more fonts in flash than code

!
That's why I talked about a bit array.
I'm afraid I've never done something like this before, and don't know the possible implications & requirements.
Could we ask other members for feedback and comments here?
Best Regards.
Re: text rendering
Posted: Wed Jun 20, 2012 11:27 pm
by Badger
I'm not convinced on using functions like lcdSetFont. This will just pollute the name space, to me it makes more sense to pass the font as a parameter to the font drawing routines. These low level functions should be kept as simple as possible; basically just specify the coordinates, colours, font.
When higher level functionality is needed (e.g handling new lines), this should be built upon the lower level stuff. I am currently working on a virtual console type interface. hopefully this wont be too painful!
Re: text rendering
Posted: Thu Jun 21, 2012 7:35 am
by Tectu
I fully agree with you. We definitely need to replace the current font rendering stuff. It is very messed up und very very dirty with all the global variables etc.
It does also cause some basic problems when using BaseSequentialStream, for example with the software X counter when having newlines.
~ Tectu
Re: text rendering
Posted: Thu Jun 21, 2012 5:44 pm
by Abhishek
@Tectu,
If you need BaseSequentialStream functionality and chprintf, then having a local or static address counter and saving the foreground/background colors must be done. The rendering functions had been written that way so that it could be used drop-in with the putchar kind of functions.
Also text wrapping is not good in the sense that wrapping happens character-wise and not word-wise. So it can get ugly sometimes. Word-wrapping is on my ToDo list.
@Badger,
About the 'ugliness' of the code and architecture, it can be probably explained by the fact that the code was first running on an 8051 3 yrs ago. It then got ported to AVR, and finally on the STM32. Each time, only cosmetic changes were made so that the code could compile and run.
Your suggestion of having a console window setting however is a good suggestion. We could have a function lcdSetTextWindow function just as we currently have a lcdSetWindow function. Then we could happily printf without having ugly output.
Alternatively, I was also thinking, I should remove all wrapping and else functionality from the lcdDrawChar function