Documentation ¶
Index ¶
- Constants
- func ClearCache()
- func FontFS() fs.FS
- func IsFontAvailable(name string) bool
- func ListFonts() []string
- type Face
- type FallbackVariant
- type Font
- func (f *Font) GetFace(size float64, style *FontStyle) (*Face, error)
- func (f *Font) GetMaxWidth() (fixed.Int26_6, error)
- func (f *Font) GetMonoFace(size float64, cellWidth int) (*Face, error)
- func (f *Font) IsMono() bool
- func (f *Font) MeasureString(s string, size float64, style *FontStyle) (fixed.Int26_6, error)
- func (f *Font) ToTrueType() (*truetype.Font, error)
- type FontStretch
- type FontStyle
- type FontWeight
Constants ¶
const ( AxisWeight = "wght" // Weight axis AxisWidth = "wdth" // Width axis AxisSlant = "slnt" // Slant axis AxisItalic = "ital" // Italic axis AxisOpticalSize = "opsz" // Optical size axis AxisTexture = "TXTR" // Texture healing AxisLigatures = "liga" // Ligatures )
Common variable font axis tags
Variables ¶
This section is empty.
Functions ¶
func IsFontAvailable ¶
IsFontAvailable is a super fast check to see if the given font is available on the system
Types ¶
type FallbackVariant ¶ added in v0.3.0
type FallbackVariant string
FallbackVariant represents the type of fallback font to use
const ( FallbackSans FallbackVariant = "sans" FallbackMono FallbackVariant = "mono" )
type Font ¶
type Font struct { Name string // Name of the font family Font *opentype.Font // Parsed font FilePath string // Path to the font file on disk Filename string // Name of the font file IsMonospace bool // Whether the font is monospaced Style FontStyle // Font style // contains filtered or unexported fields }
Font represents a loaded font
func GetFallback ¶
func GetFallback(variant FallbackVariant) (font *Font, err error)
GetFallback returns either JetBrainsMono or Inter as the fallback font
func GetFontVariants ¶
func (*Font) GetMaxWidth ¶ added in v0.7.0
GetMaxWidth returns the maximum glyph width in the font
func (*Font) GetMonoFace ¶ added in v0.7.0
GetMonoFace returns a font face that will render with fixed-width characters size is the desired font size in points cellWidth is the desired cell width in pixels (if 0, uses the font's natural maximum width)
func (*Font) MeasureString ¶ added in v0.7.0
MeasureString returns the width of a string in pixels
type FontStretch ¶ added in v0.7.0
type FontStretch int
FontStretch represents the width/stretch of a font
const ( StretchUltraCondensed FontStretch = iota + 1 StretchExtraCondensed StretchCondensed StretchSemiCondensed StretchNormal StretchSemiExpanded StretchExpanded StretchExtraExpanded StretchUltraExpanded )
type FontStyle ¶
type FontStyle struct { Weight FontWeight // Font weight Stretch FontStretch // Font width/stretch Italic bool // Whether the font is italic Underline bool // Whether the font should be underlined Mono bool // Whether the font is monospaced }
FontStyle represents the style of a font
type FontWeight ¶
type FontWeight int
FontWeight represents the weight of a font
const ( WeightThin FontWeight = iota + 1 // Thinnest font weight WeightExtraLight // Extra light font weight WeightLight // Light font weight WeightRegular // Regular (normal) font weight WeightMedium // Medium font weight WeightSemiBold // Semi-bold font weight WeightBold // Bold font weight WeightExtraBold // Extra bold font weight WeightBlack // Black font weight WeightHeavy // Heaviest font weight )
Font weight constants represent standard font weights from thin to heavy