BRT Community

Please login or register.

Login with username, password and session length
Advanced search  

News:

Welcome to the Bridgetek Community!

Please read our Welcome Note

Technical Support enquires
please contact the team
@ Bridgetek Support

Please refer to our website for detailed information on all our products - Bridgetek - Bridging Technology

Author Topic: Speeding up font conversion  (Read 12810 times)

Rudolph

  • Sr. Member
  • ****
  • Posts: 389
    • View Profile
Speeding up font conversion
« on: April 22, 2019, 08:38:06 PM »

https://www.fontsquirrel.com/tools/webfont-generator
The resulting notosans-regular-webfont.ttf only has 222 glyphs.

Then I converted the font using the EVE Asset Builder.
ASTC block footprints: Auto
Compression Speed: thorough
Addr of Font Data: FLASH

I did this for font-sizes of 12, 14, 16, 18 and 20.

At first I converted all fonts to FLASH address 4096.
Then I put together a flash file, putting .glyph and .xfont files in pairs in it:

notosans-regular-webfont_12_4096.glyph               : 4096   : 119936
notosans-regular-webfont_12_4906.xfont               : 124032 : 5056
notosans-regular-webfont_14_129088.glyph             : 129088 : 120064
notosans-regular-webfont_14_129088.xfont             : 249152 : 5056
notosans-regular-webfont_16_254208.glyph             : 254208 : 269760
notosans-regular-webfont_16_254208.xfont             : 523968 : 5056
notosans-regular-webfont_18_529024.glyph             : 529024 : 270016
notosans-regular-webfont_18_529024.xfont             : 799040 : 5120
notosans-regular-webfont_20_4096.glyph               : 804160 : 180032
notosans-regular-webfont_20_804160.xfont             : 984192 : 5120
chipsie_40x56_40x56_COMPRESSED_RGBA_ASTC_8x8_KHR.raw : 989312 : 576

Then I redid the .xfont files by re-compressing the fonts in "veryfast" for the addresses.

I wrote a litte test code, put in the numbers and got five lines of cmd_text() output.
Ah yes, I copied all the .xfont data to graphics memory and I used bitmap-handles 10...14.

Now, the problem was, only the first and the last line were okay, the other three had broken chars.

So I re-compressed the 14/16/18 fonts again in "thorough" for these addresses and replaced all files.

Now the third and the fourth line still have broken chars. And in different places.

So I started to hack this into a spreadsheet.
All the addresses are 64 byte aligned.

Then I tried to read notosans-regular-webfont_16_254208.xfont with a hex-editor.
0x0100aaff - signature
0x00001395 - size of 5013, gen-flash rounds that up to 5056 which is a multiple of 64
0x000093b5 - format
0x0000024a - swizzle
0x00000030 - width
0x00000006 - height
0x00000018 - pixel width
0x0000001e - pixel height
0x00801f08 - start -> 0x1f08 = 254208
0x00010000 - num of glyphs -> 65536 - this is wrong and the one other font (184 glyphs) I checked also had this number
gptr/wptr/widh data - not sure how to really interpret these

Now, what else could I try to put a bunch of fonts into the FLASH?

And on a side-note, the amount of bitmap-handles really is a tad bit low, having annother 32 at least would be nice.

« Last Edit: April 23, 2019, 12:48:10 AM by Rudolph »
Logged

Rudolph

  • Sr. Member
  • ****
  • Posts: 389
    • View Profile
Re: Speeding up font conversion
« Reply #1 on: May 20, 2019, 05:49:01 PM »

I almost forgot that I put this here, it has been a couple of weeks since I had time to try this.

I still would really like to know how it is possible to place more than one font into the external flash.

And I re-checked it again, there are no updates available, no newer datasheet, no newer user-guide, no newer asset-builder.
Can we please get some updates, please?

I saw there even is a beta-section for things to test out - only empty.
Logged

BRT Community

  • Administrator
  • Hero Member
  • *****
  • Posts: 734
    • View Profile
Re: Speeding up font conversion
« Reply #2 on: May 22, 2019, 10:56:39 AM »

Hi Rudolph,

Thanks for your feedback. We'll discuss the broken chars with our development team and get back to you.

