882 views
in System Integration by
In order to control the memory consumption, the cache for font resources should be limited. How to achieve this?

1 Answer

0 votes
by

All single characters of your font resources (glyphs) are managed by the font cache of the Graphics Engine. All glyphs are loaded dynamically on request into this font cache. As long as there is enough space within the cache, all loaded glyphs remain within this cache, in order to avoid future reloading and decompressing of glyphs from the flash memory.
This article describes how to limit the size of the font glyph cache.

The font cache is a single surface with 8bit color depth - the size of the font cache is by default 512x512 pixel (= 256 kByte). This is suitable for projects using a large framebuffer (like FullHD).
In many other cases, the size of the font cache can be reduced. The absolute minimum of the font cache is 128x128 pixel. This means, that the font cache can be reduced to a size of 16 kByte.
This saves 240 kByte of memory!!!
To do this, just define the macros EW_MAX_GLYPH_SURFACE_WIDTH and EW_MAX_GLYPH_SURFACE_HEIGHT within your project/makefile.
Alternatively, the macros can be defined in your 'ewextgfx.h' file.
For example:

#ifndef EW_MAX_GLYPH_SURFACE_WIDTH
  #define EW_MAX_GLYPH_SURFACE_WIDTH   128
#endif

#ifndef EW_MAX_GLYPH_SURFACE_HEIGHT
  #define EW_MAX_GLYPH_SURFACE_HEIGHT  128
#endif

Don't forget to recompile your project after appending the macro definition. Also please note, that the cache exists for performance reasons. The reduction of the cache size may thus affect the performance of your GUI application. In particular the slow decompression of glyphs will be repeated more frequently if the cache is too small.

Ask Embedded Wizard

Welcome to the question and answer site for Embedded Wizard users and UI developers.

Ask your question and receive answers from the Embedded Wizard support team or from other members of the community!

Embedded Wizard Website | Privacy Policy | Imprint

...