Skip to content
Permalink
Browse files

Update test font to Vera San and start workaround for Mac 10.9 font-l…

…oading bugs

- Test font loading should be moved to QgsFontUtils
  • Loading branch information
dakcarto committed Feb 19, 2014
1 parent 570e24b commit 34be93b849eaa9ee98d38bf19ff6d8f42f572199
@@ -737,7 +737,7 @@ int main( int argc, char *argv[] )
}

// load standard test font from testdata.qrc (for unit tests)
QFile testFont( ":/testdata/font/FreeSansQGIS.ttf" );
QFile testFont( ":/testdata/font/QGIS-Vera/QGIS-Vera.ttf" );
if ( testFont.open( QIODevice::ReadOnly ) )
{
int fontID = QFontDatabase::addApplicationFontFromData( testFont.readAll() );
@@ -91,6 +91,7 @@ void QgsApplication::init( QString customConfigPath )
qRegisterMetaType<QgsGeometry::Error>( "QgsGeometry::Error" );

QString prefixPath( getenv( "QGIS_PREFIX_PATH" ) ? getenv( "QGIS_PREFIX_PATH" ) : applicationDirPath() );
// QgsDebugMsg( QString( "prefixPath(): %1" ).arg( prefixPath ) );

// check if QGIS is run from build directory (not the install directory)
QFile f;
@@ -248,21 +248,47 @@ int main( int argc, char * argv[] )
theMapRenderer->setLabelingEngine( new QgsPalLabeling() );

#ifdef QGSMSDEBUG
// load standard test font from testdata.qrc (for unit tests)
// load standard test font from filesystem or testdata.qrc (for unit tests)
bool testFontLoaded = false;
QFile testFont( ":/testdata/font/FreeSansQGIS.ttf" );
if ( testFont.open( QIODevice::ReadOnly ) )
QFontDatabase fontDB;
QFont testFont = fontDB.font( "QGIS Vera Sans", "Roman", 12 );
if ( testFont.family().startsWith( "QGIS", Qt::CaseInsensitive ) )
{
int fontID = QFontDatabase::addApplicationFontFromData( testFont.readAll() );
testFontLoaded = ( fontID != -1 );
} // else app wasn't built with ENABLE_TESTS or not GUI app
testFontLoaded = true;
QgsDebugMsg( "Test font already available" );
}
else
{
QString fontFromWhere( "" );
if ( QgsApplication::isRunningFromBuildDir() )
{
// [LS] workaround for serious bugs on Mac 10.9, where fonts from qrc resources fail:
// https://bugreports.qt-project.org/browse/QTBUG-30917
// https://bugreports.qt-project.org/browse/QTBUG-32789
QString testFont( QgsApplication::buildSourcePath() + "/tests/testdata/font/QGIS-Vera/QGIS-Vera.ttf" );
int fontID = QFontDatabase::addApplicationFont( testFont );
testFontLoaded = ( fontID != -1 );
fontFromWhere = testFontLoaded ? "filesystem" : "";
}
else
{
QFile testFont( ":/testdata/font/QGIS-Vera/QGIS-Vera.ttf" );
if ( testFont.open( QIODevice::ReadOnly ) )
{
int fontID = QFontDatabase::addApplicationFontFromData( testFont.readAll() );
testFontLoaded = ( fontID != -1 );
} // else app wasn't built with ENABLE_TESTS or not GUI app
fontFromWhere = testFontLoaded ? "testdata.qrc" : "";
}
QgsDebugMsg( QString( "Test font %1loaded from %2 on startup" ).arg( testFontLoaded ? "" : "NOT " ).arg( fontFromWhere ) );
}
#endif

while ( fcgi_accept() >= 0 )
{
printRequestInfos(); //print request infos if in debug mode
#ifdef QGSMSDEBUG
QgsDebugMsg( QString( "Test font %1 loaded from testdata.qrc" ).arg( testFontLoaded ? "" : "NOT " ) );
QgsDebugMsg( QString( "Test font %1loaded" ).arg( testFontLoaded ? "" : "NOT " ) );
#endif

//use QgsGetRequestHandler in case of HTTP GET and QgsSOAPRequestHandler in case of HTTP POST
@@ -23,13 +23,15 @@
QgsPalLayerSettings,
)

from utilities import loadTestFont


class TestPointBase(object):

def __init__(self):
"""Dummy assignments, intended to be overriden in subclasses"""
self.lyr = QgsPalLayerSettings()
self._TestFont = QApplication.font()
self._TestFont = loadTestFont()

def checkTest(self, **kwargs):
"""Intended to be overriden in subclasses"""
@@ -50,6 +50,7 @@

TESTFONT = None


def assertHashesForFile(theHashes, theFilename):
"""Assert that a files has matches one of a list of expected hashes"""
myHash = hashForFile(theFilename)
@@ -220,10 +221,11 @@ def loadTestFont():
global TESTFONT # pylint: disable=W0603

if TESTFONT is None:
fontid = QtGui.QFontDatabase.addApplicationFont(
os.path.join(unitTestDataPath('font'), 'FreeSansQGIS.ttf'))
fontid = QtGui.QFontDatabase().addApplicationFont(
os.path.join(unitTestDataPath('font'),
'QGIS-Vera', 'QGIS-Vera.ttf'))
if fontid != -1:
TESTFONT = QtGui.QFont('FreeSansQGIS')
TESTFONT = QtGui.QFont('QGIS Vera Sans')

return TESTFONT

@@ -235,6 +237,6 @@ def openInBrowserTab(url):
# some Linux OS pause execution on webbrowser open, so background it
cmd = 'import webbrowser;' \
'webbrowser.open_new_tab({0})'.format(url)
p = subprocess.Popen([sys.executable, "-c", cmd],
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT).pid
subprocess.Popen([sys.executable, "-c", cmd],
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT)

This file was deleted.

0 comments on commit 34be93b

Please sign in to comment.
You can’t perform that action at this time.