txt2img

package
v1.2.4-fix1 Latest Latest
Warning

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

Go to latest
Published: Jan 25, 2022 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Overview

Package txt2img 文字转图片

Index

Constants

View Source
const (
	// FontPath 通用字体路径
	FontPath = "data/Font/"
	// FontFile 苹方字体
	FontFile = FontPath + "regular.ttf"
	// BoldFontFile 粗体苹方字体
	BoldFontFile = FontPath + "regular-bold.ttf"
	// SakuraFontFile ...
	SakuraFontFile = FontPath + "sakura.ttf"
	// ConsolasFontFile ...
	ConsolasFontFile = FontPath + "consolas.ttf"
)

Variables

This section is empty.

Functions

func RenderToBase64

func RenderToBase64(text, font string, width, fontSize int) (base64Bytes []byte, err error)

RenderToBase64 文字转base64

Types

type TxtCanvas added in v1.2.4

type TxtCanvas struct {
	Canvas *gg.Context
}

func Render

func Render(text, font string, width, fontSize int) (txtc TxtCanvas, err error)

Render 文字转图片 width 是图片宽度

func (TxtCanvas) ToBase64 added in v1.2.4

func (txtc TxtCanvas) ToBase64() (base64Bytes []byte, err error)

ToBase64 gg内容转为base64

func (TxtCanvas) ToBytes added in v1.2.4

func (txtc TxtCanvas) ToBytes() (data []byte, cl func())

ToBytes gg内容转为 []byte 使用完 data 后必须调用 cl 放回缓冲区

func (TxtCanvas) WriteTo added in v1.2.4

func (txtc TxtCanvas) WriteTo(f io.Writer) (n int64, err error)

WriteTo gg内容写入 Writer

Jump to

Keyboard shortcuts

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