diff options
Diffstat (limited to 'sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.cxx')
-rw-r--r-- | sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.cxx | 57 |
1 files changed, 48 insertions, 9 deletions
diff --git a/sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.cxx b/sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.cxx index 16ad04bf660a..676aefe91859 100644 --- a/sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.cxx +++ b/sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.cxx @@ -432,14 +432,19 @@ int PDFOutDev::parseFont( long long nNewId, GfxFont* gfxFont, GfxState* state ) FontAttributes aNewFont; int nSize = 0; -#if POPPLER_CHECK_VERSION(0, 64, 0) - const +#if POPPLER_CHECK_VERSION(20, 12, 0) + std::string familyName = gfxFont->getNameWithoutSubsetTag(); +#else + std::string familyName = gfxFont->getName()->toStr(); + if (familyName.length() > 7 && familyName.at(6) == '+') + { + familyName = familyName.substr(7); + } #endif - GooString* pFamily = gfxFont->getName(); - if( pFamily ) + if( familyName != "" ) { aNewFont.familyName.clear(); - aNewFont.familyName.append( gfxFont->getName() ); + aNewFont.familyName.append( familyName ); } else { @@ -456,12 +461,21 @@ int PDFOutDev::parseFont( long long nNewId, GfxFont* gfxFont, GfxState* state ) { // TODO(P3): Unfortunately, need to read stream twice, since // we must write byte count to stdout before +#if POPPLER_CHECK_VERSION(22, 6, 0) + std::optional<std::vector<unsigned char>> pBuf = gfxFont->readEmbFontFile( m_pDoc->getXRef() ); + if ( pBuf ) + { + aNewFont.isEmbedded = true; + nSize = pBuf->size(); + } +#else char* pBuf = gfxFont->readEmbFontFile( m_pDoc->getXRef(), &nSize ); if( pBuf ) { aNewFont.isEmbedded = true; gfree(pBuf); } +#endif } m_aFontMap[ nNewId ] = aNewFont; @@ -474,13 +488,29 @@ void PDFOutDev::writeFontFile( GfxFont* gfxFont ) const return; int nSize = 0; +#if POPPLER_CHECK_VERSION(22, 6, 0) + std::optional<std::vector<unsigned char>> pBuf = gfxFont->readEmbFontFile( m_pDoc->getXRef() ); + if ( pBuf ) + nSize = pBuf->size(); + if ( nSize == 0 ) + return; +#else char* pBuf = gfxFont->readEmbFontFile( m_pDoc->getXRef(), &nSize ); if( !pBuf ) return; +#endif // ---sync point--- see SYNC STREAMS above fflush(stdout); +#if POPPLER_CHECK_VERSION(22, 6, 0) + if( fwrite(pBuf->data(), sizeof(*pBuf->data()), nSize, g_binary_out) != static_cast<size_t>(nSize) ) + { + exit(1); // error + } + // ---sync point--- see SYNC STREAMS above + fflush(g_binary_out); +#else if( fwrite(pBuf, sizeof(char), nSize, g_binary_out) != static_cast<size_t>(nSize) ) { gfree(pBuf); @@ -489,6 +519,7 @@ void PDFOutDev::writeFontFile( GfxFont* gfxFont ) const // ---sync point--- see SYNC STREAMS above fflush(g_binary_out); gfree(pBuf); +#endif } #if POPPLER_CHECK_VERSION(0, 83, 0) @@ -635,8 +666,15 @@ void PDFOutDev::updateLineDash(GfxState *state) return; assert(state); - double* dashArray; int arrayLen; double startOffset; + int arrayLen; double startOffset; +#if POPPLER_CHECK_VERSION(22, 9, 0) + const std::vector<double> &dash = state->getLineDash(&startOffset); + const double* dashArray = dash.data(); + arrayLen = dash.size(); +#else + double* dashArray; state->getLineDash(&dashArray, &arrayLen, &startOffset); +#endif printf( "updateLineDash" ); if( arrayLen && dashArray ) @@ -742,7 +780,11 @@ void PDFOutDev::updateFont(GfxState *state) { assert(state); +#if POPPLER_CHECK_VERSION(22, 6, 0) + GfxFont *gfxFont = state->getFont().get(); +#else GfxFont *gfxFont = state->getFont(); +#endif if( !gfxFont ) return; @@ -786,9 +828,6 @@ void PDFOutDev::updateFont(GfxState *state) aEsc.data() ); } printf( "\n" ); - - if( nEmbedSize ) - writeFontFile(gfxFont); } void PDFOutDev::updateRender(GfxState *state) |