render

package
v0.0.0-...-42d8158 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2020 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Text

func Text(text string, opts ...Option) (image.Image, error)

Text renders text as large as possible, without exceeding the maximum size.

Types

type FontFunc

type FontFunc func(size float64) (font.Face, error)

FontFunc returns a new font face of the given point size.

Points are 1/72 of an inch. https://en.wikipedia.org/wiki/Point_(typography)

type ImageFunc

type ImageFunc func(image.Rectangle) draw.Image

type Option

type Option option

func WithFont

func WithFont(fn FontFunc) Option

WithFont sets the font used.

By default, the Go Regular font is used.

func WithFontOpenType

func WithFontOpenType(f *opentype.Font, opts *opentype.FaceOptions) Option

WithFontOpenType is a convenience helper for WithFont that uses an OpenType font.

Unlike opentype.NewFace, a FaceOptions value must be provided. FaceOptions.Size is overwritten by this function.

func WithImageFunc

func WithImageFunc(fn ImageFunc) Option

WithImageFunc sets the function used to create an image of the desired size.

By default, image.NewGray is used.

func WithMaxHeight

func WithMaxHeight(h int) Option

WithMaxHeight sets maximum height for rendered text, in pixels.

This option is mandatory.

Jump to

Keyboard shortcuts

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