text_drawer

package
v0.0.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 27, 2025 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetImageBase64

func GetImageBase64(rgba image.Image) (image_base64 string)

func GetImageMD5

func GetImageMD5(rgba image.Image) (image_MD5 string)

func GetMaxTextLength

func GetMaxTextLength(text []string) (max_text_length int, count_line int)

func GetTextLength

func GetTextLength(text string) (length int)

func ImageToByte

func ImageToByte(rgba image.Image) (image_bytes []byte)

func ReadFontFile

func ReadFontFile(font_file_path string) (f *truetype.Font, err error)

func SaveImageToFile

func SaveImageToFile(rgba image.Image, file_path string)

Types

type OptionFunc

type OptionFunc func(*TextDrawer)

func WithChars

func WithChars(i int) OptionFunc

func WithDPI

func WithDPI(f float64) OptionFunc

func WithFontFile

func WithFontFile(s string) OptionFunc

func WithFontSize

func WithFontSize(f float64) OptionFunc

func WithHeight

func WithHeight(i int) OptionFunc

func WithHingting

func WithHingting(s string) OptionFunc

func WithOptions

func WithOptions(t TextDrawer) OptionFunc

func WithPadding

func WithPadding(i int) OptionFunc

func WithSpacing

func WithSpacing(f float64) OptionFunc

func WithWidth

func WithWidth(i int) OptionFunc

func WithWonb

func WithWonb(b bool) OptionFunc

type TextDrawer

type TextDrawer struct {
	DPI      float64 // screen resolution in Dots Per Inch
	FontFile string  // filename of the ttf font
	Hinting  string  // none | full
	FontSize float64 // font size in points
	Height   int     // image height in points
	Width    int     // image width in points
	Padding  int     // text left and right padding
	Chars    int     // chars displayed per line
	Spacing  float64 // line spacing
	Wonb     bool    // white text on a black background
}

func New

func New(options ...OptionFunc) *TextDrawer

func (*TextDrawer) TextToImage

func (t *TextDrawer) TextToImage(text []string) (rgba *image.RGBA, err error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL