Icomoon manifest parser

class icomoon.store.WebfontStore(manifest_filename)[source]

Webfont store to collect every given manifest.

Store assume every webfont manifest file are located inside their webfont directory set in their fontdir_path option.

Store does not create any file, it just parse manifest and store icon maps.

Manifest filename is the same for every webfont, it is given as WebfontStore init argument manifest_filename, commonly selection.json.

Parameters:

manifest_filename (string) – Manifest filename to search for in webfont directory.

get_icon_key(elem)[source]

Return the icon name to be used as a sorting key

parse_manifest(fp)[source]

Open manifest JSON file and build icon map

Parameters:

fp (string or fileobject) – Either manifest filepath to open or manifest File object.

Returns:

Webfont icon map. Contains:

  • class_name: Builded icon classname with prefix configured in manifest (from parameters in Icomoon interface);

  • int: Icon integer code like 59649;

  • hex: Icon hexadecimal code like 0xe901;

  • unicode: Icon unicode like U+E901;

  • utf8: Icon UTF8 code like \e901;

Return type:

dict

get(webfont_name, webfont_settings)[source]

Get a manifest file, parse and store it.

Parameters:
  • webfont_name (string) – Webfont key name. Used to store manifest and potentially its parser error.

  • webfont_settings (dict) – Webfont settings (an item value from settings.ICOMOON_WEBFONTS).

fetch(webfonts)[source]

Store every defined webfonts.

Webfont are stored with sort on their name.

Parameters:

webfonts (dict) – Dictionnary of webfont settings from settings.ICOMOON_WEBFONTS.

get_manifests()[source]

Simple shortcut to get stored manifests.

Returns:

Stored webfont manifest.

Return type:

collections.OrderedDict