render – github.com/go-text/render Index | Files

package render

import "github.com/go-text/render"

Index

Types

type Renderer

type Renderer struct {
	// FontSize defines the point size of output text, commonly between 10 and 14 for regular text
	FontSize float32
	// PixScale is used to indicate the pixel density of your output target.
	// For example on a hi-DPI (or "retina") display this may be 2.0.
	// Default value is 1.0, meaning 1 pixel on the image for each render pixel.
	PixScale float32
	// Color is the pen colour for rendering
	Color color.Color
	// contains filtered or unexported fields
}

Renderer defines a type that can render strings to a bitmap canvas. The size and look of output depends on the various fields in this struct. Developers should provide suitable output images for their draw requests. This type is not thread safe so instances should be used from only 1 goroutine.

func (*Renderer) DrawShapedRunAt

func (r *Renderer) DrawShapedRunAt(run shaping.Output, img draw.Image, startX, startY int) int

DrawShapedRunAt will rasterise the given shaper run into the output image using font face referenced in the shaping. The text will be drawn starting at the startX, startY pixel position. Note that startX and startY are not multiplied by the `PixScale` value as they refer to output coordinates. The return value is the X pixel position of the end of the drawn string.

func (*Renderer) DrawString

func (r *Renderer) DrawString(str string, img draw.Image, face font.Face) int

DrawString will rasterise the given string into the output image using the specified font face. The text will be drawn starting at the left edge, down from the image top by the font ascent value, so that the text is all visible. The return value is the X pixel position of the end of the drawn string.

func (*Renderer) DrawStringAt

func (r *Renderer) DrawStringAt(str string, img draw.Image, x, y int, face font.Face) int

DrawStringAt will rasterise the given string into the output image using the specified font face. The text will be drawn starting at the x, y pixel position. Note that x and y are not multiplied by the `PixScale` value as they refer to output coordinates. The return value is the X pixel position of the end of the drawn string.

Source Files

bitmap.go render.go svg.go

Version
v0.1.1
Published
Apr 18, 2024
Platform
darwin/amd64
Imports
16 packages
Last checked
now

Tools for package owners.