Font rendering optimisations
Jeffrey Lee (213) 6048 posts |
A couple of weeks ago while tweaking some code I found myself looking at the font rendering code in the font manager. I made a few simple performance tweaks straight away, but I think there’s still a lot of room for improvement. I’m not expecting to find the time to look into this myself any time soon, so I thought I’d throw it out there for any other interested parties:
Have fun! |
Colin (478) 2433 posts |
Top of my list for font manager improvements by a long long way would be for Font_Paint to display and Font_ScanString to measure the ‘Replacement character code’ (unicode &FFFD) when using a font/encoding that doesn’t have a glyph for the character. e.g. if a font doesn’t have an ‘A’ then character code 65 in a string displays the replacement character code glyph which, according to wikipedia, is often a white question mark in a black diamond. |
Adrian Lees (1349) 122 posts |
Before anybody spends too much time looking at Fonts02 rendering optimisations, I have a confession. I’ve been sitting on ix-directed performance optimisations such as Jeffrey’s suggested suppression of needless screen access for some time. I’ll feed them back to ROOL along with the R-Pi work, for the – belated – benefit of other builds too. |
Chris Evans (457) 1614 posts |
I’d had a thought before Adrian’s posting which probably makes it reduntant and I could well have got the wrong end of the stick anyway, but I’ll mention just in case: |
Jeffrey Lee (213) 6048 posts |
That’s basically what the non-blended font code does already. You specify the font foreground and background colours and then it produces a 16 entry palette/lookup table for blending the font against that background. Any well-written program should hopefully be smart enough to disable font blending whenever it knows it’s plotting against a specific background colour. For 16bpp and 32bpp font blending I don’t think using lookup tables would help at all (except perhaps for precomputing the 16 levels of font colour). Full blending tables would simply be too big to be worth computing. For 8bpp blended fonts the code currently uses a lookup table to convert each pixel to 16bpp, blends that, and then uses another lookup table to convert back to 8bpp. This could be made a lot faster if it was changed to use just one lookup table that blends against a specific font colour. The only trouble is it would need recalculating each time the font colour changes, so to avoid rebuilding tables too often you might need to store tables for the N most recently used colours (Each table would have 4096 entries, so building a lookup table would be roughly equivalent to plotting 4096 pixels using the old code). |
Chris Evans (457) 1614 posts |
I should have guessed it was more complicated than I thought. Thanks for the explanation. |
Michael Drake (88) 336 posts |
The non-blended font rendering optimisations by Adrian have now been added . |