Adding more fonts is really just more of the same.
Well, except for the font-cache as there is only one font-cache.
So, first step, I checked what fonts I already had and in which sizes and decided to convert a Notosans to size 40.
Then I put everything in a new flash image:
unified.blob : 0 : 4096
Funtype_32_ASTC.glyph : 4096 : 145664
Funtype_32_ASTC.xfont : 149760 : 320
battery_white_176x384_COMPRESSED_RGBA_ASTC_8x8_KHR.raw : 150080 : 16896
Numbers_200x384_0_200x384_COMPRESSED_RGBA_ASTC_8x8_KHR.raw : 166976 : 19200
Numbers_200x384_1_200x384_COMPRESSED_RGBA_ASTC_8x8_KHR.raw : 186176 : 19200
Numbers_200x384_2_200x384_COMPRESSED_RGBA_ASTC_8x8_KHR.raw : 205376 : 19200
Numbers_200x384_3_200x384_COMPRESSED_RGBA_ASTC_8x8_KHR.raw : 224576 : 19200
Numbers_200x384_4_200x384_COMPRESSED_RGBA_ASTC_8x8_KHR.raw : 243776 : 19200
Numbers_200x384_5_200x384_COMPRESSED_RGBA_ASTC_8x8_KHR.raw : 262976 : 19200
Numbers_200x384_6_200x384_COMPRESSED_RGBA_ASTC_8x8_KHR.raw : 282176 : 19200
Numbers_200x384_7_200x384_COMPRESSED_RGBA_ASTC_8x8_KHR.raw : 301376 : 19200
Numbers_200x384_8_200x384_COMPRESSED_RGBA_ASTC_8x8_KHR.raw : 320576 : 19200
Numbers_200x384_9_200x384_COMPRESSED_RGBA_ASTC_8x8_KHR.raw : 339776 : 19200
NotoSans-Regular_40_ASTC.glyph : 358976 : 145664
NotoSans-Regular_40_ASTC.xfont : 504640 : 320
Inconsolata-Regular_24_ASTC.glyph : 504960 : 32384
Inconsolata-Regular_24_ASTC.xfont : 537344 : 320
Next I compressed the resulting .bin with the "Asset Compressor" and converted the .zlib with the "BIN2C" tool in EAB.
I changed tft_data.c and tft_data.h, activated the code to update the flash in TFT_init(), flashed my controller, waited a few seconds untill it started, deactivated the flash-update code again and flashed my controller again.
Well, yes, I could have used a USB/SPI adapter to flash .bin from EAB directly but I did not want to take it apart.
Anyways, it still worked like before which was the goal for the first step.
Next I reworked the memory map and added a couple of new defines for the fonts:
/* memory-map defines */
#define MEM_NUMBERS 0x00000000 /* start-address for 10 number images, ASTC 8x8, 200x384, 19200 / 0x4b00 bytes each */
#define MEM_BATTERY 0x0002ee00 /* start-address for a battery symbol, ASTC 8x8, 176x384, 16896 / 0x4200 bytes */
#define MEM_FONTCACHE 0x000ee000 /* needs to be 64 byte aligned and >16k */
#define MEM_FONT_INCON24 0x000fe840
#define MEM_FONT_FUN32 0x000fe980 /* the .xfont file for the UTF-8 font is copied here */
#define MEM_FONT_NOTO40 0x000feac0
#define MEM_LOGO 0x000fec00 /* start-address of logo, needs 784 bytes of memory */
#define MEM_DL_STATIC (EVE_RAM_G_SIZE - 4096) /* 0xff000 - start-address of the static part of the display-list, upper 4k of gfx-mem */
#define SIZE_FONTCACHE (MEM_FONT_INCON24 - MEM_FONTCACHE)
/* bitmap-handles */
#define FONT_INCON24 20
#define FONT_FUN32 21
#define FONT_NOTO040 22
I added the code to copy the extra .xfont files and switched the font-cache to the largets font:
EVE_cmd_flashread(MEM_FONT_INCON24, 537344, 320); /* copy .xfont from FLASH to RAM_G, offset and length are from the .map file */
EVE_cmd_flashread(MEM_FONT_FUN32, 149760, 320); /* copy .xfont from FLASH to RAM_G, offset and length are from the .map file */
EVE_cmd_flashread(MEM_FONT_NOTO40, 504640, 320); /* copy .xfont from FLASH to RAM_G, offset and length are from the .map file */
EVE_cmd_setfont2(FONT_NOTO040,MEM_FONT_NOTO40,32); /* assign bitmap handle to a custom font */
EVE_cmd_fontcache(FONT_NOTO040, MEM_FONTCACHE, SIZE_FONTCACHE);
EVE_cmd_dl(BITMAP_HANDLE(0));
In initStaticBackground() the fonts are assigned to their handles:
EVE_cmd_setfont2(FONT_INCON24,MEM_FONT_INCON24,32); /* assign bitmap handle to a custom font */
EVE_cmd_setfont2(FONT_FUN32,MEM_FONT_FUN32,32);
EVE_cmd_setfont2(FONT_NOTO040,MEM_FONT_NOTO40,32);
EVE_cmd_dl(BITMAP_HANDLE(0));
And the lines for the text output in the special fonts got changed as well:
EVE_cmd_text_burst(150, 490, FONT_INCON24, 0, "The quick brown fox jumps over the lazy dog!");
EVE_cmd_text_var_burst(180, 530, FONT_NOTO040, EVE_OPT_FORMAT, "Fontcache total: %d used: %d", 2, fonttotal, fontused);
And when I use FONT_FUN32 for the long text line EVE does not like that very much as the funtype 32 font no longer is cached.
So there are still limits, you can only cache one font and any uncached font needs to be either small enough to allow EVE to fetch all the glyphs in one line from the flash or you need to limit the amount of different glyphs in one line.
Why are alll the .xfont files the same size although these are completely different fonts?
I used the same charmap file for all three which limits the glyphs to a selected subset.
And my choice right now is this subset:
" !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~¡¢£¤¥¦§¨©ª«¬Â®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÃÂÃÄÅÆÇÈÉÊËÌÃÃŽÃÃÑÒÓÔÕÖ×ØÙÚÛÜÃÞßà áâãäåæçèéêëìÃîïðñòóôõö÷øùúûü"
As these are from the first two pages the .xfont file ends up with room for 256 glyphs even though only 187 are in the charmap file.