screentext

package module
v0.0.0-...-50a1415 Latest Latest
Warning

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

Go to latest
Published: Oct 4, 2014 License: MIT Imports: 6 Imported by: 0

README

This is a library for Go that draws text onto an image.Image. The text uses the underlying OS's text rendering system, so system fonts can be used. It is designed for rendering to the screen, so text is antialiased, etc.

It started as a more general-purpose vector graphics library, but technical restirctions and a general misunderstanding of the problem of vector graphics and device specificity made this unreasonable, so the scope was limited to just text strings. I plan on making a better vector graphics subsystem later.

It's sloppy :/

REQUIREMENTS

  • Windows: Windows XP or newer (same as Go); uses GDI
  • Unix (not Mac OS X): cairo (>=1.10) and pango (>=1.30)
  • Mac OS X: Mac OS X 10.6 or newer; uses Core Graphics and Core Text directly

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Line

func Line(text string, f Font, r uint8, g uint8, b uint8) *image.RGBA

Line draws the given line of text at the given position on the current Image in the given Font. The color is specified as an RGB value with no alpha information. TODO pango seems to do this vertically offset?

func LineSize

func LineSize(text string, f Font) (width int, height int)

LineSize computes the size that the given line of text would occupy in the given Font. The reported size is in pixels. It is a method of Image because some systems require a valid graphics drawing context (which Image provides) to make this calculation.

Types

type Font

type Font interface {
	// Close frees resources allocated to the Font.
	Close()
	// contains filtered or unexported methods
}

Font represents a font. A Font is created by passing a FontSpec to NewFont().

func NewFont

func NewFont(spec FontSpec) Font

NewFont creates a Font from the given FontSpec. TODO behavior if Size == 0

type FontSpec

type FontSpec struct {
	Family    string
	Size      uint // in points
	Bold      bool // TODO can it be a factor? if not, what constitutes bold?
	Italic    bool // italic == oblique if current backend differentiates
	Vertical  bool // strictly gravity east/rotation 90 degrees clockwise? TODO
	Monospace bool
}

FontSpec encodes information about a font.

func ListFonts

func ListFonts() []FontSpec

ListFonts computes a list of all fonts installed on the system. This recomputes the list on each call. The Size field of each returned Font shall be 0. Duplicates may be returned if information about the font is lost. TODO sort?

Jump to

Keyboard shortcuts

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