From d9cc5a1c28a98bc2d4014a14a8e931662e94e037 Mon Sep 17 00:00:00 2001 From: Stephan Bergmann Date: Fri, 18 May 2018 12:08:25 +0200 Subject: Turn debug fprint in vcl/unx/generic/fontmanager/ into SAL_INFO ...mapping OSL_DEBUG_LEVEL > 1 ones to "vcl.fonts" and OSL_DEBUG_LEVEL > 2 ones to new "vcl.fonts.detail" Change-Id: I750b4915083c4a0f9d0310a667987ff33d7fcc2a Reviewed-on: https://gerrit.libreoffice.org/54526 Tested-by: Jenkins Reviewed-by: Stephan Bergmann --- vcl/unx/generic/fontmanager/fontconfig.cxx | 66 +++++++++++------------------- 1 file changed, 24 insertions(+), 42 deletions(-) (limited to 'vcl/unx/generic/fontmanager/fontconfig.cxx') diff --git a/vcl/unx/generic/fontmanager/fontconfig.cxx b/vcl/unx/generic/fontmanager/fontconfig.cxx index e70cb6d067af..17629c09173a 100644 --- a/vcl/unx/generic/fontmanager/fontconfig.cxx +++ b/vcl/unx/generic/fontmanager/fontconfig.cxx @@ -470,18 +470,14 @@ static void lcl_FcFontSetRemove(FcFontSet* pFSet, int i) void PrintFontManager::countFontconfigFonts( std::unordered_map& o_rVisitedPaths ) { -#if OSL_DEBUG_LEVEL > 1 int nFonts = 0; -#endif FontCfgWrapper& rWrapper = FontCfgWrapper::get(); FcFontSet* pFSet = rWrapper.getFontSet(); const bool bMinimalFontset = utl::ConfigManager::IsFuzzing(); if( pFSet ) { -#if OSL_DEBUG_LEVEL > 1 - fprintf( stderr, "found %d entries in fontconfig fontset\n", pFSet->nfont ); -#endif + SAL_INFO("vcl.fonts", "found " << pFSet->nfont << " entries in fontconfig fontset"); for( int i = 0; i < pFSet->nfont; i++ ) { FcChar8* file = nullptr; @@ -511,20 +507,17 @@ void PrintFontManager::countFontconfigFonts( std::unordered_map& o if( eFileRes != FcResultMatch || eFamilyRes != FcResultMatch || eOutRes != FcResultMatch ) continue; -#if (OSL_DEBUG_LEVEL > 2) - fprintf( stderr, "found font \"%s\" in file %s\n" - " weight = %d, slant = %d, style = \"%s\"\n" - " width = %d, spacing = %d, outline = %d, format %s\n" - , family, file - , eWeightRes == FcResultMatch ? weight : -1 - , eSpacRes == FcResultMatch ? slant : -1 - , eStyleRes == FcResultMatch ? (const char*) style : "" - , eWeightRes == FcResultMatch ? width : -1 - , eSpacRes == FcResultMatch ? spacing : -1 - , eOutRes == FcResultMatch ? outline : -1 - , eFormatRes == FcResultMatch ? (const char*)format : "" - ); -#endif + SAL_INFO( + "vcl.fonts.detail", + "found font \"" << family << "\" in file " << file << ", weight = " + << (eWeightRes == FcResultMatch ? weight : -1) << ", slant = " + << (eSpacRes == FcResultMatch ? slant : -1) << ", style = \"" + << (eStyleRes == FcResultMatch ? reinterpret_cast(style) : "") + << "\", width = " << (eWeightRes == FcResultMatch ? width : -1) << ", spacing = " + << (eSpacRes == FcResultMatch ? spacing : -1) << ", outline = " + << (eOutRes == FcResultMatch ? outline : -1) << ", format " + << (eFormatRes == FcResultMatch + ? reinterpret_cast(format) : "")); // OSL_ASSERT(eOutRes != FcResultMatch || outline); @@ -534,9 +527,7 @@ void PrintFontManager::countFontconfigFonts( std::unordered_map& o if (isPreviouslyDuplicateOrObsoleted(pFSet, i)) { -#if OSL_DEBUG_LEVEL > 2 - fprintf(stderr, "Ditching %s as duplicate/obsolete\n", file); -#endif + SAL_INFO("vcl.fonts.detail", "Ditching " << file << " as duplicate/obsolete"); continue; } @@ -548,9 +539,7 @@ void PrintFontManager::countFontconfigFonts( std::unordered_map& o o_rVisitedPaths[aDir] = 1; int nDirID = getDirectoryAtom( aDir ); -#if OSL_DEBUG_LEVEL > 2 - fprintf( stderr, "file %s not cached\n", aBase.getStr() ); -#endif + SAL_INFO("vcl.fonts.detail", "file " << aBase << " not cached"); // not known, analyze font file to get attributes // not described by fontconfig (e.g. alias names, PSName) if (eFormatRes != FcResultMatch) @@ -558,9 +547,8 @@ void PrintFontManager::countFontconfigFonts( std::unordered_map& o std::vector> aFonts = analyzeFontFile( nDirID, aBase, reinterpret_cast(format) ); if(aFonts.empty()) { -#if OSL_DEBUG_LEVEL > 1 - fprintf( stderr, "Warning: file \"%s\" is unusable to psprint\n", aOrgPath.getStr() ); -#endif + SAL_INFO( + "vcl.fonts", "Warning: file \"" << aOrgPath << "\" is unusable to psprint"); //remove font, reuse index //we want to remove unusable fonts here, in case there is a usable font //which duplicates the properties of the unusable one @@ -600,15 +588,17 @@ void PrintFontManager::countFontconfigFonts( std::unordered_map& o // ran to the end of the list) xUpdate->m_nCollectionEntry = nCollectionEntry; } -#if OSL_DEBUG_LEVEL > 1 else { - fprintf( stderr, "multiple fonts for file, but no index in fontconfig pattern ! (index res = %d collection entry = %d\nfile will not be used\n", eIndexRes, nCollectionEntry ); + SAL_INFO( + "vcl.fonts", + "multiple fonts for file, but no index in fontconfig pattern ! (index res =" + << eIndexRes << " collection entry = " << nCollectionEntry + << "; file will not be used"); // we have found more than one font in this file // but fontconfig will not tell us which index is meant // -> something is in disorder, do not use this font } -#endif } if (xUpdate) @@ -631,20 +621,14 @@ void PrintFontManager::countFontconfigFonts( std::unordered_map& o fontID aFont = m_nNextFontID++; m_aFonts[ aFont ] = xUpdate.release(); m_aFontFileToFontID[ aBase ].insert( aFont ); -#if OSL_DEBUG_LEVEL > 1 nFonts++; -#endif -#if OSL_DEBUG_LEVEL > 2 - fprintf( stderr, "inserted font %s as fontID %d\n", family, aFont ); -#endif + SAL_INFO("vcl.fonts.detail", "inserted font " << family << " as fontID " << aFont); } } } // how does one get rid of the config ? -#if OSL_DEBUG_LEVEL > 1 - fprintf( stderr, "inserted %d fonts from fontconfig\n", nFonts ); -#endif + SAL_INFO("vcl.fonts", "inserted " << nFonts << " fonts from fontconfig"); } void PrintFontManager::deinitFontconfig() @@ -657,9 +641,7 @@ void PrintFontManager::addFontconfigDir( const OString& rDirName ) const char* pDirName = rDirName.getStr(); bool bDirOk = (FcConfigAppFontAddDir(FcConfigGetCurrent(), reinterpret_cast(pDirName) ) == FcTrue); -#if OSL_DEBUG_LEVEL > 1 - fprintf( stderr, "FcConfigAppFontAddDir( \"%s\") => %d\n", pDirName, bDirOk ); -#endif + SAL_INFO("vcl.fonts", "FcConfigAppFontAddDir( \"" << pDirName << "\") => " << bDirOk); if( !bDirOk ) return; -- cgit v1.2.3