Anyone have / or know of an external Flash Font Manager

I’m considering writing a font manager that will manage several fonts in external SPI flash. Has anyone already written one or knows of one I can start with ?

Scott,
I did something with fonts for my TI CC3200 based VO-96 Foot Pedal system. Basically:

  • Used dot factory on a Windows system to produce graphical font tables from Window’s truetype fonts. I make 4 sizes for each font (10, 12, 14, 16 points)
  • I wrote a c program I with Xcode on my Mac that includes these tables for all four sizes and writes them to a file (i.e. ariel.font) with the appropriate header and indices.
  • My display manager looks for the requested font in FRAM. If it is there, the font table and index for the requested size is loaded into memory and used for text display.
  • If the requested font is not in the FRAM, it is downloaded via my file messaging protocol from my VO-96 cloud service and written to FRAM. Then the previous step is repeated. A font file is around 38K bytes with the tables for the four sizes included within.

If this type of approach is along the lines you are thinking, I can send you my code. I also have some documentation.

Peter

3 Likes

Hi Peter, that’s awesome. Your implementation is much more sophisticated (going out to the cloud service) than what I was thinking and I’m not sure I have the extra RAM on the current core to support loading an entire font into SRAM.

I was planning on having either a file (containing all of the font tables) and flashing that to the external SPI flash on the Spark using dfu-util (I think there is a reference on this forum to being able to directly write that flash using dfu-util) or writing a program that will write/add fonts directly to the external flash.

Then I was going to write a flash font manager that scans the flash for fonts, builds a table that contains the names and SPI flash location of a GLCD font table.
The user would call setFont("name") to preload a small structure that contains the GLCD font info (basically everything except the character bitmaps). Then add hooks to the current gText driver to call the font manager for the character bitmap. The font manager would keep a cache of the bitmaps and if the character was not in the cache go out and fetch it from the external SPI flash.

This way I hope to provide an assortment of fonts with little memory footprint - at the expense of performance.

For my current app I have a font that is about 1cm tall, another about .5cm, and then a 12pt font. Can’t load them all w/ my code into flash so I was hoping this character cache handler will address the issue.

I only load the table and index for a single font/size to memory, so in that regard both approaches are similar. Dot factory puts the width in pixels in the index for each character, so only characters wider than 8 bits use two bytes. That saves a bit with larger sizes.

I’ll see what I can pull together and send to you. As always, make use of what you can and toss the rest :blush:

2 Likes

I just wanted to comment… reading the initial request I was not expecting such a “baller” reply :basketball: :sunglasses: Thanks for sharing @pra you \m/ rock \m/

1 Like

@pra - you rock once again! - you helped me out with the SPI DMA and now this!!

My document “The VO-96 Acoustic Guitar Pedal Gateway” contains a description about how I manage external font tables, and the various headers and indexes that keep them organized. This information is at pages 71-74 under the heading “Font Handling”.

1 Like

Scott,

@mtnscott Here is a writeup and my code to create font files and examples of how I use them. I’ll post here instead of directly emailing them in case others are interested. One word of caution is endian usage. As it happens, my Mac produces the same as the Arm, but that is not necessarily true for all systems.

Peter

2 Likes

@pra i realize this thread is several years old but wanted to see if these files are still available? I can’t seem to access them and would love to offload some font data.

If you message me your non particle email address, I’ll send the zipped folder as an attachment. All care but no responsibility; I haven’t played around with this in years:smile: