summaryrefslogtreecommitdiff
path: root/vcl/unx/generic
diff options
context:
space:
mode:
Diffstat (limited to 'vcl/unx/generic')
-rw-r--r--vcl/unx/generic/fontmanager/fontconfig.cxx40
-rw-r--r--vcl/unx/generic/fontmanager/fontmanager.cxx88
-rw-r--r--vcl/unx/generic/gdi/freetypetextrender.cxx39
-rw-r--r--vcl/unx/generic/print/genpspgraphics.cxx16
4 files changed, 75 insertions, 108 deletions
diff --git a/vcl/unx/generic/fontmanager/fontconfig.cxx b/vcl/unx/generic/fontmanager/fontconfig.cxx
index 57af5949bfe1..ad9bf6c268ab 100644
--- a/vcl/unx/generic/fontmanager/fontconfig.cxx
+++ b/vcl/unx/generic/fontmanager/fontconfig.cxx
@@ -706,17 +706,18 @@ void PrintFontManager::countFontconfigFonts()
if (xUpdate)
{
+ auto& rDFA = xUpdate->m_aFontAttributes;
// set family name
if( eWeightRes == FcResultMatch )
- xUpdate->m_eWeight = convertWeight(weight);
+ rDFA.SetWeight(convertWeight(weight));
if( eWidthRes == FcResultMatch )
- xUpdate->m_eWidth = convertWidth(width);
+ rDFA.SetWidthType(convertWidth(width));
if( eSpacRes == FcResultMatch )
- xUpdate->m_ePitch = convertSpacing(spacing);
+ rDFA.SetPitch(convertSpacing(spacing));
if( eSlantRes == FcResultMatch )
- xUpdate->m_eItalic = convertSlant(slant);
+ rDFA.SetItalic(convertSlant(slant));
if( eStyleRes == FcResultMatch )
- xUpdate->m_aStyleName = OStringToOUString( std::string_view( reinterpret_cast<char*>(style) ), RTL_TEXTENCODING_UTF8 );
+ rDFA.SetStyleName(OStringToOUString( std::string_view( reinterpret_cast<char*>(style) ), RTL_TEXTENCODING_UTF8 ));
if( eIndexRes == FcResultMatch )
xUpdate->m_nVariationEntry = GetVariationIndex(nEntryId);
@@ -1076,12 +1077,12 @@ void PrintFontManager::Substitute(vcl::font::FontSelectPattern &rPattern, OUStri
OString aDir, aBase, aOrgPath( reinterpret_cast<char*>(file) );
splitPath( aOrgPath, aDir, aBase );
int nDirID = getDirectoryAtom( aDir );
- fontID aFont = findFontFileID(nDirID, aBase, GetCollectionIndex(nEntryId), GetVariationIndex(nEntryId));
- if( aFont > 0 )
+ fontID nFontID = findFontFileID(nDirID, aBase, GetCollectionIndex(nEntryId), GetVariationIndex(nEntryId));
+ auto const* pFont = getFont(nFontID);
+ if (pFont)
{
- FastPrintFontInfo aInfo;
- bRet = getFontFastInfo( aFont, aInfo );
- rPattern.maSearchName = aInfo.m_aFamilyName;
+ rPattern.maSearchName = pFont->m_aFontAttributes.GetFamilyName();
+ bRet = true;
}
}
@@ -1269,8 +1270,9 @@ std::unique_ptr<FontConfigFontOptions> PrintFontManager::getFontOptions(const Fo
}
-void PrintFontManager::matchFont( FastPrintFontInfo& rInfo, const css::lang::Locale& rLocale )
+bool PrintFontManager::matchFont(FontAttributes& rDFA, const css::lang::Locale& rLocale)
{
+ bool bFound = false;
FontCfgWrapper& rWrapper = FontCfgWrapper::get();
FcConfig* pConfig = FcConfigGetCurrent();
@@ -1282,11 +1284,11 @@ void PrintFontManager::matchFont( FastPrintFontInfo& rInfo, const css::lang::Loc
if (!aLangAttrib.isEmpty())
FcPatternAddString(pPattern, FC_LANG, reinterpret_cast<FcChar8 const *>(aLangAttrib.getStr()));
- OString aFamily = OUStringToOString( rInfo.m_aFamilyName, RTL_TEXTENCODING_UTF8 );
+ OString aFamily = OUStringToOString(rDFA.GetFamilyName(), RTL_TEXTENCODING_UTF8);
if( !aFamily.isEmpty() )
FcPatternAddString(pPattern, FC_FAMILY, reinterpret_cast<FcChar8 const *>(aFamily.getStr()));
- addtopattern(pPattern, rInfo.m_eItalic, rInfo.m_eWeight, rInfo.m_eWidth, rInfo.m_ePitch);
+ addtopattern(pPattern, rDFA.GetItalic(), rDFA.GetWeight(), rDFA.GetWidthType(), rDFA.GetPitch());
FcConfigSubstitute(pConfig, pPattern, FcMatchPattern);
FcDefaultSubstitute(pPattern);
@@ -1311,11 +1313,15 @@ void PrintFontManager::matchFont( FastPrintFontInfo& rInfo, const css::lang::Loc
OString aDir, aBase, aOrgPath( reinterpret_cast<char*>(file) );
splitPath( aOrgPath, aDir, aBase );
int nDirID = getDirectoryAtom( aDir );
- fontID aFont = findFontFileID(nDirID, aBase,
+ fontID nFontID = findFontFileID(nDirID, aBase,
GetCollectionIndex(nEntryId),
GetVariationIndex(nEntryId));
- if( aFont > 0 )
- getFontFastInfo( aFont, rInfo );
+ auto const* pFont = getFont(nFontID);
+ if (pFont)
+ {
+ rDFA = pFont->m_aFontAttributes;
+ bFound = true;
+ }
}
}
// info: destroying the pSet destroys pResult implicitly
@@ -1325,6 +1331,8 @@ void PrintFontManager::matchFont( FastPrintFontInfo& rInfo, const css::lang::Loc
// cleanup
FcPatternDestroy( pPattern );
+
+ return bFound;
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/unx/generic/fontmanager/fontmanager.cxx b/vcl/unx/generic/fontmanager/fontmanager.cxx
index 2a6333f6d93e..a3d77c6ae99e 100644
--- a/vcl/unx/generic/fontmanager/fontmanager.cxx
+++ b/vcl/unx/generic/fontmanager/fontmanager.cxx
@@ -81,13 +81,7 @@ static sal_uInt16 getUInt16BE( const sal_uInt8*& pBuffer )
* PrintFont implementations
*/
PrintFontManager::PrintFont::PrintFont()
-: m_eFamilyStyle(FAMILY_DONTKNOW)
-, m_eItalic(ITALIC_DONTKNOW)
-, m_eWidth(WIDTH_DONTKNOW)
-, m_eWeight(WEIGHT_DONTKNOW)
-, m_ePitch(PITCH_DONTKNOW)
-, m_aEncoding(RTL_TEXTENCODING_DONTKNOW)
-, m_nDirectory(0)
+: m_nDirectory(0)
, m_nCollectionEntry(0)
, m_nVariationEntry(0)
{
@@ -514,20 +508,23 @@ bool PrintFontManager::analyzeSfntFile( PrintFont& rFont ) const
OString aFile = getFontFile( rFont );
TrueTypeFont* pTTFont = nullptr;
+ auto& rDFA = rFont.m_aFontAttributes;
+ rDFA.SetQuality(512);
+
auto const e = OpenTTFontFile( aFile.getStr(), rFont.m_nCollectionEntry, &pTTFont );
if( e == SFErrCodes::Ok )
{
TTGlobalFontInfo aInfo;
GetTTGlobalFontInfo( pTTFont, & aInfo );
- if (rFont.m_aFamilyName.isEmpty())
+ if (rDFA.GetFamilyName().isEmpty())
{
::std::vector< OUString > aNames;
analyzeSfntFamilyName( pTTFont, aNames );
if( !aNames.empty() )
{
- rFont.m_aFamilyName = aNames.front();
+ rDFA.SetFamilyName(aNames.front());
aNames.erase(aNames.begin());
}
else
@@ -540,53 +537,53 @@ bool PrintFontManager::analyzeSfntFile( PrintFont& rFont ) const
if ( dotIndex == -1 )
dotIndex = rFont.m_aFontFile.getLength();
- rFont.m_aFamilyName = OStringToOUString(rFont.m_aFontFile.subView(0, dotIndex), aEncoding);
+ rDFA.SetFamilyName(OStringToOUString(rFont.m_aFontFile.subView(0, dotIndex), aEncoding));
}
}
if( !aInfo.usubfamily.isEmpty() )
- rFont.m_aStyleName = aInfo.usubfamily;
+ rDFA.SetStyleName(aInfo.usubfamily);
- rFont.m_eFamilyStyle = matchFamilyName(rFont.m_aFamilyName);
+ rDFA.SetFamilyType(matchFamilyName(rDFA.GetFamilyName()));
switch( aInfo.weight )
{
- case FW_THIN: rFont.m_eWeight = WEIGHT_THIN; break;
- case FW_EXTRALIGHT: rFont.m_eWeight = WEIGHT_ULTRALIGHT; break;
- case FW_LIGHT: rFont.m_eWeight = WEIGHT_LIGHT; break;
- case FW_MEDIUM: rFont.m_eWeight = WEIGHT_MEDIUM; break;
- case FW_SEMIBOLD: rFont.m_eWeight = WEIGHT_SEMIBOLD; break;
- case FW_BOLD: rFont.m_eWeight = WEIGHT_BOLD; break;
- case FW_EXTRABOLD: rFont.m_eWeight = WEIGHT_ULTRABOLD; break;
- case FW_BLACK: rFont.m_eWeight = WEIGHT_BLACK; break;
+ case FW_THIN: rDFA.SetWeight(WEIGHT_THIN); break;
+ case FW_EXTRALIGHT: rDFA.SetWeight(WEIGHT_ULTRALIGHT); break;
+ case FW_LIGHT: rDFA.SetWeight(WEIGHT_LIGHT); break;
+ case FW_MEDIUM: rDFA.SetWeight(WEIGHT_MEDIUM); break;
+ case FW_SEMIBOLD: rDFA.SetWeight(WEIGHT_SEMIBOLD); break;
+ case FW_BOLD: rDFA.SetWeight(WEIGHT_BOLD); break;
+ case FW_EXTRABOLD: rDFA.SetWeight(WEIGHT_ULTRABOLD); break;
+ case FW_BLACK: rDFA.SetWeight(WEIGHT_BLACK); break;
case FW_NORMAL:
- default: rFont.m_eWeight = WEIGHT_NORMAL; break;
+ default: rDFA.SetWeight(WEIGHT_NORMAL); break;
}
switch( aInfo.width )
{
- case FWIDTH_ULTRA_CONDENSED: rFont.m_eWidth = WIDTH_ULTRA_CONDENSED; break;
- case FWIDTH_EXTRA_CONDENSED: rFont.m_eWidth = WIDTH_EXTRA_CONDENSED; break;
- case FWIDTH_CONDENSED: rFont.m_eWidth = WIDTH_CONDENSED; break;
- case FWIDTH_SEMI_CONDENSED: rFont.m_eWidth = WIDTH_SEMI_CONDENSED; break;
- case FWIDTH_SEMI_EXPANDED: rFont.m_eWidth = WIDTH_SEMI_EXPANDED; break;
- case FWIDTH_EXPANDED: rFont.m_eWidth = WIDTH_EXPANDED; break;
- case FWIDTH_EXTRA_EXPANDED: rFont.m_eWidth = WIDTH_EXTRA_EXPANDED; break;
- case FWIDTH_ULTRA_EXPANDED: rFont.m_eWidth = WIDTH_ULTRA_EXPANDED; break;
+ case FWIDTH_ULTRA_CONDENSED: rDFA.SetWidthType(WIDTH_ULTRA_CONDENSED); break;
+ case FWIDTH_EXTRA_CONDENSED: rDFA.SetWidthType(WIDTH_EXTRA_CONDENSED); break;
+ case FWIDTH_CONDENSED: rDFA.SetWidthType(WIDTH_CONDENSED); break;
+ case FWIDTH_SEMI_CONDENSED: rDFA.SetWidthType(WIDTH_SEMI_CONDENSED); break;
+ case FWIDTH_SEMI_EXPANDED: rDFA.SetWidthType(WIDTH_SEMI_EXPANDED); break;
+ case FWIDTH_EXPANDED: rDFA.SetWidthType(WIDTH_EXPANDED); break;
+ case FWIDTH_EXTRA_EXPANDED: rDFA.SetWidthType(WIDTH_EXTRA_EXPANDED); break;
+ case FWIDTH_ULTRA_EXPANDED: rDFA.SetWidthType(WIDTH_ULTRA_EXPANDED); break;
case FWIDTH_NORMAL:
- default: rFont.m_eWidth = WIDTH_NORMAL; break;
+ default: rDFA.SetWidthType(WIDTH_NORMAL); break;
}
- rFont.m_ePitch = aInfo.pitch ? PITCH_FIXED : PITCH_VARIABLE;
- rFont.m_eItalic = aInfo.italicAngle == 0 ? ITALIC_NONE : ( aInfo.italicAngle < 0 ? ITALIC_NORMAL : ITALIC_OBLIQUE );
+ rDFA.SetPitch(aInfo.pitch ? PITCH_FIXED : PITCH_VARIABLE);
+ rDFA.SetItalic(aInfo.italicAngle == 0 ? ITALIC_NONE : (aInfo.italicAngle < 0 ? ITALIC_NORMAL : ITALIC_OBLIQUE));
// #104264# there are fonts that set italic angle 0 although they are
// italic; use macstyle bit here
if( aInfo.italicAngle == 0 && (aInfo.macStyle & 2) )
- rFont.m_eItalic = ITALIC_NORMAL;
+ rDFA.SetItalic(ITALIC_NORMAL);
- rFont.m_aEncoding = aInfo.microsoftSymbolEncoded ? RTL_TEXTENCODING_SYMBOL : RTL_TEXTENCODING_UCS2;
+ rDFA.SetMicrosoftSymbolEncoded(aInfo.microsoftSymbolEncoded);
CloseTTFont( pTTFont );
bSuccess = true;
@@ -675,29 +672,6 @@ void PrintFontManager::getFontList( ::std::vector< fontID >& rFontIDs )
rFontIDs.push_back(font.first);
}
-void PrintFontManager::fillPrintFontInfo(const PrintFont& rFont, FastPrintFontInfo& rInfo)
-{
- rInfo.m_aFamilyName = rFont.m_aFamilyName;
- rInfo.m_aStyleName = rFont.m_aStyleName;
- rInfo.m_eFamilyStyle = rFont.m_eFamilyStyle;
- rInfo.m_eItalic = rFont.m_eItalic;
- rInfo.m_eWidth = rFont.m_eWidth;
- rInfo.m_eWeight = rFont.m_eWeight;
- rInfo.m_ePitch = rFont.m_ePitch;
- rInfo.m_aEncoding = rFont.m_aEncoding;
-}
-
-bool PrintFontManager::getFontFastInfo( fontID nFontID, FastPrintFontInfo& rInfo ) const
-{
- const PrintFont* pFont = getFont( nFontID );
- if( pFont )
- {
- rInfo.m_nID = nFontID;
- fillPrintFontInfo( *pFont, rInfo );
- }
- return pFont != nullptr;
-}
-
int PrintFontManager::getFontFaceNumber( fontID nFontID ) const
{
int nRet = 0;
diff --git a/vcl/unx/generic/gdi/freetypetextrender.cxx b/vcl/unx/generic/gdi/freetypetextrender.cxx
index e8eb6c4febab..b524a45ee73b 100644
--- a/vcl/unx/generic/gdi/freetypetextrender.cxx
+++ b/vcl/unx/generic/gdi/freetypetextrender.cxx
@@ -28,7 +28,7 @@
#include <vcl/fontcharmap.hxx>
#include <sal/log.hxx>
-#include <unx/genpspgraphics.h>
+#include <unx/fontmanager.hxx>
#include <unx/geninst.h>
#include <unx/glyphcache.hxx>
#include <unx/fc_fontoptions.hxx>
@@ -103,23 +103,24 @@ bool FreeTypeTextRenderImpl::AddTempDevFont(vcl::font::PhysicalFontCollection* p
return false;
FreetypeManager& rFreetypeManager = FreetypeManager::get();
- for (auto const& elem : aFontIds)
+ for (auto const& nFontId : aFontIds)
{
// prepare font data
- psp::FastPrintFontInfo aInfo;
- rMgr.getFontFastInfo(elem, aInfo);
- if (!rFontName.isEmpty())
- aInfo.m_aFamilyName = rFontName;
+ auto const* pFont = rMgr.getFont(nFontId);
+ if (!pFont)
+ continue;
// inform glyph cache of new font
- FontAttributes aDFA = GenPspGraphics::Info2FontAttributes(aInfo);
+ FontAttributes aDFA = pFont->m_aFontAttributes;
aDFA.IncreaseQualityBy(5800);
+ if (!rFontName.isEmpty())
+ aDFA.SetFamilyName(rFontName);
- int nFaceNum = rMgr.getFontFaceNumber(aInfo.m_nID);
- int nVariantNum = rMgr.getFontFaceVariation(aInfo.m_nID);
+ int nFaceNum = rMgr.getFontFaceNumber(nFontId);
+ int nVariantNum = rMgr.getFontFaceVariation(nFontId);
- const OString& rFileName = rMgr.getFontFileSysPath(aInfo.m_nID);
- rFreetypeManager.AddFontFile(rFileName, nFaceNum, nVariantNum, aInfo.m_nID, aDFA);
+ const OString& rFileName = rMgr.getFontFileSysPath(nFontId);
+ rFreetypeManager.AddFontFile(rFileName, nFaceNum, nVariantNum, nFontId, aDFA);
}
// announce new font to device's font list
@@ -139,22 +140,22 @@ void FreeTypeTextRenderImpl::GetDevFontList(vcl::font::PhysicalFontCollection* p
psp::PrintFontManager& rMgr = psp::PrintFontManager::get();
::std::vector<psp::fontID> aList;
- psp::FastPrintFontInfo aInfo;
rMgr.getFontList(aList);
- for (auto const& elem : aList)
+ for (auto const& nFontId : aList)
{
- if (!rMgr.getFontFastInfo(elem, aInfo))
+ auto const* pFont = rMgr.getFont(nFontId);
+ if (!pFont)
continue;
// normalize face number to the FreetypeManager
- int nFaceNum = rMgr.getFontFaceNumber(aInfo.m_nID);
- int nVariantNum = rMgr.getFontFaceVariation(aInfo.m_nID);
+ int nFaceNum = rMgr.getFontFaceNumber(nFontId);
+ int nVariantNum = rMgr.getFontFaceVariation(nFontId);
// inform FreetypeManager about this font provided by the PsPrint subsystem
- FontAttributes aDFA = GenPspGraphics::Info2FontAttributes(aInfo);
+ FontAttributes aDFA = pFont->m_aFontAttributes;
aDFA.IncreaseQualityBy(4096);
- const OString& rFileName = rMgr.getFontFileSysPath(aInfo.m_nID);
- rFreetypeManager.AddFontFile(rFileName, nFaceNum, nVariantNum, aInfo.m_nID, aDFA);
+ const OString& rFileName = rMgr.getFontFileSysPath(nFontId);
+ rFreetypeManager.AddFontFile(rFileName, nFaceNum, nVariantNum, nFontId, aDFA);
}
// announce glyphcache fonts
diff --git a/vcl/unx/generic/print/genpspgraphics.cxx b/vcl/unx/generic/print/genpspgraphics.cxx
index 9ffc75826b50..66bf4524748f 100644
--- a/vcl/unx/generic/print/genpspgraphics.cxx
+++ b/vcl/unx/generic/print/genpspgraphics.cxx
@@ -138,22 +138,6 @@ std::unique_ptr<GenericSalLayout> GenPspGraphics::GetTextLayout(int nFallbackLev
return m_aTextRenderImpl.GetTextLayout(nFallbackLevel);
}
-FontAttributes GenPspGraphics::Info2FontAttributes( const psp::FastPrintFontInfo& rInfo )
-{
- FontAttributes aDFA;
- aDFA.SetFamilyName( rInfo.m_aFamilyName );
- aDFA.SetStyleName( rInfo.m_aStyleName );
- aDFA.SetFamilyType( rInfo.m_eFamilyStyle );
- aDFA.SetWeight( rInfo.m_eWeight );
- aDFA.SetItalic( rInfo.m_eItalic );
- aDFA.SetWidthType( rInfo.m_eWidth );
- aDFA.SetPitch( rInfo.m_ePitch );
- aDFA.SetMicrosoftSymbolEncoded( rInfo.m_aEncoding == RTL_TEXTENCODING_SYMBOL );
- aDFA.SetQuality(512);
-
- return aDFA;
-}
-
namespace vcl
{
const char* getLangBoost()