luapower / tr0

Unicode text rendering engine in Lua
http://luapower.com/tr0
0 stars 1 forks source link

Font LRU-cache instead of ref-counting #11

Open capr opened 5 years ago

capr commented 5 years ago

Currently fonts are ref-counted and a ref is kept by each glyph run, which ensures that a font is not unloaded as long as there are still words shaped with that font in the glyph run cache.

But this is not how the limited resources that the fonts consume (which is file handles for mmaped fonts and memory for mem-fonts) should be distributed among fonts.

Solution: get rid of ref-counting and use two LRU caches instead: 1) count-limited for mmapped fonts, 2) size-limited for heap-allocated fonts.