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'
Defering on HTML
>>> from googlefonts_markup import Font, FontSet
>>> font = Font(family_name="Noto Sans JP")
>>> font.css_tag(defer=True)
'<link href="https://fonts.googleapis.com/css2?family=Noto+Sans+JP" rel="preload" as="style" onload="this.onload=null;this.rel=\'stylesheet\'">'
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
Built Distribution
File details
Details for the file googlefonts-markup-0.4.0.tar.gz
.
File metadata
- Download URL: googlefonts-markup-0.4.0.tar.gz
- Upload date:
- Size: 7.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.0 CPython/3.9.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b4db0af31c8603de90de8281d4708719fb95f93367a3a34872b5c2ba9bd05f26 |
|
MD5 | d2a7a4500b079907a01783a39b9cecd6 |
|
BLAKE2b-256 | 91540a46e5c644cf111ee6bff14f7364a6774dfb970868c8ec3d295f7e1087a4 |
File details
Details for the file googlefonts_markup-0.4.0-py3-none-any.whl
.
File metadata
- Download URL: googlefonts_markup-0.4.0-py3-none-any.whl
- Upload date:
- Size: 7.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.0 CPython/3.9.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | bf218aca6f36ff66f51845ab1e6c6416d97b3388ba37c642eb91a008b6d79359 |
|
MD5 | 3a51ae64cb2452b9fb1f2c45407b32ef |
|
BLAKE2b-256 | 28bca2b4203070e82915556ace237482feedf43da8667abfc51762d795207701 |