Python cairo.FONT_WEIGHT_NORMAL Examples
The following are 9
code examples of cairo.FONT_WEIGHT_NORMAL().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
cairo
, or try the search function
.
Example #1
Source File: testCairo2.py From TMDLang with GNU General Public License v3.0 | 6 votes |
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()
Example #2
Source File: drawing.py From pypath with GNU General Public License v3.0 | 5 votes |
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()
Example #3
Source File: testCairo.py From TMDLang with GNU General Public License v3.0 | 5 votes |
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)
Example #4
Source File: stickerbom.py From agg-kicad with MIT License | 4 votes |
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.
Example #5
Source File: drawing.py From pypath with GNU General Public License v3.0 | 4 votes |
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)
Example #6
Source File: drawing.py From pypath with GNU General Public License v3.0 | 4 votes |
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
Example #7
Source File: TMDDrawer.py From TMDLang with GNU General Public License v3.0 | 4 votes |
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()
Example #8
Source File: line_chart.py From openxenmanager with GNU General Public License v2.0 | 3 votes |
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)
Example #9
Source File: generate_life_calendar.py From generate_life_calendar with Apache License 2.0 | 3 votes |
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)