Welcome to gensty’s documentation!¶
GenSty is a LaTex style package generator for OpenType fonts (otf/ttf) which supports W3C SMuFL notation. With gensty you can generate your LaTeX package based on any OpenType font; the generator parses ttf/otf files and creates LaTeX commands for all Unicode Symbols. In the case of SMuFL fonts, you can also include the glyphnames.json file, so it will create friendlier names and include “Private Use” symbols.
genSty¶
GenSty is a LaTex style package generator for OpenType fonts (otf/ttf) which supports W3C SMuFL notation. With gensty you can generate your LaTeX package based on any OpenType font; the generator parses ttf/otf files and creates LaTeX commands for all Unicode Symbols. In the case of SMuFL fonts, you can also include the glyphnames.json file, so it will create friendlier names and include “Private Use” symbols.
Installation (manual)¶
Clone the repository
git clone git@github.com:tsotsos/genSty.git
and then use from the top folder. Eg.
python3 -m gensty -h
Usage¶
As referred above, the package can be used directly, installed from pip, and as a module. In case of command line the script can be used :
gensty -h
usage: genSty [-h] [--version] [--all] [--smufl SMUFL]
[--one-package ONE_PACKAGE] [--author AUTHOR] [--ver VER]
path
LaTeX Style file generator for fonts
positional arguments:
path Font(s) path. It can be either a directory in case of
multiple fonts or file path.
optional arguments:
-h, --help show this help message and exit
--version, -v show program's version number and exit
--all, -a If choosed genSty will generate LaTeX Styles for all
fonts in directory
--smufl SMUFL, -s SMUFL
If choosed genSty will generate LaTeX Styles for all
fonts in directory based on glyphnames provided.
--one-package ONE_PACKAGE
Creates one package with name provided by this
argument.
--author AUTHOR Author's name.
--ver VER LaTeX package version.
Use as a module¶
import gensty
# To create all style packages from a folder or fontfile (path). use
# makePackage().
# Optional arguments: version, author and smufl.
# smufl is path to glyphnames.json which is defined according to Specifications
# https://www.w3.org/2019/03/smufl13/specification/glyphnames.html
fontpaths, files = gensty.makePackage(path, version, author, smufl)
# if you want to save style packages in a folder use:
gensty.savePackage(fontpaths,files)
Contributing¶
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Helpers¶
Gensty helpers. A collection of functions to manipulate strings, search for files and create folders.
-
gensty.helpers.
ReplaceToken
(dict_replace, target)[source]¶ ReplaceToken. Based on dict, replaces key with the value on the target.
- Parameters
dict_replace (dict) – Dictionary includes tokens to replace.
target (str) – String to be replced.
- Returns
String with provided parameters from tokens.
- Return type
str
-
gensty.helpers.
checkExtension
(path, ext)[source]¶ checkExtension. Defines if a file exists and having the given extension.
- Parameters
path (str) – File path to check.
ext (str) – File extension.
- Returns
True in case extension is correct.
- Return type
bool
-
gensty.helpers.
checkFont
(path, supported_fonts=[])[source]¶ checkFont. Checks the provided file has one fo the supported extensions.
- Parameters
path (str) – File path to check.
supported_fonts (list) – Supported fonts extensions
- Returns
True in case font exists.
- Return type
bool
-
gensty.helpers.
createDir
(dir)[source]¶ createDir. Forces directory creation by removing any pre-existing folder with same name.
- Parameters
dir (str) – Directory to create.
-
gensty.helpers.
findByExt
(path, ext)[source]¶ findByExt.Finds file by extension. Returns list.
- Parameters
path (str) – File path to check.
ext (str) – File extension.
- Returns
A list of files having the given ext or False.
- Return type
Union
[List
[str
],bool
]
-
gensty.helpers.
fixString
(s)[source]¶ fixString. Changes a string usually package or font name, so it can be use in LaTeX and parsed without issue.
- Parameters
s (str) – String to be fixed.
- Return type
str
-
gensty.helpers.
getFontsByType
(path, supported_fonts=[])[source]¶ getFontsByType. Gets supported fonts by file extesion in a given folder.
- Parameters
path (str) – Directory includes fonts.
supported_fonts (list) – A list of supported fonts (extensions)
- Returns
File paths of supported fonts.
- Return type
List
[str
]