fontkit

package
v0.2.6 Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2023 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SetDefaultFontData

func SetDefaultFontData(regular, bold, italic, boldItalic []byte)

This function must be called before any use of fontkit

Types

type Face

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

func (*Face) DrawUnicodeBlockGlyph

func (face *Face) DrawUnicodeBlockGlyph(char rune, imgSize common.Vector2[int]) *image.RGBA

func (*Face) DrawUnicodeBoxGlyph

func (face *Face) DrawUnicodeBoxGlyph(char rune, imgSize common.Vector2[int]) *image.RGBA

func (*Face) ImageSize

func (face *Face) ImageSize() common.Vector2[int]

func (*Face) RenderChar

func (face *Face) RenderChar(char rune, underline, strikethrough bool, imgSize common.Vector2[int]) *image.RGBA

Renders given char to an RGBA image and returns. Also renders underline and strikethrough if specified.

func (*Face) RenderGlyph

func (face *Face) RenderGlyph(char rune, imgSize common.Vector2[int]) *image.RGBA

Renders given rune and returns rendered RGBA image. Width of the image is always equal to cellWidth or cellWidth*2

func (*Face) RenderUndercurl

func (face *Face) RenderUndercurl(imgSize common.Vector2[int]) *image.RGBA

This function renders an undercurl to an empty image and returns it. The undercurl drawing job is done in the shaders.

type FaceParams

type FaceParams struct {
	Size, DPI                      float64
	UseBoxDrawing, UseBlockDrawing bool
}

type Font

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

func CreateFontFromFile

func CreateFontFromFile(pathToFile string) (*Font, error)

func CreateFontFromMem

func CreateFontFromMem(data []byte) (*Font, error)

func (*Font) ContainsGlyph

func (font *Font) ContainsGlyph(char rune) bool

ContainsGlyph returns the whether font contains the given glyph.

func (*Font) CreateFace

func (f *Font) CreateFace(params FaceParams) (*Face, error)

This funtion may return a face previously created and used because it caches every face in the font and it also caches every image size. Caching and reusing makes this library incredibly fast and memory friendly. But creating so many faces and drawing multiple size of images every time increases memory usage. And this memory never be freed until the font has freed. (This is not leak)

func (*Font) FamilyName

func (font *Font) FamilyName() (string, error)

func (*Font) FilePath

func (font *Font) FilePath() string

type FontKit

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

FontKit is a struct that holds different styles of same font family TODO: Maybe we should make this safe for concurrent usage, currently not

func CreateKit

func CreateKit(fontname string) (*FontKit, error)

func Default

func Default() *FontKit

Returns default font kit, creates it if first time

func (*FontKit) Bold

func (fontkit *FontKit) Bold() *Font

func (*FontKit) BoldItalic

func (fontkit *FontKit) BoldItalic() *Font

func (*FontKit) DefaultFont

func (fontkit *FontKit) DefaultFont() *Font

Returns first non nil font starting from regular

func (*FontKit) Italic

func (fontkit *FontKit) Italic() *Font

func (*FontKit) Regular

func (fontkit *FontKit) Regular() *Font

func (*FontKit) SuitableFont

func (fontkit *FontKit) SuitableFont(bold, italic bool) *Font

Jump to

Keyboard shortcuts

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