summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2012-01-11 13:48:09 +0000
committerCaolán McNamara <caolanm@redhat.com>2012-01-11 14:13:32 +0000
commit6c06dd347ca2e8a5dc42884344ed8c7c4c5f18b9 (patch)
treeafe98065b515372d2b9be64953ce2be8b74b9041
parent6b5eacd10dde8fc5e68c64b532c441c2888b1b4e (diff)
Resolves: fdo#44492 look up font by FC_FILE+FC_INDEX rather than FC_FAMILY
-rw-r--r--vcl/generic/fontmanager/fontconfig.cxx51
-rw-r--r--vcl/generic/fontmanager/fontmanager.cxx6
-rw-r--r--vcl/generic/fontmanager/fontsubst.cxx2
-rw-r--r--vcl/inc/vcl/fontmanager.hxx2
4 files changed, 42 insertions, 19 deletions
diff --git a/vcl/generic/fontmanager/fontconfig.cxx b/vcl/generic/fontmanager/fontconfig.cxx
index d3b1f2b91922..daf4fee9d858 100644
--- a/vcl/generic/fontmanager/fontconfig.cxx
+++ b/vcl/generic/fontmanager/fontconfig.cxx
@@ -746,7 +746,7 @@ static void addtopattern(FcPattern *pPattern,
}
}
-bool PrintFontManager::Substitute( FontSelectPattern &rPattern, rtl::OUString& rMissingCodes ) const
+bool PrintFontManager::Substitute( FontSelectPattern &rPattern, rtl::OUString& rMissingCodes )
{
bool bRet = false;
@@ -814,21 +814,48 @@ bool PrintFontManager::Substitute( FontSelectPattern &rPattern, rtl::OUString& r
if( pSet->nfont > 0 )
{
//extract the closest match
- FcChar8* family = NULL;
- FcResult eFileRes = FcPatternGetString( pSet->fonts[0], FC_FAMILY, 0, &family );
-
- // get the family name
+ FcChar8* file = NULL;
+ FcResult eFileRes = FcPatternGetString(pSet->fonts[0], FC_FILE, 0, &file);
+ int nCollectionEntry = 0;
+ FcResult eIndexRes = FcPatternGetInteger(pSet->fonts[0], FC_INDEX, 0, &nCollectionEntry);
+ if (eIndexRes != FcResultMatch)
+ nCollectionEntry = 0;
if( eFileRes == FcResultMatch )
{
- bRet = true;
+ OString aDir, aBase, aOrgPath( (sal_Char*)file );
+ splitPath( aOrgPath, aDir, aBase );
+ int nDirID = getDirectoryAtom( aDir, true );
+ fontID aFont = findFontFileID( nDirID, aBase, nCollectionEntry );
+ if( aFont > 0 )
+ {
+ FastPrintFontInfo aInfo;
+ bRet = getFontFastInfo( aFont, aInfo );
+ rPattern.maSearchName = aInfo.m_aFamilyName;
+ }
+ }
+
+ SAL_WARN_IF(!bRet, "vcl", "no FC_FILE found, falling back to name search");
- OString sFamily((sal_Char*)family);
- boost::unordered_map< rtl::OString, rtl::OString, rtl::OStringHash >::const_iterator aI =
- rWrapper.m_aFontNameToLocalized.find(sFamily);
- if (aI != rWrapper.m_aFontNameToLocalized.end())
- sFamily = aI->second;
- rPattern.maSearchName = rtl::OStringToOUString( sFamily, RTL_TEXTENCODING_UTF8 );
+ if (!bRet)
+ {
+ FcChar8* family = NULL;
+ FcResult eFamilyRes = FcPatternGetString( pSet->fonts[0], FC_FAMILY, 0, &family );
+ // get the family name
+ if( eFamilyRes == FcResultMatch )
+ {
+ OString sFamily((sal_Char*)family);
+ boost::unordered_map< rtl::OString, rtl::OString, rtl::OStringHash >::const_iterator aI =
+ rWrapper.m_aFontNameToLocalized.find(sFamily);
+ if (aI != rWrapper.m_aFontNameToLocalized.end())
+ sFamily = aI->second;
+ rPattern.maSearchName = rtl::OStringToOUString( sFamily, RTL_TEXTENCODING_UTF8 );
+ bRet = true;
+ }
+ }
+
+ if (bRet)
+ {
int val = 0;
if (FcResultMatch == FcPatternGetInteger(pSet->fonts[0], FC_WEIGHT, 0, &val))
rPattern.meWeight = convertWeight(val);
diff --git a/vcl/generic/fontmanager/fontmanager.cxx b/vcl/generic/fontmanager/fontmanager.cxx
index 09e64c9358dc..35517cd806bc 100644
--- a/vcl/generic/fontmanager/fontmanager.cxx
+++ b/vcl/generic/fontmanager/fontmanager.cxx
@@ -1483,12 +1483,8 @@ fontID PrintFontManager::findFontFileID( int nDirID, const OString& rFontFile, i
{
TrueTypeFontFile* const pFont = static_cast< TrueTypeFontFile* const >((*it).second);
if( pFont->m_nDirectory == nDirID &&
- pFont->m_aFontFile == rFontFile )
- {
- fprintf(stderr, "candidate %d vs %d\n", pFont->m_nCollectionEntry, nFaceIndex);
- if (pFont->m_nCollectionEntry == nFaceIndex)
+ pFont->m_aFontFile == rFontFile && pFont->m_nCollectionEntry == nFaceIndex )
nID = it->first;
- }
}
break;
case fonttype::Builtin:
diff --git a/vcl/generic/fontmanager/fontsubst.cxx b/vcl/generic/fontmanager/fontsubst.cxx
index 26076681a99d..1086531347b0 100644
--- a/vcl/generic/fontmanager/fontsubst.cxx
+++ b/vcl/generic/fontmanager/fontsubst.cxx
@@ -117,7 +117,7 @@ void SalGenericInstance::RegisterFontSubstitutors( ImplDevFontList* pList )
static FontSelectPattern GetFcSubstitute(const FontSelectPattern &rFontSelData, rtl::OUString& rMissingCodes )
{
FontSelectPattern aSubstituted(rFontSelData);
- const psp::PrintFontManager& rMgr = psp::PrintFontManager::get();
+ psp::PrintFontManager& rMgr = psp::PrintFontManager::get();
rMgr.Substitute(aSubstituted, rMissingCodes);
return aSubstituted;
}
diff --git a/vcl/inc/vcl/fontmanager.hxx b/vcl/inc/vcl/fontmanager.hxx
index a429b7ed2532..3fe2facbcd83 100644
--- a/vcl/inc/vcl/fontmanager.hxx
+++ b/vcl/inc/vcl/fontmanager.hxx
@@ -648,7 +648,7 @@ public:
bool matchFont( FastPrintFontInfo& rInfo, const com::sun::star::lang::Locale& rLocale );
ImplFontOptions* getFontOptions( const FastPrintFontInfo&, int nSize, void (*subcallback)(void*)) const;
- bool Substitute( FontSelectPattern &rPattern, rtl::OUString& rMissingCodes ) const;
+ bool Substitute( FontSelectPattern &rPattern, rtl::OUString& rMissingCodes );
int FreeTypeCharIndex( void *pFace, sal_uInt32 aChar );
};