9fans.net/go@v0.0.5/draw/mkfont.go (about)

     1  package draw
     2  
     3  /*
     4   * Cobble fake font using existing subfont
     5   */
     6  
     7  // MakeFont creates a Font from an existing subfont. The first character of the
     8  // subfont will be rendered with rune value min.
     9  func (subfont *subfont) MakeFont(min rune) *Font {
    10  	font := &Font{
    11  		Display:  subfont.Bits.Display,
    12  		Name:     "<synthetic>",
    13  		namespec: "<synthetic>",
    14  		Height:   subfont.Height,
    15  		Ascent:   subfont.Ascent,
    16  		Scale:    1,
    17  		cache:    make([]cacheinfo, _NFCACHE+_NFLOOK),
    18  		subf:     make([]cachesubf, _NFSUBF),
    19  		age:      1,
    20  		sub: []*cachefont{{
    21  			min: min,
    22  			max: min + rune(subfont.N) - 1,
    23  		}},
    24  	}
    25  	font.subf[0].cf = font.sub[0]
    26  	font.subf[0].f = subfont
    27  	return font
    28  }