summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2018-08-20 12:35:13 +0100
committerCaolán McNamara <caolanm@redhat.com>2018-08-21 21:36:58 +0200
commitfa0ea0257676d7f96938216ac958a08d7c9a364c (patch)
treee413f20b2facc0a04df1717e64c0b71a5c783afc /vcl
parentfb4a58fcaefc2f437c0ec4a7cb40281aef4162da (diff)
change FindFontSubstitute to operate on FontSelectPatternAttributes
it remains to be seen if we need the the returned mpFontInstance of the coretext impl Change-Id: I48f73188250c3eb014f16ffe0a735191da5cb25b Reviewed-on: https://gerrit.libreoffice.org/59322 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'vcl')
-rw-r--r--vcl/inc/outdev.h4
-rw-r--r--vcl/inc/unx/fontmanager.hxx2
-rw-r--r--vcl/quartz/salgdi.cxx14
-rw-r--r--vcl/source/font/PhysicalFontCollection.cxx2
-rw-r--r--vcl/unx/generic/fontmanager/fontconfig.cxx2
-rw-r--r--vcl/unx/generic/fontmanager/fontsubst.cxx27
-rw-r--r--vcl/win/gdi/salfont.cxx8
7 files changed, 26 insertions, 33 deletions
diff --git a/vcl/inc/outdev.h b/vcl/inc/outdev.h
index 2aabdfa93acf..5ac5cc0df0b4 100644
--- a/vcl/inc/outdev.h
+++ b/vcl/inc/outdev.h
@@ -110,7 +110,7 @@ class ImplPreMatchFontSubstitution
: public ImplFontSubstitution
{
public:
- virtual bool FindFontSubstitute( FontSelectPattern& ) const = 0;
+ virtual bool FindFontSubstitute(FontSelectPatternAttributes&) const = 0;
};
// ImplGlyphFallbackFontSubstitution
@@ -119,7 +119,7 @@ class ImplGlyphFallbackFontSubstitution
: public ImplFontSubstitution
{
public:
- virtual bool FindFontSubstitute( FontSelectPattern&, OUString& rMissingCodes ) const = 0;
+ virtual bool FindFontSubstitute(FontSelectPatternAttributes&, LogicalFontInstance* pLogicalFont, OUString& rMissingCodes) const = 0;
};
namespace vcl { struct ControlLayoutData; }
diff --git a/vcl/inc/unx/fontmanager.hxx b/vcl/inc/unx/fontmanager.hxx
index fcaf801018c4..bdd2c9e1a850 100644
--- a/vcl/inc/unx/fontmanager.hxx
+++ b/vcl/inc/unx/fontmanager.hxx
@@ -310,7 +310,7 @@ public:
void matchFont( FastPrintFontInfo& rInfo, const css::lang::Locale& rLocale );
static FontConfigFontOptions* getFontOptions( const FastPrintFontInfo&, int nSize);
- void Substitute( FontSelectPattern &rPattern, OUString& rMissingCodes );
+ void Substitute(FontSelectPatternAttributes &rPattern, OUString& rMissingCodes);
};
diff --git a/vcl/quartz/salgdi.cxx b/vcl/quartz/salgdi.cxx
index 3f74e05f5910..6b9350bb4427 100644
--- a/vcl/quartz/salgdi.cxx
+++ b/vcl/quartz/salgdi.cxx
@@ -60,14 +60,14 @@ class CoreTextGlyphFallbackSubstititution
: public ImplGlyphFallbackFontSubstitution
{
public:
- bool FindFontSubstitute(FontSelectPattern&, OUString&) const override;
+ bool FindFontSubstitute(FontSelectPatternAttributes&, LogicalFontInstance* pLogicalFont, OUString&) const override;
};
-bool CoreTextGlyphFallbackSubstititution::FindFontSubstitute(FontSelectPattern& rPattern,
+bool CoreTextGlyphFallbackSubstititution::FindFontSubstitute(FontSelectPatternAttributes& rPattern, LogicalFontInstance* pLogicalFont,
OUString& rMissingChars) const
{
bool bFound = false;
- CoreTextStyle* pStyle = static_cast<CoreTextStyle*>(rPattern.mpFontInstance.get());
+ CoreTextStyle* pStyle = static_cast<CoreTextStyle*>(pLogicalFont);
CTFontRef pFont = static_cast<CTFontRef>(CFDictionaryGetValue(pStyle->GetStyleDict(), kCTFontAttributeName));
CFStringRef pStr = CreateCFString(rMissingChars);
if (pStr)
@@ -87,14 +87,6 @@ bool CoreTextGlyphFallbackSubstititution::FindFontSubstitute(FontSelectPattern&
rPattern.SetPitch(rAttr.GetPitch());
rPattern.SetWidthType(rAttr.GetWidthType());
- SalData* pSalData = GetSalData();
- if (pSalData->mpFontList)
- {
- const CoreTextFontFace *pFontFace = pSalData->mpFontList->GetFontDataFromId(reinterpret_cast<sal_IntPtr>(pDesc));
- if (pFontFace)
- rPattern.mpFontInstance = pFontFace->CreateFontInstance(rPattern);
- }
-
CFRelease(pFallback);
CFRelease(pDesc);
}
diff --git a/vcl/source/font/PhysicalFontCollection.cxx b/vcl/source/font/PhysicalFontCollection.cxx
index 38dedaf09645..77bbfd57a061 100644
--- a/vcl/source/font/PhysicalFontCollection.cxx
+++ b/vcl/source/font/PhysicalFontCollection.cxx
@@ -216,7 +216,7 @@ PhysicalFontFamily* PhysicalFontCollection::GetGlyphFallbackFont( FontSelectPatt
OUString aOldMissingCodes = rMissingCodes;
// call the hook to query the best matching glyph fallback font
- if( mpFallbackHook->FindFontSubstitute( rFontSelData, rMissingCodes ) )
+ if (mpFallbackHook->FindFontSubstitute(rFontSelData, rFontSelData.mpFontInstance.get(), rMissingCodes))
// apply outdev3.cxx specific fontname normalization
rFontSelData.maSearchName = GetEnglishSearchFontName( rFontSelData.maSearchName );
else
diff --git a/vcl/unx/generic/fontmanager/fontconfig.cxx b/vcl/unx/generic/fontmanager/fontconfig.cxx
index 10cb3a76f3fa..633f3ab4f914 100644
--- a/vcl/unx/generic/fontmanager/fontconfig.cxx
+++ b/vcl/unx/generic/fontmanager/fontconfig.cxx
@@ -862,7 +862,7 @@ IMPL_LINK_NOARG(PrintFontManager, autoInstallFontLangSupport, Timer *, void)
m_aCurrentRequests.clear();
}
-void PrintFontManager::Substitute( FontSelectPattern &rPattern, OUString& rMissingCodes )
+void PrintFontManager::Substitute(FontSelectPatternAttributes &rPattern, OUString& rMissingCodes)
{
FontCfgWrapper& rWrapper = FontCfgWrapper::get();
diff --git a/vcl/unx/generic/fontmanager/fontsubst.cxx b/vcl/unx/generic/fontmanager/fontsubst.cxx
index 11586ad21382..f43ed146e060 100644
--- a/vcl/unx/generic/fontmanager/fontsubst.cxx
+++ b/vcl/unx/generic/fontmanager/fontsubst.cxx
@@ -28,8 +28,8 @@ class FcPreMatchSubstitution
: public ImplPreMatchFontSubstitution
{
public:
- bool FindFontSubstitute( FontSelectPattern& ) const override;
- typedef ::std::pair<FontSelectPattern, FontSelectPattern> value_type;
+ bool FindFontSubstitute( FontSelectPatternAttributes& ) const override;
+ typedef ::std::pair<FontSelectPatternAttributes, FontSelectPatternAttributes> value_type;
private:
typedef ::std::list<value_type> CachedFontMapType;
mutable CachedFontMapType maCachedFontMap;
@@ -40,7 +40,7 @@ class FcGlyphFallbackSubstitution
{
// TODO: add a cache
public:
- bool FindFontSubstitute( FontSelectPattern&, OUString& rMissingCodes ) const override;
+ bool FindFontSubstitute(FontSelectPatternAttributes&, LogicalFontInstance* pLogicalFont, OUString& rMissingCodes) const override;
};
void SalGenericInstance::RegisterFontSubstitutors( PhysicalFontCollection* pFontCollection )
@@ -54,9 +54,9 @@ void SalGenericInstance::RegisterFontSubstitutors( PhysicalFontCollection* pFont
pFontCollection->SetFallbackHook( &aSubstFallback );
}
-static FontSelectPattern GetFcSubstitute(const FontSelectPattern &rFontSelData, OUString& rMissingCodes )
+static FontSelectPatternAttributes GetFcSubstitute(const FontSelectPatternAttributes &rFontSelData, OUString& rMissingCodes)
{
- FontSelectPattern aSubstituted(rFontSelData);
+ FontSelectPatternAttributes aSubstituted(rFontSelData);
psp::PrintFontManager& rMgr = psp::PrintFontManager::get();
rMgr.Substitute(aSubstituted, rMissingCodes);
return aSubstituted;
@@ -79,9 +79,9 @@ namespace
class equal
{
private:
- const FontSelectPattern& mrAttributes;
+ const FontSelectPatternAttributes& mrAttributes;
public:
- explicit equal(const FontSelectPattern& rAttributes)
+ explicit equal(const FontSelectPatternAttributes& rAttributes)
: mrAttributes(rAttributes)
{
}
@@ -90,7 +90,7 @@ namespace
};
}
-bool FcPreMatchSubstitution::FindFontSubstitute( FontSelectPattern &rFontSelData ) const
+bool FcPreMatchSubstitution::FindFontSubstitute(FontSelectPatternAttributes &rFontSelData) const
{
// We don't actually want to talk to Fontconfig at all for symbol fonts
if( rFontSelData.IsSymbolFont() )
@@ -104,13 +104,13 @@ bool FcPreMatchSubstitution::FindFontSubstitute( FontSelectPattern &rFontSelData
//different fonts depending on fontsize, bold, etc settings so don't cache
//just on the name, cache map all the input and all the output not just map
//from original selection to output fontname
- FontSelectPattern& rPatternAttributes = rFontSelData;
+ FontSelectPatternAttributes& rPatternAttributes = rFontSelData;
CachedFontMapType &rCachedFontMap = maCachedFontMap;
CachedFontMapType::iterator itr = std::find_if(rCachedFontMap.begin(), rCachedFontMap.end(), equal(rPatternAttributes));
if (itr != rCachedFontMap.end())
{
// Cached substitution
- rFontSelData.copyAttributes(itr->second);
+ rFontSelData = itr->second;
if (itr != rCachedFontMap.begin())
{
// MRU, move it to the front
@@ -120,7 +120,7 @@ bool FcPreMatchSubstitution::FindFontSubstitute( FontSelectPattern &rFontSelData
}
OUString aDummy;
- const FontSelectPattern aOut = GetFcSubstitute( rFontSelData, aDummy );
+ const FontSelectPatternAttributes aOut = GetFcSubstitute( rFontSelData, aDummy );
if( aOut.maSearchName.isEmpty() )
return false;
@@ -155,7 +155,8 @@ bool FcPreMatchSubstitution::FindFontSubstitute( FontSelectPattern &rFontSelData
return bHaveSubstitute;
}
-bool FcGlyphFallbackSubstitution::FindFontSubstitute( FontSelectPattern& rFontSelData,
+bool FcGlyphFallbackSubstitution::FindFontSubstitute(FontSelectPatternAttributes& rFontSelData,
+ LogicalFontInstance* /*pLogicalFont*/,
OUString& rMissingCodes ) const
{
// We don't actually want to talk to Fontconfig at all for symbol fonts
@@ -165,7 +166,7 @@ bool FcGlyphFallbackSubstitution::FindFontSubstitute( FontSelectPattern& rFontSe
if ( IsStarSymbol(rFontSelData.maSearchName) )
return false;
- const FontSelectPattern aOut = GetFcSubstitute( rFontSelData, rMissingCodes );
+ const FontSelectPatternAttributes aOut = GetFcSubstitute( rFontSelData, rMissingCodes );
// TODO: cache the unicode + srcfont specific result
// FC doing it would be preferable because it knows the invariables
// e.g. FC knows the FC rule that all Arial gets replaced by LiberationSans
diff --git a/vcl/win/gdi/salfont.cxx b/vcl/win/gdi/salfont.cxx
index 3fe7b6171453..010142648a5b 100644
--- a/vcl/win/gdi/salfont.cxx
+++ b/vcl/win/gdi/salfont.cxx
@@ -149,7 +149,7 @@ class WinPreMatchFontSubstititution
: public ImplPreMatchFontSubstitution
{
public:
- bool FindFontSubstitute(FontSelectPattern&) const override;
+ bool FindFontSubstitute(FontSelectPatternAttributes&) const override;
};
class WinGlyphFallbackSubstititution
@@ -166,7 +166,7 @@ public:
ReleaseDC(nullptr, mhDC);
};
- bool FindFontSubstitute( FontSelectPattern&, OUString& rMissingChars ) const override;
+ bool FindFontSubstitute(FontSelectPatternAttributes&, LogicalFontInstance* pLogicalFont, OUString& rMissingChars) const override;
private:
HDC mhDC;
bool HasMissingChars(PhysicalFontFace*, OUString& rMissingChars) const;
@@ -257,7 +257,7 @@ static const std::map<OUString, OUString> aBitmapFontSubs =
};
// TODO: See if Windows have API that we can use here to improve font fallback.
-bool WinPreMatchFontSubstititution::FindFontSubstitute(FontSelectPattern& rFontSelData) const
+bool WinPreMatchFontSubstititution::FindFontSubstitute(FontSelectPatternAttributes& rFontSelData) const
{
if (rFontSelData.IsSymbolFont() || IsStarSymbol(rFontSelData.maSearchName))
return false;
@@ -276,7 +276,7 @@ bool WinPreMatchFontSubstititution::FindFontSubstitute(FontSelectPattern& rFontS
// find a fallback font for missing characters
// TODO: should stylistic matches be searched and preferred?
-bool WinGlyphFallbackSubstititution::FindFontSubstitute( FontSelectPattern& rFontSelData, OUString& rMissingChars ) const
+bool WinGlyphFallbackSubstititution::FindFontSubstitute(FontSelectPatternAttributes& rFontSelData, LogicalFontInstance* /*pLogicalFont*/, OUString& rMissingChars) const
{
// guess a locale matching to the missing chars
LanguageType eLang = rFontSelData.meLanguage;