Kaydet (Commit) 6c06dd34 authored tarafından Caolán McNamara's avatar Caolán McNamara

Resolves: fdo#44492 look up font by FC_FILE+FC_INDEX rather than FC_FAMILY

üst 6b5eacd1
......@@ -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);
......
......@@ -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:
......
......@@ -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;
}
......
......@@ -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 );
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment