googlefonts-markup 0.4.0

Last updated:

0 purchases

googlefonts-markup 0.4.0 Image
googlefonts-markup 0.4.0 Images
Add to Cart

Description:

googlefontsmarkup 0.4.0

Warning
This is alpha library


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


Usage

Note
WIP


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

License:

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Customer Reviews

There are no reviews.