fontpreview modules¶
fontpreview¶
fontpreview module contains FontPreview class
-
class
fontpreview.fontpreview.
FontPreview
(font, font_size=64, font_text='a b c d e f', color_system='RGB', bg_color='white', fg_color='black', dimension=(700, 327))¶ Bases:
object
Class that represents the preview of a font
-
__init__
(font, font_size=64, font_text='a b c d e f', color_system='RGB', bg_color='white', fg_color='black', dimension=(700, 327))¶ Object that represents the preview of a font
- Parameters
font – font file
font_size – font size. Default is 64.
font_text – font text representation. Default is ‘a b c d e f’.
color_system – color system string. Default is ‘RGB’.
bg_color – background color of preview. Default is ‘white’.
fg_color – foreground or font color of preview. Default is ‘black’.
dimension – dimension of preview. Default is 700x327.
-
__str__
()¶ String representation of font preview
- Returns
string
-
__weakref__
¶ list of weak references to the object (if defined)
-
draw
(align='left')¶ Draw image with text based on properties of this object
- Parameters
align – alignment of text. Available ‘left’, ‘center’ and ‘right’
- Returns
None
-
save
(path='/home/docs/checkouts/readthedocs.org/user_builds/fontpreview/checkouts/latest/docs/source/fontpreview.png')¶ Save the preview font
- Parameters
path – path where you want to save the preview font
- Returns
None
-
set_font_size
(size)¶ Set size of font
- Parameters
size – size of font
- Returns
None
-
set_text_position
(position)¶ Set position of text
- Parameters
position – Position can be a tuple with x and y axis, or a string. The strings available are ‘center’, ‘top’, ‘below’, ‘rcenter’, ‘rtop’, ‘rbelow’, ‘lcenter’, ‘ltop’ and ‘lbelow’.
- Returns
None
-
show
()¶ Displays this image.
- Returns
None
-
fontbanner¶
fontbanner module contains FontBanner, FontLogo and FontWall class
Bases:
fontpreview.fontpreview.FontPreview
Class that represents the banner of a font
Object that represents the banner of a font
- Parameters
font – font file
orientation – the orientation of the banner; ‘landscape’, ‘portrait’ or tuple(x,y).
bg_color – background color of preview. Default is ‘white’.
fg_color – foreground or font color of preview. Default is ‘black’.
mode – the text inside the banner; ‘letter’,’fontname’, ‘paragraph’, ‘alpha’ and ‘combination’.
font_size – font size. Default is 64.
color_system – color system string. Default is ‘RGB’.
String representation of font banner
- Returns
string
Adds an additional image to the banner
- Parameters
image – path of image
position – position of image
- Returns
None
Set the text mode
- Parameters
mode – mode that sets the text in the banner
align – alignment of text. Available ‘left’, ‘center’ and ‘right’
- Returns
None
Set orientation of banner
- Parameters
orientation – the orientation of the banner; ‘landscape’ or ‘portrait’
font_position – font position respect dimension of banner
- Returns
None
Bases:
fontpreview.fontpreview.FontPreview
Class that represents the logo of a font
Object that represents the logo of a font
- Parameters
font – font file
letters – One or two letters (or anything)
size – size of logo square. Default is (100, 100)
bg_color – background color of preview. Default is ‘white’.
fg_color – foreground or font color of preview. Default is ‘black’.
font_size – font size. Default is 64.
color_system – color system string. Default is ‘RGB’.
Define new size of FontLogo object
- Parameters
size – size of fontlogo object
- Returns
None
Bases:
object
Class that represents the wall of fonts
Object that represents the wall of fonts
- Parameters
fonts – font list; string or FontPreview object
max_tile – maximum tile per row/column
mode – image alignment, ‘horizontal’ or ‘vertical’
String representation of font wall
- Returns
string
list of weak references to the object (if defined)
Draw wall with fonts on properties of this object
- Parameters
max_tile – maximum tile per row
- Returns
None
Save the font wall
- Parameters
path – path where you want to save the font wall
- Returns
None
Displays this image.
- Returns
None
Resize image
- Parameters
image – image to resize
bg_image – background image
- Returns
Image object
fontpage¶
fontpage module contains FontPage and FontPageTemplate class
-
class
fontpreview.fontpage.
FontBooklet
(*pages)¶ Bases:
object
Class that represents the booklet of a font page
-
__init__
(*pages)¶ Object that represents the booklet of a font page
- Parameters
pages – FontPage’s object
-
__iter__
()¶ Iterating on each FontPage
- Returns
next value
-
__weakref__
¶ list of weak references to the object (if defined)
-
save
(folder, extension='png')¶ Save on each FontPage image
- Parameters
folder – path folder where you want to save each font page
extension – extension of imge file. Default is ‘png’
- Returns
None
-
-
class
fontpreview.fontpage.
FontPage
(template=None, dimension=(2480, 3508), header=None, logo=None, body=None, footer=None)¶ Bases:
object
Class that represents the page of a font banners
-
__init__
(template=None, dimension=(2480, 3508), header=None, logo=None, body=None, footer=None)¶ Object that represents the page of a font banners
- Parameters
template – template used to build the page
dimension – dimension of page. Default A4 in pixels.
header – header of fontpage object
logo – logo of fontpage object on header part
body – body of fontpage object
footer – footer of fontpage object
-
__str__
()¶ String representation of font page
- Returns
string
-
__weakref__
¶ list of weak references to the object (if defined)
-
draw
(separator=True, sep_color='black', sep_width=5)¶ Draw font page with header, logo, body and footer
- Parameters
separator – line that separates the parts
sep_color – separator color
sep_width – separator width
- Returns
None
-
save
(path='/home/docs/checkouts/readthedocs.org/user_builds/fontpreview/checkouts/latest/docs/source/fontpage.png')¶ Save the font page
- Parameters
path – path where you want to save the font page
- Returns
None
-
set_body
(body)¶ Set body of Font page
- Parameters
body – FontPreview object
- Returns
None
Set footer of Font page
- Parameters
footer – FontPreview object
- Returns
None
-
set_header
(header)¶ Set header of Font page
- Parameters
header – FontPreview object
- Returns
None
-
set_logo
(logo)¶ Set logo of Font page
- Parameters
logo – FontLogo object
- Returns
None
-
show
()¶ Displays this image.
- Returns
None
-
-
class
fontpreview.fontpage.
FontPageTemplate
(page_height=3508, units_number=6)¶ Bases:
object
Class representing the template of a FontPage object
-
__init__
(page_height=3508, units_number=6)¶ Object representing the template of a FontPage object
- Parameters
page_height – height of FontPage object. Default is 3508.
units_number – division number to create the units
-
__str__
()¶ String representation of font page
- Returns
string
-
__weakref__
¶ list of weak references to the object (if defined)
-
set_body
(font_size, units, text_position)¶ Setting the body properties
- Parameters
font_size – the body font size
units – the body units number
text_position – the body text position
- Returns
None
Setting the footer properties
- Parameters
font_size – the footer font size
units – the footer units number
text_position – the footer text position
- Returns
None
-
set_header
(font_size, units, text_position)¶ Setting the header properties
- Parameters
font_size – the header font size
units – the header units number
text_position – the header text position
- Returns
None
-