googlefont

package
v0.1.109 Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ParsedFontFace

type ParsedFontFace struct {
	FontFamily string
	FontStyle  string
	FontWeight int
	Src        string
}

ParsedFontFace represents the properties extracted from a @font-face block.

func ParseGoogleFontsCss

func ParseGoogleFontsCss(css string) []ParsedFontFace

ParseGoogleFontsCss parses the CSS returned by Google Fonts and extracts @font-face blocks.

type Provider

type Provider struct {
	// contains filtered or unexported fields
}

Provider fetches font definitions from Google Fonts.

func NewProvider

func NewProvider(httpClient *http.Client) *Provider

NewProvider creates a new Provider.

func (*Provider) FontFamily

func (p *Provider) FontFamily(ctx context.Context, familyName string) (font.FontFamily, error)

FontFamily creates a FontFamily by fetching definitions from Google Fonts. Note: This function performs a blocking network call to fetch the CSS. In a real application, this might need to be async or cached appropriately, but for the purpose of creating a FontFamily definition, we need the URLs.

familyName: e.g. "Roboto", "Open Sans" axes: currently supported are "ital" and "wght". The implementation constructs a query to fetch all variants (ital/normal, weights 100-900) for simplicity or we can allow the user to specify.

For this first pass, we will just take the family name and try to fetch a broad range of styles/weights to populate the font family.

Jump to

Keyboard shortcuts

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