Documentation
¶
Index ¶
- func DownloadCSS(ua FontProfile, fontFamily, fontStyle string, mirror *url.URL) ([]byte, error)
- func GetURL(ua FontProfile, fontFamily, fontStyle string, mirror *url.URL) string
- func UnmarshalCSS(cssBytes []byte, typefaces *Typefaces) error
- type FontProfile
- type Typeface
- type Typefaces
- func (ts *Typefaces) CSS() string
- func (ts *Typefaces) Family() []string
- func (ts *Typefaces) Format() []string
- func (ts *Typefaces) PrettyCSS() string
- func (ts *Typefaces) Select(format, family, style string, weight int) []Typeface
- func (ts *Typefaces) Style() []string
- func (ts *Typefaces) URL() []*url.URL
- func (ts *Typefaces) Weight() []int
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DownloadCSS ¶
DownloadCSS downloads font-face CSS from Google API
func GetURL ¶
func GetURL(ua FontProfile, fontFamily, fontStyle string, mirror *url.URL) string
GetURL returns the URL for font-face CSS from Google API
func UnmarshalCSS ¶
UnmarshalCSS unmarshals a byte slice to Typefaces
Types ¶
type FontProfile ¶
type FontProfile int
FontProfile is a font profile for specific devices and format
const ( // WOFF2 font format supported by most modern browsers WOFF2 FontProfile = iota // AppleWOFF2 is WOFF2 font format optimized for Apple devices AppleWOFF2 // LegacyWOFF2 is WOFF2 font format without support for Unicode range feature LegacyWOFF2 // AppleLegacyWOFF2 is WOFF2 font format optimized for Apple devices, without support for Unicode range feature AppleLegacyWOFF2 // WOFF font format supported by most modern browsers WOFF // AppleWOFF is WOFF font format optimized for Apple devices AppleWOFF // LegacyWOFF is WOFF font format without support for Unicode range feature LegacyWOFF // AppleLegacyWOFF is WOFF font format optimized for Apple devices, without support for Unicode range feature AppleLegacyWOFF // TTF is TTF font format TTF // AppleTTF is TTF font format optimized for Apple devices AppleTTF // SVG is SVG font format SVG // EOT is EOT font format EOT )
type Typeface ¶
type Typeface struct {
Format string `json:"format"`
Weight int `json:"weight"`
Family string `json:"family"`
Style string `json:"style"`
URL *url.URL `json:"url"`
UnicodeRange []string `json:"unicodeRange,omitempty"`
}
Typeface represents a font face
func (*Typeface) MarshalJSON ¶
MarshalJSON returns a JSON representation of Typeface
func (*Typeface) UnmarshalJSON ¶
UnmarshalJSON converts a JSON representation of Typeface to Typeface
type Typefaces ¶
type Typefaces struct {
Fonts []Typeface `json:"fonts"`
}
Typefaces represents a collection of Typeface
func (*Typefaces) CSS ¶
CSS returns the CSS for all fonts in the collection, in the most legacy compatible manner
Click to show internal directories.
Click to hide internal directories.