本文整理汇总了Python中cairo.FONT_WEIGHT_BOLD属性的典型用法代码示例。如果您正苦于以下问题:Python cairo.FONT_WEIGHT_BOLD属性的具体用法?Python cairo.FONT_WEIGHT_BOLD怎么用?Python cairo.FONT_WEIGHT_BOLD使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类cairo
的用法示例。
在下文中一共展示了cairo.FONT_WEIGHT_BOLD属性的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: render
# 需要导入模块: import cairo [as 别名]
# 或者: from cairo import FONT_WEIGHT_BOLD [as 别名]
def render(self, cr, where, w, h):
cr.save()
# Clip to permissible area
cr.rectangle(where[0], where[1], w, h)
cr.clip()
# Draw first line
cr.set_source_rgb(0, 0, 0)
cr.select_font_face("Sans", cairo.FONT_SLANT_NORMAL,
cairo.FONT_WEIGHT_BOLD)
cr.set_font_size(3.0)
cr.move_to(where[0]+3, where[1]+5)
cr.show_text(" ".join(self.refs))
# Draw second line
cr.select_font_face("Sans", cairo.FONT_SLANT_NORMAL,
cairo.FONT_WEIGHT_NORMAL)
cr.set_font_size(3.0)
cr.move_to(where[0]+3, where[1]+9)
cr.show_text("{}x {} {}"
.format(len(self.refs), self.value, self.footprint))
# Draw third line
cr.select_font_face("Sans", cairo.FONT_SLANT_NORMAL,
cairo.FONT_WEIGHT_NORMAL)
cr.set_font_size(3.0)
cr.move_to(where[0]+3, where[1]+12)
cr.show_text("{} {}".format(self.supplier, self.code))
cr.restore()
# Forever yields a new (x, y) of successive label top-left positions,
# calling cr.show_page() when the current page is exhausted.
示例2: draw
# 需要导入模块: import cairo [as 别名]
# 或者: from cairo import FONT_WEIGHT_BOLD [as 别名]
def draw(self,context):
context.set_source_rgb(256,256,256)
context.select_font_face("Courier", cairo.FONT_SLANT_NORMAL,
cairo.FONT_WEIGHT_BOLD)
context.set_font_size(FONTSIZE)
(x, y, width, height, dx, dy) = context.text_extents(self.c)
context.move_to(self.p.x*16 - width/2, self.p.y*16 - height/2)
context.scale(1,-1)
context.show_text(self.c)
context.scale(1,-1)
context.stroke()
示例3: gen_calendar
# 需要导入模块: import cairo [as 别名]
# 或者: from cairo import FONT_WEIGHT_BOLD [as 别名]
def gen_calendar(start_date, title, filename):
if len(title) > MAX_TITLE_SIZE:
raise ValueError("Title can't be longer than %d characters"
% MAX_TITLE_SIZE)
# Fill background with white
surface = cairo.PDFSurface (filename, DOC_WIDTH, DOC_HEIGHT)
ctx = cairo.Context(surface)
ctx.set_source_rgb(1, 1, 1)
ctx.rectangle(0, 0, DOC_WIDTH, DOC_HEIGHT)
ctx.fill()
ctx.select_font_face(FONT, cairo.FONT_SLANT_NORMAL,
cairo.FONT_WEIGHT_BOLD)
ctx.set_source_rgb(0, 0, 0)
ctx.set_font_size(BIGFONT_SIZE)
w, h = text_size(ctx, title)
ctx.move_to((DOC_WIDTH / 2) - (w / 2), (Y_MARGIN / 2) - (h / 2))
ctx.show_text(title)
# Back up to the last monday
date = start_date
while date.weekday() != 0:
date -= datetime.timedelta(days=1)
# Draw 52x90 grid of squares
draw_grid(ctx, date)
ctx.show_page()