Skip to main content

Small utility to use Google Fonts for markup files

Project description


This is small utility to handle specs of Google Fonts in my products.


Simple case

>>> from googlefonts_markup import Font
>>> noto_sans_jp = Font(family_name="Noto Sans JP")
>>> noto_sans_jp.css_url()
>>> noto_sans_jp.css_tag()
'<link href="" rel="stylesheet">'

If you want only URL of CSS, use googlefonts_markup.shortcuts.

>>> from googlefonts_markup.shortcuts import font_css_url
>>> font_css_url("Noto Sans JP")

With italic

>>> from googlefonts_markup import Axis, Font
>>> red_hat_mono = Font(family_name="Red Hat Mono", axis_list=[Axis(italic=True)])
>>> red_hat_mono.css_url()

Extra attributes

>>> from googlefonts_markup import Font, FontSet
>>> noto_sans_jp = Font(family_name="Noto Sans JP")
>>> fontset = FontSet(fonts=[noto_sans_jp], display="swap")
>>> fontset.css_url()

Multiple fonts

>>> from googlefonts_markup import Font, FontSet
>>> noto_sans_jp = Font(family_name="Noto Sans JP")
>>> roboto_mono = Font(family_name="Roboto Mono")
>>> fontset = FontSet(fonts=[noto_sans_jp, roboto_mono], display="swap")
>>> fontset.css_url()

Defering on HTML

>>> from googlefonts_markup import Font, FontSet
>>> font = Font(family_name="Noto Sans JP")
>>> font.css_tag(defer=True)
'<link href="" rel="preload" as="style" onload="this.onload=null;this.rel=\'stylesheet\'">'


pip install git+

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

googlefonts-markup-0.4.0.tar.gz (7.5 kB view hashes)

Uploaded Source

Built Distribution

googlefonts_markup-0.4.0-py3-none-any.whl (7.9 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page