Python cairo.FONT_WEIGHT_BOLD Examples

The following are 3 code examples of cairo.FONT_WEIGHT_BOLD(). 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: stickerbom.py    From agg-kicad with MIT License 4 votes vote down vote up
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 #2
Source File: language.py    From TikZ with GNU General Public License v3.0 4 votes vote down vote up
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() 
Example #3
Source File: generate_life_calendar.py    From generate_life_calendar with Apache License 2.0 4 votes vote down vote up
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()