diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2021-05-27 14:01:20 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2021-05-27 21:21:50 +0200 |
commit | 7c1dbb665a3eb7859164dbf83c245b7f450c9028 (patch) | |
tree | 1ba04cb7bb43ff8ffdf3b8b015dd82c25dd83092 /vcl/inc/unx | |
parent | 98a8d8bc15018576e1312493425d7bb3725be735 (diff) |
no need to allocate PrintFont separately
Change-Id: I8bc213e096ad6ae83d88c548ff8685a872c5ea91
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/116258
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'vcl/inc/unx')
-rw-r--r-- | vcl/inc/unx/fontmanager.hxx | 33 |
1 files changed, 19 insertions, 14 deletions
diff --git a/vcl/inc/unx/fontmanager.hxx b/vcl/inc/unx/fontmanager.hxx index 0f5a85d61153..0e2fa772183f 100644 --- a/vcl/inc/unx/fontmanager.hxx +++ b/vcl/inc/unx/fontmanager.hxx @@ -136,7 +136,7 @@ class VCL_PLUGIN_PUBLIC PrintFontManager }; fontID m_nNextFontID; - std::unordered_map< fontID, std::unique_ptr<PrintFont> > m_aFonts; + std::unordered_map< fontID, PrintFont > m_aFonts; // for speeding up findFontFileID std::unordered_map< OString, std::set< fontID > > m_aFontFileToFontID; @@ -146,12 +146,12 @@ class VCL_PLUGIN_PUBLIC PrintFontManager std::unordered_map< int, OString > m_aAtomToDir; int m_nNextDirAtom; - OString getFontFile(const PrintFont* pFont) const; + OString getFontFile(const PrintFont& rFont) const; - std::vector<std::unique_ptr<PrintFont>> analyzeFontFile(int nDirID, const OString& rFileName, const char *pFormat=nullptr) const; + std::vector<PrintFont> analyzeFontFile(int nDirID, const OString& rFileName, const char *pFormat=nullptr) const; static OUString convertSfntName( void* pNameRecord ); // actually a NameRecord* format font subsetting code static void analyzeSfntFamilyName( void const * pTTFont, std::vector< OUString >& rnames ); // actually a TrueTypeFont* from font subsetting code - bool analyzeSfntFile(PrintFont* pFont) const; + bool analyzeSfntFile(PrintFont& rFont) const; // finds the font id for the nFaceIndex face in this font file // There may be multiple font ids for font collections fontID findFontFileID(int nDirID, const OString& rFile, int nFaceIndex, int nVariationIndex) const; @@ -161,13 +161,18 @@ class VCL_PLUGIN_PUBLIC PrintFontManager static FontFamily matchFamilyName( std::u16string_view rFamily ); - PrintFont* getFont( fontID nID ) const + const PrintFont* getFont( fontID nID ) const { auto it = m_aFonts.find( nID ); - return it == m_aFonts.end() ? nullptr : it->second.get(); + return it == m_aFonts.end() ? nullptr : &it->second; } - static void fillPrintFontInfo(PrintFont* pFont, FastPrintFontInfo& rInfo); - void fillPrintFontInfo( PrintFont* pFont, PrintFontInfo& rInfo ) const; + PrintFont* getFont( fontID nID ) + { + auto it = m_aFonts.find( nID ); + return it == m_aFonts.end() ? nullptr : &it->second; + } + static void fillPrintFontInfo(const PrintFont& rFont, FastPrintFontInfo& rInfo); + void fillPrintFontInfo( PrintFont& rFont, PrintFontInfo& rInfo ) const; OString getDirectory( int nAtom ) const; int getDirectoryAtom( const OString& rDirectory ); @@ -217,26 +222,26 @@ public: // routines to get font info in small pieces // get a specific fonts PSName name - OUString getPSName( fontID nFontID ) const; + OUString getPSName( fontID nFontID ); // get a specific fonts italic type FontItalic getFontItalic( fontID nFontID ) const { - PrintFont* pFont = getFont( nFontID ); + const PrintFont* pFont = getFont( nFontID ); return pFont ? pFont->m_eItalic : ITALIC_DONTKNOW; } // get a specific fonts weight type FontWeight getFontWeight( fontID nFontID ) const { - PrintFont* pFont = getFont( nFontID ); + const PrintFont* pFont = getFont( nFontID ); return pFont ? pFont->m_eWeight : WEIGHT_DONTKNOW; } // get a specific fonts system dependent filename OString getFontFileSysPath( fontID nFontID ) const { - return getFontFile( getFont( nFontID ) ); + return getFontFile( *getFont( nFontID ) ); } // get the ttc face number @@ -246,10 +251,10 @@ public: int getFontFaceVariation( fontID nFontID ) const; // get a specific fonts ascend - int getFontAscend( fontID nFontID ) const; + int getFontAscend( fontID nFontID ); // get a specific fonts descent - int getFontDescend( fontID nFontID ) const; + int getFontDescend( fontID nFontID ); // get a fonts glyph bounding box void getFontBoundingBox( fontID nFont, int& xMin, int& yMin, int& xMax, int& yMax ); |