font

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jan 21, 2024 License: MIT, Unlicense Imports: 1 Imported by: 1

Documentation

Overview

Package font provides type describing font faces attributes.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Face

type Face interface {
	Face() font.Face
}

Face is an opaque handle to a typeface. The concrete implementation depends upon the kind of font and shaper in use.

type Font

type Font struct {
	// Typeface specifies the name(s) of the the font faces to try. See [Typeface]
	// for details.
	Typeface Typeface
	// Style specifies the kind of text style.
	Style Style
	// Weight is the text weight.
	Weight Weight
}

Font specify a particular typeface variant, style and weight.

type FontFace

type FontFace struct {
	Font Font
	Face Face
}

A FontFace is a Font and a matching Face.

type Style

type Style int

Style is the font style.

const (
	Regular Style = iota
	Italic
)

func (Style) String

func (s Style) String() string

type Typeface

type Typeface string

Typeface identifies a list of font families to attempt to use for displaying a string. The syntax is a comma-delimited list of family names. In order to allow for the remote possibility of needing to express a font family name containing a comma, name entries may be quoted using either single or double quotes. Within quotes, a literal quotation mark can be expressed by escaping it with `\`. A literal backslash may be expressed by escaping it with another `\`.

Here's an example Typeface:

Times New Roman, Georgia, serif

This is equivalent to the above:

"Times New Roman", 'Georgia', serif

Here are some valid uses of escape sequences:

"Contains a literal \" doublequote", 'Literal \' Singlequote', "\\ Literal backslash", '\\ another'

This syntax has the happy side effect that most CSS "font-family" rules are valid Typefaces (without the trailing semicolon).

Generic CSS font families are supported, and are automatically expanded to lists of known font families with a matching style. The supported generic families are:

  • fantasy
  • math
  • emoji
  • serif
  • sans-serif
  • cursive
  • monospace

type Weight

type Weight int

Weight is a font weight, in CSS units subtracted 400 so the zero value is normal text weight.

const (
	Thin       Weight = -300
	ExtraLight Weight = -200
	Light      Weight = -100
	Normal     Weight = 0
	Medium     Weight = 100
	SemiBold   Weight = 200
	Bold       Weight = 300
	ExtraBold  Weight = 400
	Black      Weight = 500
)

func (Weight) String

func (w Weight) String() string

Directories

Path Synopsis
Package gofont exports the Go fonts as a text.Collection.
Package gofont exports the Go fonts as a text.Collection.
Package opentype implements text layout and shaping for OpenType files.
Package opentype implements text layout and shaping for OpenType files.

Jump to

Keyboard shortcuts

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