本文整理匯總了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()