Documentation ¶
Overview ¶
Package font provides types to describe and select text font faces.
Index ¶
Constants ¶
const ( Inch Length = 72 Centimeter = Inch / 2.54 Millimeter = Centimeter / 10 )
Common lengths.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cache ¶
type Cache struct {
// contains filtered or unexported fields
}
Cache collects font faces.
func NewCache ¶
func NewCache(coll Collection) *Cache
NewCache creates a new cache of fonts from the provided collection of font Faces. The first font Face in the collection is set to be the default one.
func (*Cache) Add ¶
func (c *Cache) Add(coll Collection)
Add adds a whole collection of font Faces to the font cache. If the cache is empty, the first font Face in the collection is set to be the default one.
type Collection ¶
type Collection []Face
Collection is a collection of fonts, regrouped under a common typeface.
type Extents ¶
type Extents struct { // Ascent is the distance that the text // extends above the baseline. Ascent Length // Descent is the distance that the text // extends below the baseline. The descent // is given as a positive value. Descent Length // Height is the distance from the lowest // descending point to the highest ascending // point. Height Length }
Extents contains font metric information.
type Face ¶
Face holds a font descriptor and the associated font face.
func (*Face) FontFace ¶
FontFace returns the opentype font face for the requested dots-per-inch resolution.
type Font ¶
type Font struct { // Typeface identifies the Font. Typeface Typeface // Variant is the variant of a font, such as "Mono" or "Smallcaps". Variant Variant // Style is the style of a font, such as Regular or Italic. Style font.Style // Weight is the weight of a font, such as Normal or Bold. Weight font.Weight // Size is the size of the font. Size Length }
Font represents a font face.
type Length ¶
type Length float64
Length is a unit-independent representation of length. Internally, the length is stored in postscript points.
func ParseLength ¶
ParseLength parses a Length string. A Length string is a possible signed floating number with a unit. e.g. "42cm" "2.4in" "66pt" If no unit was given, ParseLength assumes it was (postscript) points. Currently valid units are:
- mm (millimeter)
- cm (centimeter)
- in (inch)
- pt (point)
Directories ¶
Path | Synopsis |
---|---|
Package liberation exports the Liberation fonts as a font.Collection.
|
Package liberation exports the Liberation fonts as a font.Collection. |