diff options
author | Jan-Marek Glogowski <glogow@fbihome.de> | 2020-09-13 15:01:22 +0200 |
---|---|---|
committer | Jan-Marek Glogowski <glogow@fbihome.de> | 2020-09-15 06:43:42 +0200 |
commit | bdde33ea94b77f50ca58b82bed86d6fcde77749c (patch) | |
tree | 3f605a937a3f239a21f588c967ebe543f5d6cd65 /vcl/win | |
parent | 5ebc5f9df6972ac3d9ce7ed6a1504c48535c0881 (diff) |
WIN OSX Qt5 unify CreateFontSubset code
This is basically just some refactoring. Most interestingly the
MacOS used to work with 257 glyphs. I couldn't find any
explaination for the 256 glyph limit. Sadly the PrintFontManager
is out of scope. That needs more inspection.
Change-Id: Ibfa0e905f5efeb7d4a609884d64b4ed2615a9d3d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/102688
Reviewed-by: Jan-Marek Glogowski <glogow@fbihome.de>
Tested-by: Jenkins
Diffstat (limited to 'vcl/win')
-rw-r--r-- | vcl/win/gdi/salfont.cxx | 69 |
1 files changed, 8 insertions, 61 deletions
diff --git a/vcl/win/gdi/salfont.cxx b/vcl/win/gdi/salfont.cxx index bc7f83b8b6f2..0d7930d20e71 100644 --- a/vcl/win/gdi/salfont.cxx +++ b/vcl/win/gdi/salfont.cxx @@ -1605,17 +1605,12 @@ bool WinSalGraphics::CreateFontSubset( const OUString& rToFile, // check if the font has a CFF-table const DWORD nCffTag = CalcTag( "CFF " ); const RawFontData aRawCffData( getHDC(), nCffTag ); - if( aRawCffData.get() ) + if (aRawCffData.get()) { pWinFontData->UpdateFromHDC( getHDC() ); - - // provide a font subset from the CFF-table - FILE* pOutFile = fopen( aToFile.getStr(), "wb" ); - rInfo.LoadFont( FontType::CFF_FONT, aRawCffData.get(), aRawCffData.size() ); - bool bRC = rInfo.CreateFontSubset( FontType::TYPE1_PFB, pOutFile, nullptr, - pGlyphIds, pEncoding, nGlyphCount, pGlyphWidths ); - fclose( pOutFile ); - return bRC; + return SalGraphics::CreateCFFfontSubset(aRawCffData.get(), aRawCffData.size(), aToFile, + pGlyphIds, pEncoding, pGlyphWidths, nGlyphCount, + rInfo); } // get raw font file data @@ -1635,60 +1630,12 @@ bool WinSalGraphics::CreateFontSubset( const OUString& rToFile, TTGlobalFontInfo aTTInfo; ::GetTTGlobalFontInfo( aSftTTF.get(), &aTTInfo ); - rInfo.m_nFontType = FontType::SFNT_TTF; - rInfo.m_aPSName = ImplSalGetUniString( aTTInfo.psname ); - rInfo.m_nAscent = aTTInfo.winAscent; - rInfo.m_nDescent = aTTInfo.winDescent; - rInfo.m_aFontBBox = tools::Rectangle( Point( aTTInfo.xMin, aTTInfo.yMin ), - Point( aTTInfo.xMax, aTTInfo.yMax ) ); - rInfo.m_nCapHeight = aTTInfo.yMax; // Well ... - - // subset TTF-glyphs and get their properties - // take care that subset fonts require the NotDef glyph in pos 0 - int nOrigCount = nGlyphCount; - sal_uInt16 aShortIDs[ 256 ]; - sal_uInt8 aTempEncs[ 256 ]; - - int nNotDef=-1, i; - for( i = 0; i < nGlyphCount; ++i ) - { - aTempEncs[i] = pEncoding[i]; - aShortIDs[i] = static_cast<sal_uInt16>(pGlyphIds[i]); - if (!aShortIDs[i]) - if( nNotDef < 0 ) - nNotDef = i; // first NotDef glyph found - } - - if( nNotDef != 0 ) - { - // add fake NotDef glyph if needed - if( nNotDef < 0 ) - nNotDef = nGlyphCount++; - - // NotDef glyph must be in pos 0 => swap glyphids - aShortIDs[ nNotDef ] = aShortIDs[0]; - aTempEncs[ nNotDef ] = aTempEncs[0]; - aShortIDs[0] = 0; - aTempEncs[0] = 0; - } - SAL_WARN_IF( nGlyphCount >= 257, "vcl", "too many glyphs for subsetting" ); - - // fill pWidth array - std::unique_ptr<sal_uInt16[]> pMetrics = - ::GetTTSimpleGlyphMetrics( aSftTTF.get(), aShortIDs, nGlyphCount, aIFSD.mbVertical ); - if( !pMetrics ) - return false; - sal_uInt16 nNotDefAdv = pMetrics[0]; - pMetrics[0] = pMetrics[nNotDef]; - pMetrics[nNotDef] = nNotDefAdv; - for( i = 0; i < nOrigCount; ++i ) - pGlyphWidths[i] = pMetrics[i]; - pMetrics.reset(); + OUString aPSName = ImplSalGetUniString(aTTInfo.psname); + FillFontSubsetInfo(aTTInfo, aPSName, rInfo); // write subset into destination file - nRC = ::CreateTTFromTTGlyphs( aSftTTF.get(), aToFile.getStr(), aShortIDs, - aTempEncs, nGlyphCount ); - return (nRC == SFErrCodes::Ok); + return SalGraphics::CreateTTFfontSubset(*aSftTTF.get(), aToFile, aIFSD.mbVertical, pGlyphIds, + pEncoding, pGlyphWidths, nGlyphCount); } const void* WinSalGraphics::GetEmbedFontData(const PhysicalFontFace* pFont, long* pDataLen) |