[Libreoffice-commits] core.git: Branch 'libreoffice-7-2' - sdext/source

Kevin Suo (via logerrit) logerrit at kemper.freedesktop.org
Mon Jul 12 16:47:11 UTC 2021


 sdext/source/pdfimport/wrapper/wrapper.cxx            |   52 ------------------
 sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.cxx |    9 +--
 2 files changed, 3 insertions(+), 58 deletions(-)

New commits:
commit ac3207d3b2c3b6580de14132fd12e9c6fedc6502
Author:     Kevin Suo <suokunlong at 126.com>
AuthorDate: Sat Jul 10 11:47:39 2021 +0800
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Mon Jul 12 18:46:36 2021 +0200

    tdf#78427 sdext.pdfimport: No need to read a font file for the purpose of...
    
    ...determining the bold/italic/underline etc.
    
    The purpose for reading a font file is that in case the font attributes determined by the xpdfimport process is not enough, then we use the lo core font classes which read in the font file and then determine whether it is bold, italic etc.
    However, while this works in some cases, it does not work in many cases when the font file was actually a subset and a toUnicode map is followed in the PDF, see tdf#78427.
    In addition, in case the information collected from the xpdfimport process is enough, there is no need to read the font file.
    
    This commit removes the read of font file part. Also, this commit uses gfxFont->getNameWithoutSubsetTag() to get the font name with the subset tags removed, thus simplified the code in wrapper.cxx while also improves performace as the remove of subset tags is only run when the font is a subset (the previous code did this for all the font names).
    
    Change-Id: I94c1ad8e743abfab81cf0a46da178d4d8b212427
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118733
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
    Tested-by: Jenkins
    (cherry picked from commit c8d4ced79eaad886d6e863a52d70c24ca9d4be48)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118724

diff --git a/sdext/source/pdfimport/wrapper/wrapper.cxx b/sdext/source/pdfimport/wrapper/wrapper.cxx
index 2221f1ebe33f..ae4903526c65 100644
--- a/sdext/source/pdfimport/wrapper/wrapper.cxx
+++ b/sdext/source/pdfimport/wrapper/wrapper.cxx
@@ -514,12 +514,6 @@ void LineParser::parseFontFamilyName( FontAttributes& rResult )
 
     const sal_Unicode* pCopy = rResult.familyName.getStr();
     sal_Int32 nLen = rResult.familyName.getLength();
-    // parse out truetype subsets (e.g. BAAAAA+Thorndale)
-    if( nLen > 8 && pCopy[6] == '+' )
-    {
-        pCopy += 7;
-        nLen -= 7;
-    }
 
     // TODO: Looks like this block needs to be refactored
     while( nLen )
@@ -641,52 +635,6 @@ void LineParser::readFont()
 
     // extract textual attributes (bold, italic in the name, etc.)
     parseFontFamilyName(aResult);
-    // need to read font file?
-    if( nFileLen )
-    {
-        uno::Sequence<sal_Int8> aFontFile(nFileLen);
-        readBinaryData( aFontFile );
-
-        awt::FontDescriptor aFD;
-        uno::Sequence< uno::Any > aArgs(1);
-        aArgs[0] <<= aFontFile;
-
-        try
-        {
-            uno::Reference< beans::XMaterialHolder > xMat(
-                m_parser.m_xContext->getServiceManager()->createInstanceWithArgumentsAndContext(
-                    "com.sun.star.awt.FontIdentificator", aArgs, m_parser.m_xContext ),
-                uno::UNO_QUERY );
-            if( xMat.is() )
-            {
-                uno::Any aRes( xMat->getMaterial() );
-                if( aRes >>= aFD )
-                {
-                    if (!aFD.Name.isEmpty())
-                    {
-                        aResult.familyName = aFD.Name;
-                        parseFontFamilyName(aResult);
-                    }
-                    aResult.isBold      = (aFD.Weight > 100.0);
-                    aResult.isItalic    = (aFD.Slant == awt::FontSlant_OBLIQUE ||
-                                           aFD.Slant == awt::FontSlant_ITALIC );
-                    aResult.isUnderline = false;
-                    aResult.size        = 0;
-                }
-            }
-        }
-        catch( uno::Exception& )
-        {
-        }
-
-        if( aResult.familyName.isEmpty() )
-        {
-            // last fallback
-            aResult.familyName  = "Arial";
-            aResult.isUnderline = false;
-        }
-
-    }
 
     if (!m_parser.m_xDev)
         m_parser.m_xDev.disposeAndReset(VclPtr<VirtualDevice>::Create());
diff --git a/sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.cxx b/sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.cxx
index 16ad04bf660a..d8b73f621a09 100644
--- a/sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.cxx
+++ b/sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.cxx
@@ -435,11 +435,11 @@ int PDFOutDev::parseFont( long long nNewId, GfxFont* gfxFont, GfxState* state )
 #if POPPLER_CHECK_VERSION(0, 64, 0)
     const
 #endif
-    GooString* pFamily = gfxFont->getName();
-    if( pFamily )
+    std::string familyName = gfxFont->getNameWithoutSubsetTag();
+    if( familyName != "" )
     {
         aNewFont.familyName.clear();
-        aNewFont.familyName.append( gfxFont->getName() );
+        aNewFont.familyName.append( familyName );
     }
     else
     {
@@ -786,9 +786,6 @@ void PDFOutDev::updateFont(GfxState *state)
                 aEsc.data() );
     }
     printf( "\n" );
-
-    if( nEmbedSize )
-        writeFontFile(gfxFont);
 }
 
 void PDFOutDev::updateRender(GfxState *state)


More information about the Libreoffice-commits mailing list