本文整理汇总了Python中cairo.FONT_WEIGHT_NORMAL属性的典型用法代码示例。如果您正苦于以下问题:Python cairo.FONT_WEIGHT_NORMAL属性的具体用法?Python cairo.FONT_WEIGHT_NORMAL怎么用?Python cairo.FONT_WEIGHT_NORMAL使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类cairo
的用法示例。
在下文中一共展示了cairo.FONT_WEIGHT_NORMAL属性的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: label
# 需要导入模块: import cairo [as 别名]
# 或者: from cairo import FONT_WEIGHT_NORMAL [as 别名]
def label(self, txt, x, y, pt, c, center=True, rot=0.0, vcenter=False):
c = self.rgb1(c)
self.ctx.select_font_face(self.font, cairo.FONT_SLANT_NORMAL,
cairo.FONT_WEIGHT_NORMAL)
self.ctx.set_font_size(pt)
self.ctx.save()
self.ctx.translate(x, y)
self.ctx.rotate(math.radians(rot))
if center:
ext = self.ctx.text_extents(txt)
self.ctx.translate(-ext[2] / 2.0, 0.0)
if vcenter:
ext = self.ctx.text_extents(txt)
self.ctx.translate(0.0, -ext[3] / 2.0)
self.ctx.move_to(0, 0)
self.ctx.set_source_rgba(*c)
self.ctx.show_text(txt)
self.ctx.restore()
示例2: barCoord
# 需要导入模块: import cairo [as 别名]
# 或者: from cairo import FONT_WEIGHT_NORMAL [as 别名]
def barCoord(n):
'''
returns ((x-left-top, y-left-top),
(x-left-buttom, y-right-buttom),
(x-right-top, y-right-top),
(x-right-buttom, y-right-buttom))
coordinate of a bar area
'''
return ((100 + (n % 6) * 380, 430 + (n // 6) * 331), # left x-axis 100pt for margin blank
(100 + (n % 6) * 380, 430 + (n // 6) * 331 + 252), # top y-axis 430pt for title
(100 + (n % 6) * 380 + 380, 430 + (n // 6) * 331), # 252 is 1.5em for chord 1em * 3 for melody 56pt per em
(100 + (n % 6) * 380 + 380, 430 + (n // 6) * 331 + 252))
# ctx = cairo.Context(cairo.PDFSurface("haha.pdf", 2480.0, 3508.0))
# ctx.set_font_size(30)
# ctx.select_font_face("FreeSerif", cairo.FONT_SLANT_NORMAL,
# cairo.FONT_WEIGHT_NORMAL)
示例3: main
# 需要导入模块: import cairo [as 别名]
# 或者: from cairo import FONT_WEIGHT_NORMAL [as 别名]
def main():
ps = cairo.PDFSurface("pdffile.pdf", 504, 648)
cr = cairo.Context(ps)
cr.set_source_rgb(0, 0, 0)
cr.select_font_face("FreeSerif", cairo.FONT_SLANT_NORMAL,
cairo.FONT_WEIGHT_NORMAL)
cr.set_font_size(40)
cr.move_to(10, 50)
cr.show_text(chr(119046) +'1 2 3 4 5' + chr(119047) )
cr.set_line_width(11)
cr.move_to(100, 100)
cr.line_to(20, 300)
cr.show_page()
示例4: render
# 需要导入模块: import cairo [as 别名]
# 或者: from cairo import FONT_WEIGHT_NORMAL [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.
示例5: make_title
# 需要导入模块: import cairo [as 别名]
# 或者: from cairo import FONT_WEIGHT_NORMAL [as 别名]
def make_title(self):
ctx = cairo.Context(self.plots[-1].surface)
ctx.set_font_size(self.title_font_size)
ctx.select_font_face(self.title_font_family, cairo.FONT_SLANT_NORMAL,
cairo.FONT_WEIGHT_NORMAL)
ctx.set_source_rgba(*self.rgb1(self.hex2rgb(self.title_color)))
title_drawer = igraph.drawing.text.TextDrawer(
ctx, self.title_text, halign=igraph.drawing.text.TextDrawer.CENTER)
title_drawer.draw_at(0, 40, width=self.bbox.width)
示例6: fit_text
# 需要导入模块: import cairo [as 别名]
# 或者: from cairo import FONT_WEIGHT_NORMAL [as 别名]
def fit_text(self, txt, width, pt=24, padding=2):
overf = 1
while overf > 0:
self.ctx.select_font_face(self.font, cairo.FONT_SLANT_NORMAL,
cairo.FONT_WEIGHT_NORMAL)
self.ctx.set_font_size(pt)
overf = self.ctx.text_extents(txt)[2] - width + padding
pt *= 0.95
return pt
示例7: DrawChord
# 需要导入模块: import cairo [as 别名]
# 或者: from cairo import FONT_WEIGHT_NORMAL [as 别名]
def DrawChord(ThisPageChordList, CSF):
CSF.move_to(0, 0)
CSF.select_font_face("FreeSerif", cairo.FONT_SLANT_NORMAL,
cairo.FONT_WEIGHT_NORMAL)
CSF.move_to(100, 100)
CSF.set_font_size(80)
for i in ThisPageChordList:
CSF.show_text(i)
CSF.show_page()
示例8: draw
# 需要导入模块: import cairo [as 别名]
# 或者: from cairo import FONT_WEIGHT_NORMAL [as 别名]
def draw(self, context):
"""
Draw the widget. This method is called automatically. Don't call it
yourself. If you want to force a redrawing of the widget, call
the queue_draw() method.
@type context: cairo.Context
@param context: The context to draw on.
"""
label.begin_drawing()
chart.init_sensitive_areas()
rect = self.get_allocation() ###############
graph_rect = rect
graph_rect.y += 10
graph_rect.height -= 26
# Make the thing bigger
if (self.legend.get_property("visible") == True) and (self.legend.get_position() == POSITION_RIGHT):
graph_rect.width -= self.legend.last_width
self._range_calc.prepare_tics(graph_rect, self.xaxis, self.yaxis)
#initial context settings: line width & font
context.set_line_width(1)
font = gtk.Label().style.font_desc.get_family()
context.select_font_face(font,cairo.FONT_SLANT_NORMAL, cairo.FONT_WEIGHT_NORMAL)
# self.draw_basics(context, rect)
data_available = False
for (name, graph) in self.graphs.iteritems():
if graph.has_something_to_draw():
data_available = True
break
if self.graphs and data_available:
self.grid.draw(context, graph_rect, self.xaxis, self.yaxis) # This is the grid
self._do_draw_axes(context, graph_rect)
self._do_draw_graphs(context, graph_rect)
label.finish_drawing()
self.legend.draw(context, rect, self.graphs)
示例9: draw_grid
# 需要导入模块: import cairo [as 别名]
# 或者: from cairo import FONT_WEIGHT_NORMAL [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)