Fonts
Manage and load font choices.
add_font_choices_to_pdf(pdf, font_options)
Add font to choices to pdf.
Takes PDF instance and checks if the selected fonts are default fonts to FPDF2. If they are not default it takes the font location from the fonts.yaml file and adds the font under its name to the pdf.
Source code in report_generator/fonts.py
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 | |
check_if_default_font(font_name)
Check if choice is a default font.
Checks if the font_name passed into method is on the list of the 14 default fonts built into the PDF engine.
Returns:
| Type | Description |
|---|---|
bool
|
bool - Whether the font is a default font or not. |
Source code in report_generator/fonts.py
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 | |
font_dict_loader()
Load fonts from yaml file.
Show dict of font-name, font-location pairings based on yaml file in projects data/fonts directory.
Returns:
| Type | Description |
|---|---|
dict
|
font-dict (dict): dict of font-name, font-file-path str values. Used to select font choices or to add font to pdf. |
Source code in report_generator/fonts.py
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | |
font_selection_updater(chosen_fonts)
Update config.yaml with default font selection.
Takes a dict of chosen fonts and updates the config.yaml with the selection. Fonts included for: - Title Font, colour, font-size - Paragraph Font, colour, font-size - Heading Font, colour, font-size
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
chosen_fonts |
dict
|
Dict |
required |
Source code in report_generator/fonts.py
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 | |