Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def font_metrics_provider():
""" Creates an object to be used for querying font metrics. Typically
this can just be an empty/dummy graphics context
"""
gc = GraphicsContext((1,1))
gc.set_font(Font())
return gc
def GetFont(font):
""" Returns a Pylget Font object for the given Agg or Kiva font """
if isinstance(font, PygletFont):
pyglet_font = font
else:
# AggFontType
key = (font.name, font.size, font.family, font.style)
if key not in GlobalFontCache:
if isinstance(font, AggFontType):
agg_font = font
font = Font(face_name = agg_font.name,
size = agg_font.size,
family = agg_font.family,
style = agg_font.style)
bold = False
italic = False
if font.style == BOLD or font.style == BOLD_ITALIC or font.weight == BOLD:
bold = True
if font.style == ITALIC or font.style == BOLD_ITALIC:
italic = True
pyglet_font = load_font(font.findfontname(), font.size, bold, italic)
GlobalFontCache[key] = pyglet_font
else:
pyglet_font = GlobalFontCache[key]
return pyglet_font
def font_metrics_provider():
gc = GraphicsContext((1, 1))
gc.set_font(Font())
return gc