DrawText draws the specified text on a new, tightly fitting image, and returns a pointer to the image.
(text string)
| 205 | |
| 206 | // DrawText draws the specified text on a new, tightly fitting image, and returns a pointer to the image. |
| 207 | func (f *Font) DrawText(text string) *image.RGBA { |
| 208 | |
| 209 | width, height := f.MeasureText(text) |
| 210 | img := image.NewRGBA(image.Rect(0, 0, width, height)) |
| 211 | draw.Draw(img, img.Bounds(), f.bg, image.ZP, draw.Src) |
| 212 | f.DrawTextOnImage(text, 0, 0, img) |
| 213 | |
| 214 | return img |
| 215 | } |
| 216 | |
| 217 | // DrawTextOnImage draws the specified text on the specified image at the specified coordinates. |
| 218 | func (f *Font) DrawTextOnImage(text string, x, y int, dst *image.RGBA) { |
no test coverage detected