Documentation ¶
Overview ¶
The freetype package provides a convenient API to draw text onto an image. Use the freetype/raster and freetype/truetype packages for lower level control over rasterization and TrueType parsing.
Index ¶
- Constants
- func ParseFont(b []byte) (*truetype.Font, error)
- func Pt(x, y int) raster.Point
- type Context
- func (c *Context) DrawString(s string, p raster.Point) (raster.Point, error)
- func (c *Context) PointToFix32(x float64) raster.Fix32
- func (c *Context) SetClip(clip image.Rectangle)
- func (c *Context) SetDPI(dpi float64)
- func (c *Context) SetDst(dst draw.Image)
- func (c *Context) SetFont(font *truetype.Font)
- func (c *Context) SetFontSize(fontSize float64)
- func (c *Context) SetHinting(hinting Hinting)
- func (c *Context) SetSrc(src image.Image)
- type Hinting
Constants ¶
const ( // NoHinting means to not perform any hinting. NoHinting = Hinting(truetype.NoHinting) // FullHinting means to use the font's hinting instructions. FullHinting = Hinting(truetype.FullHinting) )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Context ¶
type Context struct {
// contains filtered or unexported fields
}
A Context holds the state for drawing text in a given font and size.
func (*Context) DrawString ¶
DrawString draws s at p and returns p advanced by the text extent. The text is placed so that the left edge of the em square of the first character of s and the baseline intersect at p. The majority of the affected pixels will be above and to the right of the point, but some may be below or to the left. For example, drawing a string that starts with a 'J' in an italic font may affect pixels below and left of the point. p is a raster.Point and can therefore represent sub-pixel positions.
func (*Context) PointToFix32 ¶
PointToFix32 converts the given number of points (as in “a 12 point font”) into fixed point units.
func (*Context) SetFontSize ¶
SetFontSize sets the font size in points (as in “a 12 point font”).
func (*Context) SetHinting ¶
SetHinting sets the hinting policy.
Directories ¶
Path | Synopsis |
---|---|
The raster package provides an anti-aliasing 2-D rasterizer.
|
The raster package provides an anti-aliasing 2-D rasterizer. |
Package truetype provides a parser for the TTF and TTC file formats.
|
Package truetype provides a parser for the TTF and TTC file formats. |