One thing to mention is that the Asset Builder has a feature where it can re-calculate the addresses of the fonts in the bin file. When generating the flash in the 'Generate Flash' tab, if you have the .xfont file with the same name in the same folder as the glyph file, it will adjust the data address of the font accordingly. This means you don't need to re-convert the fonts a second time and will save a lot of time.

Best Regards,
BRT Community

Logged

Rudolph

  • Sr. Member
  • ****
  • Posts: 389
    • View Profile
Re: Speeding up font conversion
« Reply #3 on: May 22, 2019, 06:56:06 PM »

One thing to mention is that the Asset Builder has a feature where it can re-calculate the addresses of the fonts in the bin file. When generating the flash in the 'Generate Flash' tab, if you have the .xfont file with the same name in the same folder as the glyph file, it will adjust the data address of the font accordingly. This means you don't need to re-convert the fonts a second time and will save a lot of time.

Now this is really interesting, thank you Graham!  :)

I tested it and it changes a 16 bit word at offset 0x20 of the .xfont file, both in the original file and
in the flash image.
This puzzled me at first, this is the start of graphics data.
But instead of the absolute address it is the number of a block the size of 32 bytes, just like what BITMAP_SOURCE
is used with to display a picture from FLASH.
So 0x0080011e at offset 0x20 means that is in FLASH at address 0x11e * 0x20 = 0x23c0.
And the following glyph adresses are all relative to this start address.

Nice, so most of what I tried to get a number of fonts into FLASH was pointless since the adress
we use the "Generate Font" tool pratically becomes meaningless when we use "Generate Flash".
I like that.

Unfortunately, with this working as intended, I have no idea left why my fonts are not working.

And since I also used the "User Guide" while playing with the EVE Asset Builder, I noticed that it does not
match version 0.4.2.
It appears to be written for 0.4.1. and there have been some changes to the Asset Builder that did not make
it into the "User Guide".
Logged

Rudolph

  • Sr. Member
  • ****
  • Posts: 389
    • View Profile
Re: Speeding up font conversion
« Reply #4 on: May 26, 2019, 11:52:00 AM »

I converted the notosans-regular-webfont.ttf I generated to sizes from 13 to 30 now.
I used the EVE Asset Builder 0.4.2 with its default settings and only changed the font-size from one conversion to the next.
ASTC block footprints: auto
Compression Speed: thorough
Addr of Font Data: FLASH 4096

I put all the .glyph and .xfont files in a flash image and placed an image at the end.
My programm first copies the .xfont files to G-RAM using cmd_flashread.
In the display-list my programm used cmd_setfont2 to assign bitmap handles to the custom fonts.
And finally my programm prints out the same text ten times with different fonts.
The first 9 lines are font-sizes 13 to 21, the last line is with internal font 28.
The image is displayed directly from FLASH.

I was prepared to add my files as attachments but I could not attach them all: Restrictions: 4 per post, maximum total size 192KB, maximum individual size 128KB

The high-res version of Font_Test_4.jpg is 1,09MB and the zipped Font-Test_4.bin is 219kB.

The notosans-regular-webfont.ttf is the version of the notosans-regular.ttf from Google that I stripped down to only 222 Glyphs.
This is purely attached for testing purposes and in no way meant as redistribution for anything else but testing.


Logged

BRT Community

  • Administrator
  • Hero Member
  • *****
  • Posts: 734
    • View Profile
Re: Speeding up font conversion
« Reply #5 on: May 27, 2019, 02:51:29 PM »

Hi Rudolph,

Thanks for your reply. Could you please send us the files in to the support email address support.emea@brtchip.com and we'll try them out here?

Best Regards,
BRT Community

Logged

Rudolph

  • Sr. Member
  • ****
  • Posts: 389
    • View Profile
Re: Speeding up font conversion
« Reply #6 on: May 27, 2019, 08:34:38 PM »

Sent out a bunch of files.
Logged

BRT Community

  • Administrator
  • Hero Member
  • *****
  • Posts: 734
    • View Profile
Re: Speeding up font conversion
« Reply #7 on: May 29, 2019, 09:22:14 AM »

Thanks Rudolph,
We got the files and we'll try it out here.
Best Regards, BRT Community
Logged