pdfme.fonts
- class pdfme.fonts.PDFFont(ref)
Bases:
abc.ABC
Abstract class that represents a PDF font.
- Parameters
ref (str) – the name of the font, included in every paragraph and page that uses this font.
- property ref
Property that returns the name (ref) of this font.
- Returns
the name of this font
- Return type
str
- abstract property base_font
Abstract property that should return this font’s base font name.
- Returns
the base font name
- Return type
str
- abstract get_char_width(char)
Abstract method that should return the width of
char
character in this font.- Parameters
char (str) – the character.
- Returns
the character’s width.
- Return type
float
- abstract get_text_width(text)
Abstract method that should return the width of the
text
string in this font.- Parameters
text (str) – the sentence to measure.
- Returns
the sentence’s width.
- Return type
float
- class pdfme.fonts.PDFStandardFont(ref, base_font, widths)
Bases:
pdfme.fonts.PDFFont
This class represents a standard PDF font.
- Parameters
ref (str) – the name of this font.
base_font (str) – the base font name of this font.
widths (dict) – the widths of each character in this font.
- property base_font
- get_char_width(char)
- get_text_width(text)
- add_font(base)
- class pdfme.fonts.PDFTrueTypeFont(ref, filename=None)
Bases:
pdfme.fonts.PDFFont
This class represents a TrueType PDF font.
This class is not working yet.
- Parameters
ref (str) – the name of this font.
base_font (str) – the base font name of this font.
widths (dict) – the widths of each character in this font.
- property base_font
- get_char_width(char)
- get_text_width(text)
- load_font(filename)
Method to extract information needed by the PDF document about this font, from font file in
filename
path.- Parameters
filename (str) – font file path.
- Raises
ImportError – if
fonttools
library is not installed.
- add_font(base)
- class pdfme.fonts.PDFFonts
Bases:
object
Class that represents the set of all the fonts added to a PDF document.
- get_font(font_family, mode)
Method to get a font from its
font_family
andmode
.- Parameters
font_family (str) – the name of the font family
mode (str) – the mode of the font you want to get.
n
,b
,i
orbi
.
- Returns
an object that represents a PDF font.
- Return type
- load_font(path, font_family, mode='n')
Method to add a TrueType font to this instance.
- Parameters
path (str) – the location of the font file.
font_family (str) – the name of the font family
mode (str, optional) – the mode of the font you want to get.
n
,b
,i
orbi
.