diff options
-rw-r--r-- | vcl/inc/sft.hxx | 16 | ||||
-rw-r--r-- | vcl/qt5/Qt5Graphics_Text.cxx | 12 | ||||
-rw-r--r-- | vcl/quartz/salgdi.cxx | 3 | ||||
-rw-r--r-- | vcl/source/fontsubset/sft.cxx | 17 | ||||
-rw-r--r-- | vcl/win/gdi/salfont.cxx | 10 |
5 files changed, 34 insertions, 24 deletions
diff --git a/vcl/inc/sft.hxx b/vcl/inc/sft.hxx index bcbf74b07aa1..86cb718809b3 100644 --- a/vcl/inc/sft.hxx +++ b/vcl/inc/sft.hxx @@ -470,11 +470,13 @@ class TrueTypeFont; * @param nLen - size of memory buffer * @param facenum - logical font number within a TTC file. This value is ignored * for TrueType fonts - * @param ttf - array of TrueTypeFonts + * @param ttf - returns the opened TrueTypeFont + * @param xCharMap - optional parsed character map * @return value of SFErrCodes enum * @ingroup sft */ - SFErrCodes VCL_DLLPUBLIC OpenTTFontBuffer(const void* pBuffer, sal_uInt32 nLen, sal_uInt32 facenum, TrueTypeFont** ttf); + SFErrCodes VCL_DLLPUBLIC OpenTTFontBuffer(const void* pBuffer, sal_uInt32 nLen, sal_uInt32 facenum, + TrueTypeFont** ttf, const FontCharMapRef xCharMap = nullptr); #if !defined(_WIN32) /** * TrueTypeFont constructor. @@ -483,11 +485,13 @@ class TrueTypeFont; * @param fname - name of TrueType font file * @param facenum - logical font number within a TTC file. This value is ignored * for TrueType fonts - * @param ttf - array of TrueTypeFonts + * @param ttf - returns the opened TrueTypeFont + * @param xCharMap - optional parsed character map * @return value of SFErrCodes enum * @ingroup sft */ - SFErrCodes VCL_DLLPUBLIC OpenTTFontFile(const char *fname, sal_uInt32 facenum, TrueTypeFont** ttf); + SFErrCodes VCL_DLLPUBLIC OpenTTFontFile(const char *fname, sal_uInt32 facenum, TrueTypeFont** ttf, + const FontCharMapRef xCharMap = nullptr); #endif bool VCL_DLLPUBLIC getTTCoverage( @@ -728,7 +732,7 @@ protected: SFErrCodes indexGlyphData(); public: - AbstractTrueTypeFont(const char* fileName = nullptr); + AbstractTrueTypeFont(const char* fileName = nullptr, const FontCharMapRef xCharMap = nullptr); virtual ~AbstractTrueTypeFont(); const char* fileName() const { return m_pFileName; } @@ -765,7 +769,7 @@ public: sal_uInt32 ntables; - TrueTypeFont(const char* pFileName = nullptr); + TrueTypeFont(const char* pFileName = nullptr, const FontCharMapRef xCharMap = nullptr); ~TrueTypeFont() override; SFErrCodes open(sal_uInt32 facenum); diff --git a/vcl/qt5/Qt5Graphics_Text.cxx b/vcl/qt5/Qt5Graphics_Text.cxx index 0fe602d1ce3f..0b823858a9bb 100644 --- a/vcl/qt5/Qt5Graphics_Text.cxx +++ b/vcl/qt5/Qt5Graphics_Text.cxx @@ -137,14 +137,15 @@ class Qt5TrueTypeFont : public vcl::AbstractTrueTypeFont mutable QByteArray m_aFontTable[vcl::NUM_TAGS]; public: - Qt5TrueTypeFont(const QRawFont& aRawFont); + Qt5TrueTypeFont(const Qt5FontFace& aFontFace, const QRawFont& aRawFont); bool hasTable(sal_uInt32 ord) const override; const sal_uInt8* table(sal_uInt32 ord, sal_uInt32& size) const override; }; -Qt5TrueTypeFont::Qt5TrueTypeFont(const QRawFont& aRawFont) - : m_aRawFont(aRawFont) +Qt5TrueTypeFont::Qt5TrueTypeFont(const Qt5FontFace& aFontFace, const QRawFont& aRawFont) + : vcl::AbstractTrueTypeFont(nullptr, aFontFace.GetFontCharMap()) + , m_aRawFont(aRawFont) { indexGlyphData(); } @@ -224,7 +225,8 @@ bool Qt5Graphics::CreateFontSubset(const OUString& rToFile, const PhysicalFontFa return false; // get the raw-bytes from the font to be subset - const QFont aFont = static_cast<const Qt5FontFace*>(pFontFace)->CreateFont(); + const Qt5FontFace* pQt5FontFace = static_cast<const Qt5FontFace*>(pFontFace); + const QFont aFont = pQt5FontFace->CreateFont(); const QRawFont aRawFont(QRawFont::fromFont(aFont)); const QFontInfo aFontInfo(aFont); const OString aToFile(OUStringToOString(aSysPath, osl_getThreadTextEncoding())); @@ -249,7 +251,7 @@ bool Qt5Graphics::CreateFontSubset(const OUString& rToFile, const PhysicalFontFa rInfo.m_nAscent = aRawFont.ascent(); rInfo.m_nDescent = aRawFont.descent(); - Qt5TrueTypeFont aTTF(aRawFont); + Qt5TrueTypeFont aTTF(*pQt5FontFace, aRawFont); int nXmin, nYmin, nXmax, nYmax; sal_uInt16 nMacStyleFlags; if (GetTTGlobalFontHeadInfo(&aTTF, nXmin, nYmin, nXmax, nYmax, nMacStyleFlags)) diff --git a/vcl/quartz/salgdi.cxx b/vcl/quartz/salgdi.cxx index 2c1fdff16eec..1501043924b6 100644 --- a/vcl/quartz/salgdi.cxx +++ b/vcl/quartz/salgdi.cxx @@ -759,7 +759,8 @@ void AquaSalGraphics::GetGlyphWidths( const PhysicalFontFace* pFontData, bool bV // use the font subsetter to get the widths TrueTypeFont* pSftFont = nullptr; - SFErrCodes nRC = ::OpenTTFontBuffer( static_cast<void*>(aBuffer.data()), aBuffer.size(), 0, &pSftFont); + SFErrCodes nRC = ::OpenTTFontBuffer(static_cast<void*>(aBuffer.data()), aBuffer.size(), 0, &pSftFont, + pFontData->GetFontCharMap()); if( nRC != SFErrCodes::Ok ) return; diff --git a/vcl/source/fontsubset/sft.cxx b/vcl/source/fontsubset/sft.cxx index 812c539d6700..6aba6d6d48d2 100644 --- a/vcl/source/fontsubset/sft.cxx +++ b/vcl/source/fontsubset/sft.cxx @@ -1021,7 +1021,8 @@ int CountTTCFonts(const char* fname) } #if !defined(_WIN32) -SFErrCodes OpenTTFontFile( const char* fname, sal_uInt32 facenum, TrueTypeFont** ttf ) +SFErrCodes OpenTTFontFile(const char* fname, sal_uInt32 facenum, TrueTypeFont** ttf, + const FontCharMapRef xCharMap) { SFErrCodes ret; int fd = -1; @@ -1029,7 +1030,7 @@ SFErrCodes OpenTTFontFile( const char* fname, sal_uInt32 facenum, TrueTypeFont** if (!fname || !*fname) return SFErrCodes::BadFile; - *ttf = new TrueTypeFont(fname); + *ttf = new TrueTypeFont(fname, xCharMap); if( ! *ttf ) return SFErrCodes::Memory; @@ -1080,9 +1081,10 @@ cleanup: } #endif -SFErrCodes OpenTTFontBuffer(const void* pBuffer, sal_uInt32 nLen, sal_uInt32 facenum, TrueTypeFont** ttf) +SFErrCodes OpenTTFontBuffer(const void* pBuffer, sal_uInt32 nLen, sal_uInt32 facenum, TrueTypeFont** ttf, + const FontCharMapRef xCharMap) { - *ttf = new TrueTypeFont(); + *ttf = new TrueTypeFont(nullptr, xCharMap); if( *ttf == nullptr ) return SFErrCodes::Memory; @@ -1111,13 +1113,14 @@ bool withinBounds(sal_uInt32 tdoffset, sal_uInt32 moreoffset, sal_uInt32 len, sa } } -AbstractTrueTypeFont::AbstractTrueTypeFont(const char* pFileName) +AbstractTrueTypeFont::AbstractTrueTypeFont(const char* pFileName, const FontCharMapRef xCharMap) : m_pFileName(nullptr) , m_nGlyphs(0xFFFFFFFF) , m_pGlyphOffsets(nullptr) , m_nHorzMetrics(0) , m_nVertMetrics(0) , m_nUnitsPerEm(0) + , m_xCharMap(xCharMap) { if (pFileName) m_pFileName = strdup(pFileName); @@ -1129,8 +1132,8 @@ AbstractTrueTypeFont::~AbstractTrueTypeFont() free(m_pGlyphOffsets); } -TrueTypeFont::TrueTypeFont(const char* pFileName) - : AbstractTrueTypeFont(pFileName) +TrueTypeFont::TrueTypeFont(const char* pFileName, const FontCharMapRef xCharMap) + : AbstractTrueTypeFont(pFileName, xCharMap) , fsize(-1) , ptr(nullptr) , psname(nullptr) diff --git a/vcl/win/gdi/salfont.cxx b/vcl/win/gdi/salfont.cxx index f5f69f3eab33..bc7f83b8b6f2 100644 --- a/vcl/win/gdi/salfont.cxx +++ b/vcl/win/gdi/salfont.cxx @@ -1543,7 +1543,7 @@ public: ~ScopedTrueTypeFont(); - SFErrCodes open(void const * pBuffer, sal_uInt32 nLen, sal_uInt32 nFaceNum); + SFErrCodes open(void const * pBuffer, sal_uInt32 nLen, sal_uInt32 nFaceNum, const FontCharMapRef xCharMap = nullptr); TrueTypeFont * get() const { return m_pFont; } TrueTypeFont* operator->() { return m_pFont; } @@ -1561,10 +1561,10 @@ ScopedTrueTypeFont::~ScopedTrueTypeFont() } SFErrCodes ScopedTrueTypeFont::open(void const * pBuffer, sal_uInt32 nLen, - sal_uInt32 nFaceNum) + sal_uInt32 nFaceNum, const FontCharMapRef xCharMap) { OSL_ENSURE(m_pFont == nullptr, "already open"); - return OpenTTFontBuffer(pBuffer, nLen, nFaceNum, &m_pFont); + return OpenTTFontBuffer(pBuffer, nLen, nFaceNum, &m_pFont, xCharMap); } bool WinSalGraphics::CreateFontSubset( const OUString& rToFile, @@ -1629,7 +1629,7 @@ bool WinSalGraphics::CreateFontSubset( const OUString& rToFile, nFaceNum = ~0U; // indicate "TTC font extracts only" ScopedTrueTypeFont aSftTTF; - SFErrCodes nRC = aSftTTF.open( xRawFontData.get(), xRawFontData.size(), nFaceNum ); + SFErrCodes nRC = aSftTTF.open( xRawFontData.get(), xRawFontData.size(), nFaceNum, pFont->GetFontCharMap()); if( nRC != SFErrCodes::Ok ) return false; @@ -1745,7 +1745,7 @@ void WinSalGraphics::GetGlyphWidths( const PhysicalFontFace* pFont, nFaceNum = ~0U; // indicate "TTC font extracts only" ScopedTrueTypeFont aSftTTF; - SFErrCodes nRC = aSftTTF.open( xRawFontData.get(), xRawFontData.size(), nFaceNum ); + SFErrCodes nRC = aSftTTF.open(xRawFontData.get(), xRawFontData.size(), nFaceNum, pFont->GetFontCharMap()); if( nRC != SFErrCodes::Ok ) return; |