Kaydet (Commit) 3681e8d8 authored tarafından Caolán McNamara's avatar Caolán McNamara

Related: rhbz#1690732 FC_INDEX doesn't mean exactly what it used to mean

its been repurposed to hold font face variation information too

Change-Id: I5d667d79a49337e7ade1e1697ca2fc9cb8c00f1c
Reviewed-on: https://gerrit.libreoffice.org/69474
Tested-by: Jenkins
Reviewed-by: 's avatarCaolán McNamara <caolanm@redhat.com>
Tested-by: 's avatarCaolán McNamara <caolanm@redhat.com>
üst c5db5d32
...@@ -467,6 +467,17 @@ static void lcl_FcFontSetRemove(FcFontSet* pFSet, int i) ...@@ -467,6 +467,17 @@ static void lcl_FcFontSetRemove(FcFontSet* pFSet, int i)
memmove(pFSet->fonts + i, pFSet->fonts + i + 1, nTail*sizeof(FcPattern*)); 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 ) void PrintFontManager::countFontconfigFonts( std::unordered_map<OString, int>& o_rVisitedPaths )
{ {
int nFonts = 0; int nFonts = 0;
...@@ -487,7 +498,7 @@ void PrintFontManager::countFontconfigFonts( std::unordered_map<OString, int>& o ...@@ -487,7 +498,7 @@ void PrintFontManager::countFontconfigFonts( std::unordered_map<OString, int>& o
int weight = 0; int weight = 0;
int width = 0; int width = 0;
int spacing = 0; int spacing = 0;
int nCollectionEntry = -1; int nCollectionEntryId = -1;
FcBool outline = false; FcBool outline = false;
FcResult eFileRes = FcPatternGetString(pFSet->fonts[i], FC_FILE, 0, &file); FcResult eFileRes = FcPatternGetString(pFSet->fonts[i], FC_FILE, 0, &file);
...@@ -500,7 +511,7 @@ void PrintFontManager::countFontconfigFonts( std::unordered_map<OString, int>& o ...@@ -500,7 +511,7 @@ void PrintFontManager::countFontconfigFonts( std::unordered_map<OString, int>& o
FcResult eWidthRes = FcPatternGetInteger(pFSet->fonts[i], FC_WIDTH, 0, &width); FcResult eWidthRes = FcPatternGetInteger(pFSet->fonts[i], FC_WIDTH, 0, &width);
FcResult eSpacRes = FcPatternGetInteger(pFSet->fonts[i], FC_SPACING, 0, &spacing); FcResult eSpacRes = FcPatternGetInteger(pFSet->fonts[i], FC_SPACING, 0, &spacing);
FcResult eOutRes = FcPatternGetBool(pFSet->fonts[i], FC_OUTLINE, 0, &outline); 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); FcResult eFormatRes = FcPatternGetString(pFSet->fonts[i], FC_FONTFORMAT, 0, &format);
if( eFileRes != FcResultMatch || eFamilyRes != FcResultMatch || eOutRes != FcResultMatch ) if( eFileRes != FcResultMatch || eFamilyRes != FcResultMatch || eOutRes != FcResultMatch )
...@@ -565,8 +576,9 @@ void PrintFontManager::countFontconfigFonts( std::unordered_map<OString, int>& o ...@@ -565,8 +576,9 @@ void PrintFontManager::countFontconfigFonts( std::unordered_map<OString, int>& o
else // more than one font else // more than one font
{ {
// a collection entry, get the correct index // 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) for (auto & font : aFonts)
{ {
if( font->m_nCollectionEntry == nCollectionEntry ) if( font->m_nCollectionEntry == nCollectionEntry )
...@@ -583,14 +595,14 @@ void PrintFontManager::countFontconfigFonts( std::unordered_map<OString, int>& o ...@@ -583,14 +595,14 @@ void PrintFontManager::countFontconfigFonts( std::unordered_map<OString, int>& o
// additional entries will be created in the cache // additional entries will be created in the cache
// if this is a new index (that is if the loop above // if this is a new index (that is if the loop above
// ran to the end of the list) // ran to the end of the list)
xUpdate->m_nCollectionEntry = nCollectionEntry; xUpdate->m_nCollectionEntry = GetCollectionIndex(nCollectionEntryId);
} }
else else
{ {
SAL_INFO( SAL_INFO(
"vcl.fonts", "vcl.fonts",
"multiple fonts for file, but no index in fontconfig pattern ! (index res =" "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"); << "; file will not be used");
// we have found more than one font in this file // we have found more than one font in this file
// but fontconfig will not tell us which index is meant // but fontconfig will not tell us which index is meant
...@@ -933,16 +945,16 @@ void PrintFontManager::Substitute(FontSelectPattern &rPattern, OUString& rMissin ...@@ -933,16 +945,16 @@ void PrintFontManager::Substitute(FontSelectPattern &rPattern, OUString& rMissin
//extract the closest match //extract the closest match
FcChar8* file = nullptr; FcChar8* file = nullptr;
FcResult eFileRes = FcPatternGetString(pSet->fonts[0], FC_FILE, 0, &file); FcResult eFileRes = FcPatternGetString(pSet->fonts[0], FC_FILE, 0, &file);
int nCollectionEntry = 0; int nCollectionEntryId = 0;
FcResult eIndexRes = FcPatternGetInteger(pSet->fonts[0], FC_INDEX, 0, &nCollectionEntry); FcResult eIndexRes = FcPatternGetInteger(pSet->fonts[0], FC_INDEX, 0, &nCollectionEntryId);
if (eIndexRes != FcResultMatch) if (eIndexRes != FcResultMatch)
nCollectionEntry = 0; nCollectionEntryId = 0;
if( eFileRes == FcResultMatch ) if( eFileRes == FcResultMatch )
{ {
OString aDir, aBase, aOrgPath( reinterpret_cast<char*>(file) ); OString aDir, aBase, aOrgPath( reinterpret_cast<char*>(file) );
splitPath( aOrgPath, aDir, aBase ); splitPath( aOrgPath, aDir, aBase );
int nDirID = getDirectoryAtom( aDir ); int nDirID = getDirectoryAtom( aDir );
fontID aFont = findFontFileID( nDirID, aBase, nCollectionEntry ); fontID aFont = findFontFileID( nDirID, aBase, GetCollectionIndex(nCollectionEntryId) );
if( aFont > 0 ) if( aFont > 0 )
{ {
FastPrintFontInfo aInfo; FastPrintFontInfo aInfo;
......
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