font

package
v0.0.0-...-af996ba Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2019 License: MPL-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// PangoScale is a constant used by the Pango font engine.
	PangoScale = float64(C.PANGO_SCALE)
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Capitalization

type Capitalization C.PangoVariant

Capitalization is an enumeration of capitalization possibilities.

const (
	CapitalizationNormal Capitalization = C.PANGO_VARIANT_NORMAL
	CapitalizationSmall  Capitalization = C.PANGO_VARIANT_SMALL_CAPS
)

Possible capitalizations.

func (Capitalization) String

func (c Capitalization) String() string

String returns the name of the capitalization.

type Face

type Face struct {
	// contains filtered or unexported fields
}

Face represents a group of fonts with the same family, slant, weight, and width.

func (*Face) Font

func (f *Face) Font() *Font

Font returns the font representing this face. No size will have been set for the returned font.

func (*Face) Name

func (f *Face) Name() string

Name returns the name of the face.

func (*Face) String

func (f *Face) String() string

String returns the name of the face.

func (*Face) Synthesized

func (f *Face) Synthesized() bool

Synthesized returns true if the font synthesized from another variant.

type Family

type Family struct {
	// contains filtered or unexported fields
}

Family represents a family of related font faces. The faces in a family share a common design, but differ in slant, weight, width, and other aspects.

func Families

func Families() []*Family

Families returns the installed font families.

func MonospacedFamilies

func MonospacedFamilies() []*Family

MonospacedFamilies returns the installed font families that are monospaced.

func (*Family) Faces

func (f *Family) Faces() []*Face

Faces returns the faces that make up the family. The faces share a common design, but differ in slant, weight, width, and other aspects.

func (*Family) Monospaced

func (f *Family) Monospaced() bool

Monospaced returns true if the family has a fixed width.

func (*Family) Name

func (f *Family) Name() string

Name returns the name of the family.

func (*Family) String

func (f *Family) String() string

String returns the name of the family.

type Font

type Font struct {
	// contains filtered or unexported fields
}

Font represents a font.

var (
	// User is the font used by default for documents and other text under the user’s control
	// (that is, text whose font the user can normally change).
	User *Font
	// UserMonospaced is the font used by default for documents and other text under the user’s
	// control when that font is fixed-pitch.
	UserMonospaced *Font
	// System is the system font used for standard user-interface items such as window titles,
	// button labels, etc.
	System *Font
	// EmphasizedSystem is the system font used for emphasis in alerts.
	EmphasizedSystem *Font
	// SmallSystem is the standard small system font used for informative text in alerts,
	// column headings in lists, help tags, utility window titles, toolbar item labels, tool
	// palettes, tool tips, and small controls.
	SmallSystem *Font
	// SmallEmphasizedSystem is the small system font used for emphasis.
	SmallEmphasizedSystem *Font
	// Views is the font used as the default font of text in lists and tables.
	Views *Font
	// Label is the font used for labels.
	Label *Font
	// Menu is the font used for menus.
	Menu *Font
	// MenuCmdKey is the font used for menu item command key equivalents.
	MenuCmdKey *Font
)

func NewFont

func NewFont(str string) *Font

NewFont creates a font from a string.

func (*Font) Ascent

func (d *Font) Ascent() float64

Ascent returns the amount of space used from the baseline to the top of the tallest character.

func (*Font) BetterMatch

func (d *Font) BetterMatch(oldDesc *Font, newDesc *Font) bool

BetterMatch determines if the style attributes of newDesc are a closer match for this font than those of oldDesc are, or if oldDesc is nil, determines if newDesc is a match at all. Approximate matching is done for weight and style; other style attributes must match exactly. Style attributes are all attributes other than family and size-related attributes. Approximate matching for style considers SlantOblique and SlantItalic as matches, but not as good a match as when the slants are equal. Note that oldDesc must match this font or be nil.

func (*Font) Capitalization

func (d *Font) Capitalization() Capitalization

Capitalization returns the font capitalization.

func (*Font) Copy

func (d *Font) Copy() *Font

Copy makes a copy of a font.

func (*Font) Descent

func (d *Font) Descent() float64

Descent returns the amount of space used from the baseline to the bottom.

func (*Font) Dispose

func (d *Font) Dispose()

Dispose of the underlying OS resources.

func (*Font) Equals

func (d *Font) Equals(other *Font) bool

Equals compares two fonts for equality. Two fonts are considered equal if the fonts they describe are provably identical. This means that their masks do not have to match, as long as other fields are all the same. Two fonts may result in identical fonts being loaded, but still compare false.

func (*Font) Family

func (d *Font) Family() string

Family returns the family name. May be empty if it has not been set.

func (*Font) Height

func (d *Font) Height() float64

Height returns the overall height of the font, effectively Leading() + Ascent() + Descent().

func (*Font) IndexForPosition

func (d *Font) IndexForPosition(x float64, text string) int

