Jump to content

How can I put the customer font file in a external spi flash?


jayjiang

Recommended Posts

Using a font in SPI flash would not be directly feasible. The reason is that SPI flash is very slow and fast memory based access is required when the system is drawing the font. There are therefore two solutions to your problem...

1. Load the font from SPI flash into RAM. Whilst we have now provided the ugfx api function to add fonts from RAM we have not added the functions to load a font into RAM as there are fixups and relocations that need to occur. There might be old third party code on the forum to help with this but we have never tested it. Adding an official uGFX api for this second part is on the todo list but is not currently high priority.

2. Filter the range of characters during the font conversion to reduce its size. Antialiasing a font also increases its size so turn that off too. The font can then be integrated in the normal fashion.

Unfortunately large fonts will always be large on any platform and fast access is required for drawing. I hope this helps provide some tips to make them work for you.

Link to comment
Share on other sites

All font files require space to encode. Large Chinese fonts are exactly that - large no matter how you encode them.

It really then comes done to two factors, the number of glyphs and the efficiency of encoding.

With uGFX the number of glyphs can be controlled by using the glyph filtering capabilities of the font encoder. The web interface allows a single filtering range but the command line utility allows unlimited filter ranges. I suspect this is where your problem lies - you are not sufficiently filtering the glyphs in your font to reduce the size. Particularly for Chinese fonts this is very important. 

With regard to efficiency, ugfx supports a couple of encoding schemes. Different schemes provide different results for various fonts. Particularly look at rle as that is likely to be the most efficient scheme.

With regard to the xbf font format, yes it allows fonts to be used that don't fit in RAM. The RAM overheads for that however are still significant. The big problem with xbf fonts is that they require dynamic loading of font data while drawing. For SPI flash this is unacceptably slow especially for sparse character sets such as Chinese. Yes large fonts can be used but the price is unacceptable performance.

xbf is a reasonable format to use if you have fast flash storage. uGFX in the same situation however does one better, the uGFX font can be stored entirely in addressable flash, has zero RAM usage and does not have the speed overhead problems that the xbf format has. So, the only downside to the uGFX format is that it can't be directly operated out of non-addressable memory such as SPI flash. The xbf alternative whilst it will work in that situation will have performance so bad that it is totally unacceptable in real life.

The best solution for your problem is proper filtering and encoding of your font.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...