def GetFont(font): """ Returns a Pylget Font object for the given Agg or Kiva font """ if isinstance(font, PygletFont): pyglet_font = font else: # KivaGLFontType key = (font.name, font.size, font.family, font.style) if key not in GlobalFontCache: if isinstance(font, KivaGLFontType): kiva_gl_font = font font = Font( face_name=kiva_gl_font.name, size=kiva_gl_font.size, family=kiva_gl_font.family, style=kiva_gl_font.style, ) bold = font.is_bold() italic = font.style in italic_styles pyglet_font = load_font(font.findfontname(), font.size, bold, italic) GlobalFontCache[key] = pyglet_font else: pyglet_font = GlobalFontCache[key] return pyglet_font