util

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2023 License: AGPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Font

type Font struct {
	// name of the font
	Name string
	// weight for this variant of the font
	Weight string
	// source of the deflated font
	Source string
	// truetype parsed font
	Font *truetype.Font
	// contains filtered or unexported fields
}

func ParseFont

func ParseFont(deflatedFont deflated.DeflatedFont) *Font

parse an inflated font file to a Font struct

func (*Font) GetFontFace

func (f *Font) GetFontFace(dpi float64, size float64) FontFace

get the font face for a specific dpi and font size

uses a previously created font face if one exists for the dpi and size, otherwise creates a new one and stores it for future use

func (*Font) GetTextData

func (f *Font) GetTextData(face FontFace, text string) *TextInfo

calculates the text width and height for later use rendering the text

type FontFace

type FontFace struct {
	// font face used to render the text
	Face font.Face
	// font size
	Size float64
	// dpi
	DPI float64
}

type TextInfo

type TextInfo struct {
	// font face used to render the text
	FontFace FontFace
	// text to render
	Text string
	// width of the text
	Width int
	// height of the text
	Height int

	// min height point from the baseline
	HeightMin fixed.Int26_6
	// max height point from the baseline
	HeightMax fixed.Int26_6
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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