Skip to main content

Small utility to use Google Fonts for markup files

Project description

Overview

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

Usage

Simple case

>>> from googlefonts_markup import Font
>>> noto_sans_jp = Font(family_name="Noto Sans JP")
>>> noto_sans_jp.css_url()
'https://fonts.googleapis.com/css2?family=Noto+Sans+JP'
>>> noto_sans_jp.css_tag()
'<link href="https://fonts.googleapis.com/css2?family=Noto+Sans+JP" 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")
'https://fonts.googleapis.com/css2?family=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()
'https://fonts.googleapis.com/css2?family=Red+Hat+Mono:ital,wght@1,400'

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()
'https://fonts.googleapis.com/css2?family=Noto+Sans+JP&display=swap'

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()
'https://fonts.googleapis.com/css2?family=Noto+Sans+JP&family=Roboto+Mono&display=swap'

Installation

pip install git+https://github.com/attakei-lab/googlefonts-markup

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.1.0.tar.gz (6.9 kB view hashes)

Uploaded Source

Built Distribution

googlefonts_markup-0.1.0-py3-none-any.whl (7.3 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