diff options
Diffstat (limited to 'vcl/unx')
-rw-r--r-- | vcl/unx/generic/fontmanager/fontconfig.cxx | 30 |
1 files changed, 21 insertions, 9 deletions
diff --git a/vcl/unx/generic/fontmanager/fontconfig.cxx b/vcl/unx/generic/fontmanager/fontconfig.cxx index 3a97540434ed..374321bc1eb3 100644 --- a/vcl/unx/generic/fontmanager/fontconfig.cxx +++ b/vcl/unx/generic/fontmanager/fontconfig.cxx @@ -467,6 +467,17 @@ static void lcl_FcFontSetRemove(FcFontSet* pFSet, int i) memmove(pFSet->fonts + i, pFSet->fonts + i + 1, nTail*sizeof(FcPattern*)); } +namespace +{ + // for variable fonts, FC_INDEX has been changed such that the lower half is now the + // index of the font within the collection, and the upper half has been repurposed + // as the index within the variations + unsigned int GetCollectionIndex(unsigned int nCollectionEntryId) + { + return nCollectionEntryId & 0xFFFF; + } +} + void PrintFontManager::countFontconfigFonts( std::unordered_map<OString, int>& o_rVisitedPaths ) { int nFonts = 0; @@ -487,7 +498,7 @@ void PrintFontManager::countFontconfigFonts( std::unordered_map<OString, int>& o int weight = 0; int width = 0; int spacing = 0; - int nCollectionEntry = -1; + int nCollectionEntryId = -1; FcBool outline = false; FcResult eFileRes = FcPatternGetString(pFSet->fonts[i], FC_FILE, 0, &file); @@ -500,7 +511,7 @@ void PrintFontManager::countFontconfigFonts( std::unordered_map<OString, int>& o FcResult eWidthRes = FcPatternGetInteger(pFSet->fonts[i], FC_WIDTH, 0, &width); FcResult eSpacRes = FcPatternGetInteger(pFSet->fonts[i], FC_SPACING, 0, &spacing); FcResult eOutRes = FcPatternGetBool(pFSet->fonts[i], FC_OUTLINE, 0, &outline); - FcResult eIndexRes = FcPatternGetInteger(pFSet->fonts[i], FC_INDEX, 0, &nCollectionEntry); + FcResult eIndexRes = FcPatternGetInteger(pFSet->fonts[i], FC_INDEX, 0, &nCollectionEntryId); FcResult eFormatRes = FcPatternGetString(pFSet->fonts[i], FC_FONTFORMAT, 0, &format); if( eFileRes != FcResultMatch || eFamilyRes != FcResultMatch || eOutRes != FcResultMatch ) @@ -565,8 +576,9 @@ void PrintFontManager::countFontconfigFonts( std::unordered_map<OString, int>& o else // more than one font { // a collection entry, get the correct index - if( eIndexRes == FcResultMatch && nCollectionEntry != -1 ) + if( eIndexRes == FcResultMatch && nCollectionEntryId != -1 ) { + int nCollectionEntry = GetCollectionIndex(nCollectionEntryId); for (auto & font : aFonts) { if( font->m_nCollectionEntry == nCollectionEntry ) @@ -583,14 +595,14 @@ void PrintFontManager::countFontconfigFonts( std::unordered_map<OString, int>& o // additional entries will be created in the cache // if this is a new index (that is if the loop above // ran to the end of the list) - xUpdate->m_nCollectionEntry = nCollectionEntry; + xUpdate->m_nCollectionEntry = GetCollectionIndex(nCollectionEntryId); } else { SAL_INFO( "vcl.fonts", "multiple fonts for file, but no index in fontconfig pattern ! (index res =" - << eIndexRes << " collection entry = " << nCollectionEntry + << eIndexRes << " collection entry = " << nCollectionEntryId << "; 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 @@ -933,16 +945,16 @@ void PrintFontManager::Substitute(FontSelectPattern &rPattern, OUString& rMissin //extract the closest match FcChar8* file = nullptr; FcResult eFileRes = FcPatternGetString(pSet->fonts[0], FC_FILE, 0, &file); - int nCollectionEntry = 0; - FcResult eIndexRes = FcPatternGetInteger(pSet->fonts[0], FC_INDEX, 0, &nCollectionEntry); + int nCollectionEntryId = 0; + FcResult eIndexRes = FcPatternGetInteger(pSet->fonts[0], FC_INDEX, 0, &nCollectionEntryId); if (eIndexRes != FcResultMatch) - nCollectionEntry = 0; + nCollectionEntryId = 0; if( eFileRes == FcResultMatch ) { OString aDir, aBase, aOrgPath( reinterpret_cast<char*>(file) ); splitPath( aOrgPath, aDir, aBase ); int nDirID = getDirectoryAtom( aDir ); - fontID aFont = findFontFileID( nDirID, aBase, nCollectionEntry ); + fontID aFont = findFontFileID( nDirID, aBase, GetCollectionIndex(nCollectionEntryId) ); if( aFont > 0 ) { FastPrintFontInfo aInfo; |