google

package
v0.0.0-...-90067c2 Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2023 License: MIT Imports: 13 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetFontBytes

func GetFontBytes(ctx context.Context, family string, variant string, cache fonts.Cache) ([]byte, error)

Get the []byte of a font variant ctx context.Context: To possibly cancel the http request. family: the font family e.g. "Open Sans". variant: the font variant e.g. "700". cache: A cache implementation to prevent duplicate request if reusing fonts. Use nil to disable. Returns ErrUnknownFont if the font family is not found, or ErrMissingVariant if the font family does not contain that variant

func GetFontDetails

func GetFontDetails(ctx context.Context, family string) (*fonts.Font, error)

Get the details of a font: family, category, available variants, e.t.c No http request is made. The font details are embeded in the package Returns ErrUnknownFont if the font family is not found

func Proxy

func Proxy(path string) http.Handler

The proxy return a http.Handler that will proxy all requests to the Google Fonts server it take a path, which is used when generating the urls of the font bytes For example, if you want to proxy requests on `example.com/fonts`:

http.Handle("/fonts", http.StripPrefix("/fonts", google.Proxy("/fonts")))

Types

This section is empty.

Jump to

Keyboard shortcuts

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