github.com/Kintar/etxt@v0.0.0-20221224033739-2fc69f000137/esizer/sizer.go (about) 1 package esizer 2 3 import "golang.org/x/image/font" 4 import "golang.org/x/image/math/fixed" 5 6 // When drawing or traversing glyphs, we need some information 7 // related to the "font metrics". For example, how much we need 8 // to advance after drawing a glyph or what's the kerning between 9 // a specific pair of glyphs. 10 // 11 // Sizers are the interface that Renderers use to access that 12 // information. 13 // 14 // You rarely need to care about Sizers, but they can be useful 15 // in the following cases: 16 // - Disable kerning and adjust horizontal spacing. 17 // - Make full size adjustments for a custom rasterizer (e.g., 18 // a rasterizer that puts glyphs into boxes, bubbles or frames). 19 type Sizer interface { 20 Metrics(*Font, fixed.Int26_6) font.Metrics 21 Advance(*Font, GlyphIndex, fixed.Int26_6) fixed.Int26_6 22 Kern(*Font, GlyphIndex, GlyphIndex, fixed.Int26_6) fixed.Int26_6 23 24 // We could have a method for bounds too, but we 25 // don't need it in etxt, so it doesn't exist yet. 26 //Bounds(*Font, GlyphIndex, fixed.Int26_6, *sfnt.Buffer) fixed.Rect26_6 27 }