Documentation ¶
Overview ¶
Package gfonts provides bindings for the Google Fonts Developer API.
Index ¶
- Constants
- Variables
- type APIResponse
- type Family
- type Response
- func (r *Response) Categories(valid ...string) *Response
- func (r *Response) Filter(fn func(Family) bool) *Response
- func (r *Response) Styles(valid ...string) *Response
- func (r *Response) Subsets(valid ...string) *Response
- func (r *Response) Trim(n int) *Response
- func (r *Response) URLs() (files []download.File)
- func (r *Response) UnmarshalJSON(b []byte) error
Constants ¶
const ( SortAlpha = "alpha" SortDate = "date" SortPopularity = "popularity" SortStyle = "style" SortTrending = "trending" )
Sort modes for the API
Variables ¶
var ( SortModes = []string{SortAlpha, SortDate, SortPopularity, SortStyle, SortTrending} ErrNoKey = errors.New("empty API key") )
Functions ¶
This section is empty.
Types ¶
type APIResponse ¶
type APIResponse struct { Kind string `json:"kind"` Items []struct { Kind string `json:"kind"` Family string `json:"family"` Category string `json:"category"` Version string `json:"version"` LastModified string `json:"lastModified"` Subsets []string `json:"subsets"` Variants []string `json:"variants"` Files map[string]string `json:"files"` } `json:"items"` }
type Family ¶
type Family struct { Name string Category string Version string LastModified time.Time Subsets []string // Fonts is a map of style to URL Fonts map[string]string }
Family is a collection of font styles.
type Response ¶
type Response []Family
Response is a slice of Family, satisfies json.Unmarshaler and download.Interface.
func (*Response) Categories ¶
Categories filters out fonts that are not in any of those categories. Passing no valid categories will not filter out anything.
func (*Response) Styles ¶
Styles filters out fonts that don't have any of the valid styles. The returned response will only have valid styles. Passing no valid styles will not filter out anything.
func (*Response) Subsets ¶
Subsets filters out fonts that don't have any of the valid subsets. Passing no valid subsets will not filter out anything.
func (*Response) Trim ¶
Trim response down to len(response) == n. Passing n <= 0 or n > len(response) will not trim anything.
func (*Response) UnmarshalJSON ¶
UnmarshalJSON satisfies json.Unmarshaler.