Font Style
Learn of the different font styles.
We'll cover the following...
In addition to the normal font style, the text is displayed in italic or bold styles. These styles are applied via optional parameters when we create the font.
FontSlant
This is how we can create italic fonts:
Press + to interact
import cairo# Set up surfacesurface = cairo.ImageSurface(cairo.FORMAT_RGB24, 600, 400)ctx = cairo.Context(surface)ctx.set_source_rgb(0.8, 0.8, 0.8)ctx.paint()# Select fontctx.set_font_size(50)ctx.set_source_rgb(0, 0, 0)ctx.select_font_face('Times', cairo.FontSlant.NORMAL)ctx.move_to(100, 100)ctx.show_text("Normal")ctx.select_font_face('Times', cairo.FontSlant.ITALIC)ctx.move_to(100, 200)ctx.show_text("Italic")ctx.select_font_face('Times', cairo.FontSlant.OBLIQUE)ctx.move_to(100, 300)ctx.show_text("Oblique")
The first example creates normal ...