d2font

package
v0.0.0-...-7f92c57 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2021 License: GPL-3.0 Imports: 7 Imported by: 3

Documentation

Overview

Package d2font contains logic for loading and processing d2 fonts

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Font

type Font struct {
	Glyphs map[rune]*d2fontglyph.FontGlyph
	// contains filtered or unexported fields
}

Font represents a displayable font

func Load

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

Load loads a new font from byte slice

func (*Font) GetTextMetrics

func (f *Font) GetTextMetrics(text string) (width, height int)

GetTextMetrics returns the dimensions of the Font element in pixels

func (*Font) Marshal

func (f *Font) Marshal() []byte

Marshal encodes font back into byte slice

func (*Font) RenderText

func (f *Font) RenderText(text string, target d2interface.Surface) error

RenderText prints a text using its configured style on a Surface (multi-lines are left-aligned, use label otherwise)

func (*Font) SetBackground

func (f *Font) SetBackground(sheet d2interface.Animation)

SetBackground sets font's background

func (*Font) SetColor

func (f *Font) SetColor(c color.Color)

SetColor sets the fonts color

Directories

Path Synopsis
Package d2fontglyph represents a single font glyph
Package d2fontglyph represents a single font glyph

Jump to

Keyboard shortcuts

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