Large fonts

djung1000
Posts: 12
Joined: Mon Feb 04, 2013 9:18 pm

Large fonts

Postby djung1000 » Thu Mar 21, 2013 8:15 am

Hi all, back at the dev board after a long time :)
Got a question about the font size. I need large fonts for the app I'm designing and wonder if it is possible to add my own font to the fonts.c file.
I tried to use an existing one by increasing the size as intended but it gets to rough around the edges.
Image doesn't seem to work???
That's the photo - http://s839.photobucket.com/user/djung1 ... 9.jpg.html

I was looking for a 160 pixel high font. Is that possible to be added to the fonts.c file? Any tool available to do that or has it to be done manually?

Cheers
Dietmar

User avatar
Tectu
Posts: 1226
Joined: Thu May 10, 2012 9:50 am
Location: Switzerland
Contact:

Re: Large fonts

Postby Tectu » Thu Mar 21, 2013 8:45 am

Hello Dietmar,

The scaling is indeed not a permanent solution for this. What would be needed is a proper anti-aliasing routine. This way, we can use a base font of let's say 10pt and scale it up without getting rough edges. The problem is that you can currently not store any fonts that are larger than 32pt in height. Back the days, there was the idea of implementing a truetype font support.

If you can implement any of these two solutions, everybody and especially I would be VERY thankful. The current font routine is indeed nothing for the future.
The anti-aliasing might be something that could be implemented globally so all the drawing routines could take advantage of it?


~ Tectu

djung1000
Posts: 12
Joined: Mon Feb 04, 2013 9:18 pm

Re: Large fonts

Postby djung1000 » Thu Mar 21, 2013 8:51 am

Hi Tectu, I have no idea how this could be done. I'm not a SW developer, but if you can point me in the right direction where I could have a look and get more info about something like that then I could learn a bit and try it.

Danke
Dietmar

User avatar
Tectu
Posts: 1226
Joined: Thu May 10, 2012 9:50 am
Location: Switzerland
Contact:

Re: Large fonts

Postby Tectu » Thu Mar 21, 2013 10:34 am

Hey there,

I've never done any anti-aliasing myself. However, there are quite a few tutorials about this. I guess you'd need to read into it a bit. As far as I know, there are even algorithms directly in wikipedia. I'd recommend you to google for simple anti-aliasing algorithms or similar keywoards. Maybe 'tutorial' might be a good shot as well.
For the truetype fonts, I don't have any idea. I never found the time to read myself into the topic and I don't have any knowledge from previous projects. Google might help here as well - not sure.


~ Tectu

djung1000
Posts: 12
Joined: Mon Feb 04, 2013 9:18 pm

Re: Large fonts

Postby djung1000 » Sun Mar 24, 2013 11:45 pm

Had a read about fonts for embedded systems and it looks like this could be a big task to implement if you want to do it properly.
As I only need a certain font for easy to read numbers, I think I have two options.
1. create the sizes I require in arrays for all the numbers and symbols and write a different font engine which is able to display these fonts in different colours on the lcd similar to the existing font engine.
2. Create different header files for each bitmap and colour of the required numbers and symbols and store these either on an sd card or SPI flash device and create a "font engine" displaying the bitmaps as required.

obviously the real font engine using the set pixels of the font to display the numbers in the colour of choice would be more versatile and using less amount of memory would probably be a better choice, I just wonder how this is for speed.
Is there a big difference between displaying a bitmap array and creating/calculating the "bitmap" in runtime?
Guess I have to try it to see.
Hope this all makes sense :?
Any thoughts?

Cheers
Dietmar

inmarket
Posts: 89
Joined: Fri Jul 27, 2012 1:37 pm
Location: Brisbane, Australia

Re: Large fonts

Postby inmarket » Wed Mar 27, 2013 3:07 am

The current font rendering engine in GFX is a simple bitmap font solution. It is possible to supply your own fonts in your application code by including
#include "gdisp/fonts.h"
in your application and then defining your own font.

