def outline_glyph(glyph):
    source = glyph
    font = glyph._parent
    
    # Save the anchors from the original glyph in a list
    anchors = [a for a in source.anchors]

    # Remove all anchors from the glyph so they don't interfere with our processing
    source.clear(contours=False, components=False, anchors=True, guides=False)
    
    # Temporary glyph to which the pen is writing
    target = RGlyph()
    target_pen = target.getPointPen()
    
    source_pen = OutlinePen(font, contrast=1, offset=5, connection="round")
    source.draw(source_pen)
    source_pen.drawSettings(drawInner=True, drawOuter=True)
    source_pen.drawPoints(target_pen)
    
    # Clear the original glyph and add the modfied outline
    source.clear()
    source.appendGlyph(target)
    
    # Restore the saved anchors
    for a in anchors:
        source.appendAnchor(a.name, a.position)