From 04a084bfdb62051428f0fae6e62b1058623b0c9a Mon Sep 17 00:00:00 2001 From: poruri sai rahul Date: Tue, 24 Sep 2019 13:36:04 +0100 Subject: [PATCH] DEV : Defer imports from font_manager in font module Deferring this imports means that a number of places where we need to import from font don't trigger the import time side-effect in the font_manager module modified: kiva/fonttools/font.py --- kiva/fonttools/font.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/kiva/fonttools/font.py b/kiva/fonttools/font.py index 42ea53096..4a82b98f2 100644 --- a/kiva/fonttools/font.py +++ b/kiva/fonttools/font.py @@ -10,7 +10,6 @@ import copy from kiva.constants import (DEFAULT, DECORATIVE, ROMAN, SCRIPT, SWISS, MODERN, TELETYPE, NORMAL, ITALIC, BOLD, BOLD_ITALIC) -from .font_manager import FontProperties, fontManager # Various maps used by str_to_font font_families = { @@ -104,6 +103,8 @@ def findfont(self): """ Returns the file name containing the font that most closely matches our font properties. """ + from .font_manager import fontManager + fp = self._make_font_props() return str(fontManager.findfont(fp)) @@ -118,6 +119,8 @@ def _make_font_props(self): """ Returns a font_manager.FontProperties object that encapsulates our font properties """ + from .font_manager import FontProperties + # XXX: change the weight to a numerical value if self.style == BOLD or self.style == BOLD_ITALIC: weight = "bold"