There are some limitations to this approach...
  • The maximum native font size is 16 bits. This can be increased to 32 bits by putting #define GDISP_MAX_FONT_HEIGHT 32 in your gfxconf.h. Note, doing this doubles the size of the in-built font tables.
  • Fonts can then be scaled using the x and Y scaling factor. This is pure bitmap scaling and therefore presents "jaggies" at larger scaling factors. I have found that scaling in the y direction is far more eye-pleasing than scaling in the x direction hence the standard range of "Narrow" fonts.
  • Generalised anti-aliasing is generally not an option for bitmap fonts as it requires the ability to be able to read the existing pixel colors from the display hardware. Very few GDISP drivers actually support this. A more specific anti-alias routine could be written for when the font is being displayed with a filled background however this has not yet been done.

The proper solution is to support scalable fonts such as truetype. Although the GDISP API allows for this to happen transparently to the application code - this is a lot of work and therefore hasn't been done yet. There may also be significant RAM usage constraints on this as most scalable font libraries I have seen to date are rather heavy on their use of RAM.

Loading of fonts from an SD-Card or such (whether bitmap or scalable) is also allowed for in the current API but not implemented yet.

In general, if adding some of these nice features to the GDISP font handling is not practical for you, the only solution is to create a GDISP native format bitmap image of each character you want and to use the gdispBlitAreaEx() function to display them.

SIDE NOTE: BMP, GIF, JPG image decoders and supporting display routines are coming soon. Until then you will need to use hardware native pixel array images.

Hope this helps.

User avatar
DeusExMachina
Posts: 223
Joined: Tue Apr 03, 2012 5:08 am
Location: South Korea
Has thanked: 3 times
Been thanked: 3 times

Re: Large fonts

Postby DeusExMachina » Sun Mar 31, 2013 2:39 pm

I want to use GFX in my future project - but I am afraid of bad suppot for cyrrilic fonts. Can I use non-ansii encoding? cp1251 or UTF8?

User avatar
Tectu
Posts: 1226
Joined: Thu May 10, 2012 9:50 am
Location: Switzerland
Contact:

Re: Large fonts

Postby Tectu » Sun Mar 31, 2013 3:44 pm

It's possible to do this. The current font implementation doesn't depend on any standard, they are simple bit arrays! Check it out here. Currently, the only restriction is that the fonts cannot have a larger height than 32px. Of course you can upscale them afterwards, but as this thread describes, it's not that nice.
The fonts have been generated using a font generator, I'm not sure if there are also generators for cyrillic fonts, but I'm quite sure that there must be something.


~ Tectu

Abhishek
Posts: 266
Joined: Wed May 23, 2012 3:15 pm
Location: India

Re: Large fonts

Postby Abhishek » Mon Apr 01, 2013 3:06 pm

I read about the Cyrillic charset and it seems a slight possibility that it could be supported within the current framework, because there are no compound characters (as in, two characters make up one visible alphabet e.g. for the Devanagari script in Hindi, my mother tongue) [Please correct me if I am wrong]. But the support I guess would be extending the ASCII character set in ChibiOS/GFX or will be some non-standard encoding.

Solution is libfreetype or something of that kind. Only that there is currently shortage of time (on my side) for making changes to the text rendering system. It does need a major revamp. I always consider a bitmap-based variable sized bitarray (not just 16-bit or 32-bit) as the proper solution for implementing fonts. This way we would not be restricted to just 32px high fonts but can think of bigger fonts too. But if we have to cover the Unicode charset, then I cannot think of anything else but libfreetype.

Let's see how it all turns out in the future. A revamp of the text rendering feature seems imminent.

Abhishek

User avatar
Tectu
Posts: 1226
Joined: Thu May 10, 2012 9:50 am
Location: Switzerland
Contact:

Re: Large fonts

Postby Tectu » Mon Apr 01, 2013 3:14 pm

Abhishek, afaik the currently implemented fonts in the ChibiOS/GFX repository come from you, right? Could you please tell us what font generator you used? Does it also support cyrillic characters?
Of course we need a complete rework of the font stuff, but as three people now already mentioned, it's not an easy job and it will be very time consuming. However, if anyone is willing to do this, I'd be very thankful for it.


~ Tectu


Return to “LCD Driver and Graphic Framework”

Who is online

Users browsing this forum: No registered users and 3 guests