text

package
v0.0.0-...-0e6b51b Latest Latest
Warning

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

Go to latest
Published: May 11, 2020 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TextAlignmentLeft      = 0
	TextAlignmentCenter    = 1
	TextAlignmentRight     = 2
	TextAlignmentJustified = 3
)
View Source
const (
	VerticalAlignmentTop    = 0
	VerticalAlignmentMiddle = 1
	VerticalAlignmentBottom = 2
)

Variables

This section is empty.

Functions

func AddFontLibrary

func AddFontLibrary(family string, library FontLibrary)

func AddFontLoad

func AddFontLoad(fn FontLoad)

func ColorFromString

func ColorFromString(v string) uint32

func Draw

func Draw(dst draw.Image, v *Layout, x, y, width, height float64, pleft float64, pright float64, textAlign TextAlignment)

func DrawString

func DrawString(F Font, dst draw.Image, u *image.Uniform, x, y float64, v string)

func GetFamilys

func GetFamilys() []string

func Load

func Load(path string)

func MeasureString

func MeasureString(F Font, v string) float64

Types

type Font

type Font interface {
	GetSize() float64
	GetFamily() string
	GetAscent() float64
	GetDescent() float64
	Index(vs []rune, i int) Index
	Kern(p, i Index) float64
	Width(i Index) float64
	Draw(i Index, dst draw.Image, u *image.Uniform, x, y, width, height float64) error
}

func NewFont

func NewFont(family string, size float64) (Font, error)

type FontLibrary

type FontLibrary func(family string, size float64) (Font, error)

type FontLoad

type FontLoad func(path string)

type Index

type Index interface {
	GetFont() Font
	GetLength() int
}

type Item

type Item struct {
	Style *Style
	Text  string
}

type Layout

type Layout struct {
	Rows []*LayoutRow
	// contains filtered or unexported fields
}

func NewLayout

func NewLayout(text *Text, maxWidth float64, dpi float64, lineSpacing float64) *Layout

func (*Layout) Height

func (L *Layout) Height() float64

func (*Layout) MaxWidth

func (L *Layout) MaxWidth() float64

func (*Layout) Text

func (L *Layout) Text() *Text

func (*Layout) Width

func (L *Layout) Width() float64

type LayoutItem

type LayoutItem struct {
	X      float64
	Y      float64
	Width  float64
	Height float64
	Loc    int
	Len    int
	Style  *Style
}

type LayoutRow

type LayoutRow struct {
	Y      float64
	Width  float64
	Height float64
	Loc    int
	Len    int
	Items  []*LayoutItem
}

func (*LayoutRow) Layout

func (R *LayoutRow) Layout()

type Style

type Style struct {
	Font              Font
	Color             uint32
	VerticalAlignment VerticalAlignment
	LetterSpacing     float64
}

type Text

type Text struct {
	// contains filtered or unexported fields
}

func NewText

func NewText() *Text

func (*Text) Add

func (T *Text) Add(text string, style *Style)

func (*Text) Each

func (T *Text) Each(fn func(vs []rune, i int, style *Style) int)

func (*Text) StringWithRange

func (T *Text) StringWithRange(loc int, length int) string

type TextAlignment

type TextAlignment int

func TextAlignmentFromString

func TextAlignmentFromString(v string) TextAlignment

func (TextAlignment) String

func (T TextAlignment) String() string

type VerticalAlignment

type VerticalAlignment int

func VerticalAlignmentFromString

func VerticalAlignmentFromString(v string) VerticalAlignment

Jump to

Keyboard shortcuts

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