IndexForPosition returns the rune index within the string for the specified x-coordinate, where 0 is the start of the string.

func (*Font) Leading

func (d *Font) Leading() float64

Leading returns the amount of space before the ascent.

func (*Font) Measure

func (d *Font) Measure(text string) geom.Size

Measure the string rendered with this font. If you want to account for transformations in a graphics context, you must use the Measure method on the Graphics object instead.

func (*Font) Monospaced

func (d *Font) Monospaced() bool

Monospaced returns true if this font has a fixed width.

func (*Font) PangoFontDescription

func (d *Font) PangoFontDescription() unsafe.Pointer

PangoFontDescription returns the pointer to the underlying Pango font description.

func (*Font) PositionForIndex

func (d *Font) PositionForIndex(index int, text string) float64

PositionForIndex returns the x-coordinate where the specified rune index starts. The returned coordinate assumes 0 is the start of the string.

func (*Font) SetCapitalization

func (d *Font) SetCapitalization(capitalization Capitalization)

SetCapitalization sets the font capitalization.

func (*Font) SetFamily

func (d *Font) SetFamily(family string)

SetFamily sets the family name.

func (*Font) SetSize

func (d *Font) SetSize(size float64)

SetSize sets the size of the font, in points.

func (*Font) SetSlant

func (d *Font) SetSlant(slant Slant)

SetSlant sets the font slant.

func (*Font) SetStretch

func (d *Font) SetStretch(stretch Stretch)

SetStretch sets the font stretch.

func (*Font) SetWeight

func (d *Font) SetWeight(weight Weight)

SetWeight sets the font weight.

func (*Font) Size

func (d *Font) Size() float64

Size the size of the font, in points.

func (*Font) Slant

func (d *Font) Slant() Slant

Slant returns the font slant.

func (*Font) Stretch

func (d *Font) Stretch() Stretch

Stretch returns the font stretch.

func (*Font) String

func (d *Font) String() string

String returns a string that can be used with NewFont.

func (*Font) Weight

func (d *Font) Weight() Weight

Weight returns the font weight.

type Slant

type Slant C.PangoStyle

Slant represents the angle that a font is skewed when drawn.

const (
	SlantNormal  Slant = C.PANGO_STYLE_NORMAL
	SlantOblique Slant = C.PANGO_STYLE_OBLIQUE
	SlantItalic  Slant = C.PANGO_STYLE_ITALIC
)

Possible font slant variants.

func (Slant) String

func (s Slant) String() string

String returns the name of the slant.

type Stretch

type Stretch C.PangoStretch

Stretch is an enumeration of stretch possibilities.

const (
	StretchUltraCondensed Stretch = C.PANGO_STRETCH_ULTRA_CONDENSED
	StretchExtraCondensed Stretch = C.PANGO_STRETCH_EXTRA_CONDENSED
	StretchCondensed      Stretch = C.PANGO_STRETCH_CONDENSED
	StretchSemiCondensed  Stretch = C.PANGO_STRETCH_SEMI_CONDENSED
	StretchNormal         Stretch = C.PANGO_STRETCH_NORMAL
	StretchSemiExpanded   Stretch = C.PANGO_STRETCH_SEMI_EXPANDED
	StretchExpanded       Stretch = C.PANGO_STRETCH_EXPANDED
	StretchExtraExpanded  Stretch = C.PANGO_STRETCH_EXTRA_EXPANDED
	StretchUltraExpanded  Stretch = C.PANGO_STRETCH_ULTRA_EXPANDED
)

Possible stretch values.

func (Stretch) String

func (s Stretch) String() string

String returns the name of the stretch.

type Weight

type Weight C.PangoWeight

Weight specifies the boldness of a font. It can range from 100 to 1000.

const (
	WeightThin       Weight = C.PANGO_WEIGHT_THIN
	WeightUltraLight Weight = C.PANGO_WEIGHT_ULTRALIGHT
	WeightLight      Weight = C.PANGO_WEIGHT_LIGHT
	WeightSemiLight  Weight = C.PANGO_WEIGHT_SEMILIGHT
	WeightBook       Weight = C.PANGO_WEIGHT_BOOK
	WeightNormal     Weight = C.PANGO_WEIGHT_NORMAL
	WeightMedium     Weight = C.PANGO_WEIGHT_MEDIUM
	WeightSemiBold   Weight = C.PANGO_WEIGHT_SEMIBOLD
	WeightBold       Weight = C.PANGO_WEIGHT_BOLD
	WeightUltraBold  Weight = C.PANGO_WEIGHT_ULTRABOLD
	WeightHeavy      Weight = C.PANGO_WEIGHT_HEAVY
	WeightUltraHeavy Weight = C.PANGO_WEIGHT_ULTRAHEAVY
)

Pre-defined weights.

func (Weight) String

func (c Weight) String() string

String returns the name of the weight, or a value from 100 to 1000 if the value doesn't match one of the pre-defined weights.

Jump to

Keyboard shortcuts

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