bacon/text.py
def draw_glyph_layout(glyph_layout):
    '''Draw a prepared :class:`GlyphLayout`
    '''
    pushed_color = False

    # Draw lines
    for line in glyph_layout.lines:
        x = line.x
        y = line.y
        
        for run in line.runs:
            style = run.style
            if style.color is not None:
                if not pushed_color:
                    bacon.push_color()
                    pushed_color = True
                bacon.set_color(*style.color)
            elif pushed_color:
                bacon.pop_color()
                pushed_color = False

            for glyph in run.glyphs:
                if glyph.image:
                    bacon.draw_image(glyph.image, x + glyph.offset_x, y - glyph.offset_y)
                x += glyph.advance

    if pushed_color:
        bacon.pop_color()
def draw_glyph_layout(glyph_layout):
    '''Draw a prepared :class:`GlyphLayout`
    '''
    pushed_color = False

    # Draw lines
    for line in glyph_layout.lines:
        x = line.x
        y = line.y
        
        for run in line.runs:
            style = run.style
            if style.color is not None:
                if not pushed_color:
                    bacon.push_color()
                    pushed_color = True
                bacon.set_color(*style.color)
            elif pushed_color:
                bacon.pop_color()
                pushed_color = False

            for glyph in run.glyphs:
                if glyph.image:
                    bacon.draw_image(glyph.image, x + glyph.offset_x, y - glyph.offset_y)
                x += glyph.advance

    if pushed_color:
        bacon.pop_color()
Draw a prepared :class:`GlyphLayout`