本文整理汇总了Python中cairo.FONT_SLANT_ITALIC属性的典型用法代码示例。如果您正苦于以下问题:Python cairo.FONT_SLANT_ITALIC属性的具体用法?Python cairo.FONT_SLANT_ITALIC怎么用?Python cairo.FONT_SLANT_ITALIC使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类cairo
的用法示例。
在下文中一共展示了cairo.FONT_SLANT_ITALIC属性的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: draw_grid
# 需要导入模块: import cairo [as 别名]
# 或者: from cairo import FONT_SLANT_ITALIC [as 别名]
def draw_grid(ctx, date):
"""
Draws the whole grid of 52x90 squares
"""
start_date = date
pos_x = X_MARGIN / 4
pos_y = pos_x
# Draw the key for box colours
ctx.set_font_size(TINYFONT_SIZE)
ctx.select_font_face(FONT, cairo.FONT_SLANT_NORMAL,
cairo.FONT_WEIGHT_NORMAL)
pos_x = draw_key_item(ctx, pos_x, pos_y, KEY_BIRTHDAY_DESC, BIRTHDAY_COLOUR)
draw_key_item(ctx, pos_x, pos_y, KEY_NEWYEAR_DESC, NEWYEAR_COLOUR)
# draw week numbers above top row
ctx.set_font_size(TINYFONT_SIZE)
ctx.select_font_face(FONT, cairo.FONT_SLANT_NORMAL,
cairo.FONT_WEIGHT_NORMAL)
pos_x = X_MARGIN
pos_y = Y_MARGIN
for i in range(NUM_COLUMNS):
text = str(i + 1)
w, h = text_size(ctx, text)
ctx.move_to(pos_x + (BOX_SIZE / 2) - (w / 2), pos_y - BOX_SIZE)
ctx.show_text(text)
pos_x += BOX_SIZE + BOX_MARGIN
ctx.set_font_size(TINYFONT_SIZE)
ctx.select_font_face(FONT, cairo.FONT_SLANT_ITALIC,
cairo.FONT_WEIGHT_NORMAL)
for i in range(NUM_ROWS):
# Generate string for current date
ctx.set_source_rgb(0, 0, 0)
date_str = date.strftime('%d %b, %Y')
w, h = text_size(ctx, date_str)
# Draw it in front of the current row
ctx.move_to(X_MARGIN - w - BOX_SIZE,
pos_y + ((BOX_SIZE / 2) + (h / 2)))
ctx.show_text(date_str)
# Draw the current row
draw_row(ctx, pos_y, start_date, date)
# Increment y position and current date by 1 row/year
pos_y += BOX_SIZE + BOX_MARGIN
date += datetime.timedelta(weeks=52)