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

     1  package esizer
     2  
     3  import "golang.org/x/image/font"
     4  import "golang.org/x/image/font/sfnt"
     5  import "golang.org/x/image/math/fixed"
     6  
     7  // The default [Sizer] used by etxt renderers. For more information
     8  // about sizers, see the documentation of the [Sizer] interface.
     9  type DefaultSizer struct{ buffer sfnt.Buffer }
    10  
    11  // Satisfies the [Sizer] interface.
    12  func (self *DefaultSizer) Metrics(font *Font, size fixed.Int26_6) font.Metrics {
    13  	return DefaultMetricsFunc(font, size, &self.buffer)
    14  }
    15  
    16  // Satisfies the [Sizer] interface.
    17  func (self *DefaultSizer) Advance(font *Font, glyphIndex GlyphIndex, size fixed.Int26_6) fixed.Int26_6 {
    18  	return DefaultAdvanceFunc(font, glyphIndex, size, &self.buffer)
    19  }
    20  
    21  // Satisfies the [Sizer] interface.
    22  func (self *DefaultSizer) Kern(font *Font, prevGlyphIndex GlyphIndex, currGlyphIndex GlyphIndex, size fixed.Int26_6) fixed.Int26_6 {
    23  	return DefaultKernFunc(font, prevGlyphIndex, currGlyphIndex, size, &self.buffer)
    24  }