package freetype
import "github.com/goki/freetype"
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) fixed.Point26_6
- type Context
- func NewContext() *Context
- func (c *Context) DrawString(s string, p fixed.Point26_6) (fixed.Point26_6, error)
- func (c *Context) PointToFixed(x float64) fixed.Int26_6
- func (c *Context) SetClip(clip image.Rectangle)
- func (c *Context) SetDPI(dpi float64)
- func (c *Context) SetDst(dst draw.Image)
- func (c *Context) SetFont(f *truetype.Font)
- func (c *Context) SetFontSize(fontSize float64)
- func (c *Context) SetHinting(hinting font.Hinting)
- func (c *Context) SetSrc(src image.Image)
Constants ¶
const ( Version = "v1.0.2" GitCommit = "08ab4e6" // the commit JUST BEFORE the release VersionDate = "2024-01-18 18:34" // UTC )
Functions ¶
func ParseFont ¶
ParseFont just calls the Parse function from the freetype/truetype package. It is provided here so that code that imports this package doesn't need to also include the freetype/truetype package.
func Pt ¶
Pt converts from a co-ordinate pair measured in pixels to a fixed.Point26_6 co-ordinate pair measured in fixed.Int26_6 units.
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 NewContext ¶
func NewContext() *Context
NewContext creates a new Context.
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 fixed.Point26_6 and can therefore represent sub-pixel positions.
func (*Context) PointToFixed ¶
PointToFixed converts the given number of points (as in "a 12 point font") into a 26.6 fixed point number of pixels.
func (*Context) SetClip ¶
SetClip sets the clip rectangle for drawing.
func (*Context) SetDPI ¶
SetDPI sets the screen resolution in dots per inch.
func (*Context) SetDst ¶
SetDst sets the destination image for draw operations.
func (*Context) SetFont ¶
SetFont sets the font used to draw text.
func (*Context) SetFontSize ¶
SetFontSize sets the font size in points (as in "a 12 point font").
func (*Context) SetHinting ¶
SetHinting sets the hinting policy.
func (*Context) SetSrc ¶
SetSrc sets the source image for draw operations. This is typically an image.Uniform.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
raster | Package raster provides an anti-aliasing 2-D rasterizer. |
truetype |
- Version
- v1.0.2
- Published
- Jan 18, 2024
- Platform
- darwin/amd64
- Imports
- 7 packages
- Last checked
- now –
Tools for package owners.