github.com/Kintar/etxt@v0.0.0-20221224033739-2fc69f000137/ecache/doc.go (about)

     1  // The ecache subpackage defines the [GlyphCacheHandler] interface used
     2  // within etxt, provides a default cache implementation and exposes a
     3  // few more helper types to assist you if you want to implement your own.
     4  //
     5  // Since glyph rasterization is usually an expensive CPU process, caches are
     6  // a vital part of any real-time text rendering pipeline.
     7  //
     8  // As far as practical advice goes, "how to determine the size of my cache"
     9  // would be the main topic of discussion. Sadly, there's no good rule of
    10  // thumb to say "set your cache size to half its peak memory usage" or
    11  // similar. Cache sizes really depend on your use-case: sometimes you have
    12  // only a couple fonts at a few fixed sizes and you want your cache to fit
    13  // everything. Sometimes you determine your font sizes based on the current
    14  // screen size and can absolutely not pretend to cache all the masks that
    15  // the renderers may generate. The [DefaultCache.PeakSize]() function is
    16  // a good tool to assist you, but you will have to figure out your requirements
    17  // by yourself... or just set an arbitrary cache size like 16MB (16*1024*1024
    18  // bytes) and see how far does that get you.
    19  package ecache