47
47
unittest ,
48
48
expectedFailure ,
49
49
unitTestDataPath ,
50
+ loadTestFont ,
50
51
openInBrowserTab
51
52
)
52
53
53
54
QGISAPP , CANVAS , IFACE , PARENT = getQgisTestApp ()
55
+ TESTFONT = loadTestFont ()
54
56
55
57
PALREPORT = 'PAL_REPORT' in os .environ
56
58
PALREPORTS = {}
@@ -61,7 +63,7 @@ class TestQgsPalLabeling(TestCase):
61
63
_TestDataDir = unitTestDataPath ()
62
64
_PalDataDir = os .path .join (_TestDataDir , 'labeling' )
63
65
_PalFeaturesDb = os .path .join (_PalDataDir , 'pal_features_v3.sqlite' )
64
- _TestFontID = - 1
66
+ _TestFont = TESTFONT
65
67
_MapRegistry = None
66
68
_MapRenderer = None
67
69
_Canvas = None
@@ -81,18 +83,8 @@ def setUpClass(cls):
81
83
assert res , msg
82
84
83
85
# load the FreeSansQGIS labeling test font
84
- fontdb = QFontDatabase ()
85
- cls ._TestFontID = fontdb .addApplicationFont (
86
- os .path .join (cls ._TestDataDir , 'font' , 'FreeSansQGIS.ttf' ))
87
- msg = ('\n Could not store test font in font database, '
88
- 'SKIPPING TEST SUITE' )
89
- assert cls ._TestFontID != - 1 , msg
90
-
91
- cls ._TestFont = fontdb .font ('FreeSansQGIS' , 'Medium' , 48 )
92
- appfont = QApplication .font ()
93
- msg = ('\n Could not load test font from font database, '
94
- 'SKIPPING TEST SUITE' )
95
- assert cls ._TestFont .toString () != appfont .toString (), msg
86
+ msg = '\n Could not load test font, SKIPPING TEST SUITE'
87
+ assert TESTFONT is not None , msg
96
88
97
89
cls ._TestFunction = ''
98
90
cls ._TestGroup = ''
@@ -128,6 +120,10 @@ def tearDownClass(cls):
128
120
def removeAllLayers (cls ):
129
121
cls ._MapRegistry .removeAllMapLayers ()
130
122
123
+ @classmethod
124
+ def getTestFont (cls ):
125
+ return QFont (cls ._TestFont )
126
+
131
127
@classmethod
132
128
def loadFeatureLayer (cls , table ):
133
129
uri = QgsDataSourceURI ()
@@ -176,7 +172,9 @@ def defaultSettings(self):
176
172
lyr = QgsPalLayerSettings ()
177
173
lyr .enabled = True
178
174
lyr .fieldName = 'text' # default in data sources
179
- lyr .textFont = self ._TestFont
175
+ font = self .getTestFont ()
176
+ font .setPointSize (48 )
177
+ lyr .textFont = font
180
178
lyr .textNamedStyle = 'Medium'
181
179
return lyr
182
180
0 commit comments