[Libreoffice-commits] core.git: vcl/inc vcl/source vcl/unx

Khaled Hosny khaledhosny at eglug.org
Wed Nov 30 15:03:16 UTC 2016


 vcl/inc/sft.hxx                             |   46 -----------
 vcl/inc/unx/fontmanager.hxx                 |   36 ---------
 vcl/source/fontsubset/sft.cxx               |   77 -------------------
 vcl/unx/generic/fontmanager/fontcache.cxx   |    9 --
 vcl/unx/generic/fontmanager/fontmanager.cxx |  112 ----------------------------
 5 files changed, 4 insertions(+), 276 deletions(-)

New commits:
commit b32dfbff56089c2ea3be07afce6a1e60777deb4b
Author: Khaled Hosny <khaledhosny at eglug.org>
Date:   Tue Nov 29 22:24:56 2016 +0200

    More dead code
    
    Change-Id: I820ed3905d18801513b14f535042801023be5538
    Reviewed-on: https://gerrit.libreoffice.org/31387
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Khaled Hosny <khaledhosny at eglug.org>

diff --git a/vcl/inc/sft.hxx b/vcl/inc/sft.hxx
index 2efe115..fe50a95 100644
--- a/vcl/inc/sft.hxx
+++ b/vcl/inc/sft.hxx
@@ -437,43 +437,6 @@ namespace vcl
  */
     TTSimpleGlyphMetrics *GetTTSimpleGlyphMetrics(TrueTypeFont *ttf, sal_uInt16 *glyphArray, int nGlyphs, bool vertical);
 
-/**
- * Queries glyph metrics. Allocates an array of TTSimpleGlyphMetrics structs and returns it.
- * This function behaves just like GetTTSimpleGlyphMetrics() but it takes a range of Unicode
- * characters instead of an array of glyphs.
- *
- * @param ttf         pointer to the TrueTypeFont structure
- * @param firstChar   Unicode value of the first character in the range
- * @param nChars      number of Unicode characters in the range
- * @param vertical    writing mode: false - horizontal, true - vertical
- *
- * @see GetTTSimpleGlyphMetrics
- * @ingroup sft
- *
- */
-    TTSimpleGlyphMetrics *GetTTSimpleCharMetrics(TrueTypeFont *ttf, sal_uInt16 firstChar, int nChars, bool vertical);
-
-/**
- * Maps a Unicode (UCS-2) string to a glyph array. Returns the number of glyphs in the array,
- * which for TrueType fonts is always the same as the number of input characters.
- *
- * @param ttf         pointer to the TrueTypeFont structure
- * @param str         pointer to a UCS-2 string
- * @param nchars      number of characters in <b>str</b>
- * @param glyphArray  pointer to the glyph array where glyph IDs are to be recorded.
- * @param bvertical   vertical text
- *
- * @return MapString() returns -1 if the TrueType font has no usable 'cmap' tables.
- *         Otherwise it returns the number of characters processed: <b>nChars</b>
- *
- * glyphIDs of TrueType fonts are 2 byte positive numbers. glyphID of 0 denotes a missing
- * glyph and traditionally defaults to an empty square.
- * glyphArray should be at least sizeof(sal_uInt16) * nchars bytes long. If glyphArray is NULL
- * MapString() replaces the UCS-2 characters in str with glyphIDs.
- * @ingroup sft
- */
-    int VCL_DLLPUBLIC MapString(TrueTypeFont *ttf, sal_uInt16 *str, int nchars, sal_uInt16 *glyphArray, bool bvertical);
-
 #if defined(_WIN32) || defined(MACOSX) || defined(IOS)
 /**
  * Maps a Unicode (UCS-2) character to a glyph ID and returns it. Missing glyph has
@@ -490,15 +453,6 @@ namespace vcl
 #endif
 
 /**
- * Returns 0 when the font does not substitute vertical glyphs
- *
- * @param ttf         pointer to the TrueTypeFont structure
- * @param bvertical   flag to function that we want to find the vertical
- *                    GlobalSUBstitution attribute
- */
-    int DoesVerticalSubstitution( TrueTypeFont *ttf, int bvertical);
-
-/**
  * Returns global font information about the TrueType font.
  * @see TTGlobalFontInfo
  *
diff --git a/vcl/inc/unx/fontmanager.hxx b/vcl/inc/unx/fontmanager.hxx
index 0a2de15..86d946a 100644
--- a/vcl/inc/unx/fontmanager.hxx
+++ b/vcl/inc/unx/fontmanager.hxx
@@ -130,32 +130,6 @@ class VCL_PLUGIN_PUBLIC PrintFontManager
     friend struct PrintFont;
     friend class FontCache;
 
-    struct PrintFontMetrics
-    {
-        // character metrics are stored by the following keys:
-        // lower two bytes contain a sal_Unicode (a UCS2 character)
-        // upper byte contains: 0 for horizontal metric
-        //                      1 for vertical metric
-        // highest byte: 0 for now
-        std::unordered_map< int, CharacterMetric >     m_aMetrics;
-        // contains the unicode blocks for which metrics were queried
-        // this implies that metrics should be queried in terms of
-        // unicode blocks. here a unicode block is identified
-        // by the upper byte of the UCS2 encoding.
-        // note that the corresponding bit should be set even
-        // if the font does not support a single character of that page
-        // this map shows, which pages were queried already
-        // if (like in AFM metrics) all metrics are queried in
-        // a single pass, then all bits should be set
-        char                                        m_aPages[32];
-
-        std::unordered_map< sal_Unicode, bool >       m_bVerticalSubstitutions;
-
-        PrintFontMetrics() {}
-
-        bool isEmpty() const { return m_aMetrics.empty(); }
-    };
-
     struct PrintFont
     {
         // font attributes
@@ -170,7 +144,6 @@ class VCL_PLUGIN_PUBLIC PrintFontManager
         rtl_TextEncoding  m_aEncoding;
         CharacterMetric   m_aGlobalMetricX;
         CharacterMetric   m_aGlobalMetricY;
-        PrintFontMetrics* m_pMetrics;
         int               m_nAscend;
         int               m_nDescend;
         int               m_nLeading;
@@ -178,7 +151,6 @@ class VCL_PLUGIN_PUBLIC PrintFontManager
         int               m_nYMin;
         int               m_nXMax;
         int               m_nYMax;
-        bool              m_bHaveVerticalSubstitutedGlyphs;
         bool              m_bUserOverride;
 
         int               m_nDirectory;       // atom containing system dependent path
@@ -187,8 +159,6 @@ class VCL_PLUGIN_PUBLIC PrintFontManager
         unsigned int      m_nTypeFlags;       // copyright bits and PS-OpenType flag
 
         explicit PrintFont();
-        ~PrintFont();
-        bool queryMetricPage(int nPage, utl::MultiAtomProvider* pProvider);
     };
 
     fontID                                      m_nNextFontID;
@@ -328,12 +298,6 @@ public:
     // get a fonts glyph bounding box
     void getFontBoundingBox( fontID nFont, int& xMin, int& yMin, int& xMax, int& yMax );
 
-    // get a specific fonts metrics
-
-    // get metrics for an array of sal_Unicode characters
-    // the user is responsible to allocate pArray large enough
-    bool getMetrics( fontID nFontID, const sal_Unicode* pString, int nLen, CharacterMetric* pArray ) const;
-
     // creates a new font subset of an existing SFNT font
     // returns true in case of success, else false
     // nFont: the font to be subsetted
diff --git a/vcl/source/fontsubset/sft.cxx b/vcl/source/fontsubset/sft.cxx
index d4a8b5a..6922026 100644
--- a/vcl/source/fontsubset/sft.cxx
+++ b/vcl/source/fontsubset/sft.cxx
@@ -2344,57 +2344,6 @@ int  CreateT42FromTTGlyphs(TrueTypeFont  *ttf,
     return SF_OK;
 }
 
-int MapString(TrueTypeFont *ttf, sal_uInt16 *str, int nchars, sal_uInt16 *glyphArray, bool bvertical)
-{
-    int i;
-    sal_uInt16 *cp;
-
-    if (ttf->cmapType == CMAP_NOT_USABLE ) return -1;
-    if (!nchars) return 0;
-
-    if (glyphArray == nullptr) {
-        cp = str;
-    } else {
-        cp = glyphArray;
-    }
-
-    switch (ttf->cmapType) {
-        case CMAP_MS_Symbol:
-            if( ttf->mapper == getGlyph0 ) {
-                sal_uInt16 aChar;
-                for( i = 0; i < nchars; i++ ) {
-                    aChar = str[i];
-                    if( ( aChar & 0xf000 ) == 0xf000 )
-                        aChar &= 0x00ff;
-                    cp[i] = aChar;
-                }
-            }
-            else if( glyphArray )
-                memcpy(glyphArray, str, nchars * 2);
-            break;
-
-        case CMAP_MS_Unicode:
-            if (glyphArray != nullptr) {
-                memcpy(glyphArray, str, nchars * 2);
-            }
-            break;
-
-        case CMAP_MS_ShiftJIS:  TranslateString12(str, cp, nchars); break;
-        case CMAP_MS_Big5:      TranslateString13(str, cp, nchars); break;
-        case CMAP_MS_PRC:       TranslateString14(str, cp, nchars); break;
-        case CMAP_MS_Wansung:   TranslateString15(str, cp, nchars); break;
-        case CMAP_MS_Johab:     TranslateString16(str, cp, nchars); break;
-    }
-
-    const sal_uInt32 nMaxCmapSize = ttf->ptr + ttf->fsize - ttf->cmap;
-    for (i = 0; i < nchars; i++) {
-        cp[i] = (sal_uInt16)ttf->mapper(ttf->cmap, nMaxCmapSize, cp[i]);
-        if (cp[i]!=0 && bvertical)
-            cp[i] = (sal_uInt16)UseGSUB(ttf,cp[i]);
-    }
-    return nchars;
-}
-
 #if defined(_WIN32) || defined(MACOSX) || defined(IOS)
 sal_uInt16 MapChar(TrueTypeFont *ttf, sal_uInt16 ch, bool bvertical)
 {
@@ -2424,14 +2373,6 @@ sal_uInt16 MapChar(TrueTypeFont *ttf, sal_uInt16 ch, bool bvertical)
 #endif
 
 
-int DoesVerticalSubstitution( TrueTypeFont *ttf, int bvertical)
-{
-    int nRet = 0;
-    if( bvertical)
-        nRet = HasVerticalGSUB( ttf);
-    return nRet;
-}
-
 int GetTTGlyphCount( TrueTypeFont* ttf )
 {
     return ttf->nglyphs;
@@ -2502,24 +2443,6 @@ TTSimpleGlyphMetrics *GetTTSimpleGlyphMetrics(TrueTypeFont *ttf, sal_uInt16 *gly
     return res;
 }
 
-TTSimpleGlyphMetrics *GetTTSimpleCharMetrics(TrueTypeFont * ttf, sal_uInt16 firstChar, int nChars, bool vertical)
-{
-    TTSimpleGlyphMetrics *res = nullptr;
-    int i, n;
-
-    sal_uInt16* str = static_cast<sal_uInt16*>(malloc(nChars * 2));
-    assert(str != nullptr);
-
-    for (i=0; i<nChars; i++) str[i] = (sal_uInt16)(firstChar + i);
-    if ((n = MapString(ttf, str, nChars, nullptr, vertical)) != -1) {
-        res = GetTTSimpleGlyphMetrics(ttf, str, n, vertical);
-    }
-
-    free(str);
-
-    return res;
-}
-
 // TODO, clean up table parsing and re-use it elsewhere in this file.
 void GetTTFontMterics(const std::vector<uint8_t>& hhea,
                       const std::vector<uint8_t>& os2,
diff --git a/vcl/unx/generic/fontmanager/fontcache.cxx b/vcl/unx/generic/fontmanager/fontcache.cxx
index 7407efb..4c26e4e 100644
--- a/vcl/unx/generic/fontmanager/fontcache.cxx
+++ b/vcl/unx/generic/fontmanager/fontcache.cxx
@@ -37,7 +37,7 @@
 #include <cstdio>
 #endif
 
-#define CACHE_MAGIC "LibreOffice PspFontCacheFile format 8"
+#define CACHE_MAGIC "LibreOffice PspFontCacheFile format 9"
 
 using namespace std;
 using namespace psp;
@@ -183,7 +183,7 @@ void FontCache::flush()
                 aLine.append(';');
                 aLine.append(static_cast<sal_Int32>((*it)->m_nLeading));
                 aLine.append(';');
-                aLine.append((*it)->m_bHaveVerticalSubstitutedGlyphs ? '1' : '0');
+                aLine.append('0');
                 aLine.append(';');
                 aLine.append(static_cast<sal_Int32>((*it)->m_aGlobalMetricX.width ));
                 aLine.append(';');
@@ -359,8 +359,7 @@ void FontCache::read()
                 pFont->m_nAscend    = atoi( pLine + nTokenPos[7] );
                 pFont->m_nDescend   = atoi( pLine + nTokenPos[8] );
                 pFont->m_nLeading   = atoi( pLine + nTokenPos[9] );
-                pFont->m_bHaveVerticalSubstitutedGlyphs
-                                    = (atoi( pLine + nTokenPos[10] ) != 0);
+                /* removed */   (void)atoi( pLine + nTokenPos[10] );
                 pFont->m_aGlobalMetricX.width
                                     = atoi( pLine + nTokenPos[11] );
                 pFont->m_aGlobalMetricX.height
@@ -449,7 +448,6 @@ void FontCache::copyPrintFont( const PrintFontManager::PrintFont* pFrom, PrintFo
     pTo->m_nYMin            = pFrom->m_nYMin;
     pTo->m_nXMax            = pFrom->m_nXMax;
     pTo->m_nYMax            = pFrom->m_nYMax;
-    pTo->m_bHaveVerticalSubstitutedGlyphs = pFrom->m_bHaveVerticalSubstitutedGlyphs;
     pTo->m_bUserOverride    = pFrom->m_bUserOverride;
 }
 
@@ -479,7 +477,6 @@ bool FontCache::equalsPrintFont( const PrintFontManager::PrintFont* pLeft, Print
         pRight->m_nYMin             != pLeft->m_nYMin           ||
         pRight->m_nXMax             != pLeft->m_nXMax           ||
         pRight->m_nYMax             != pLeft->m_nYMax           ||
-        pRight->m_bHaveVerticalSubstitutedGlyphs != pLeft->m_bHaveVerticalSubstitutedGlyphs ||
         pRight->m_bUserOverride     != pLeft->m_bUserOverride
         )
         return false;
diff --git a/vcl/unx/generic/fontmanager/fontmanager.cxx b/vcl/unx/generic/fontmanager/fontmanager.cxx
index dbd816e..30f1d0a 100644
--- a/vcl/unx/generic/fontmanager/fontmanager.cxx
+++ b/vcl/unx/generic/fontmanager/fontmanager.cxx
@@ -102,7 +102,6 @@ PrintFontManager::PrintFont::PrintFont()
 ,   m_eWeight(WEIGHT_DONTKNOW)
 ,   m_ePitch(PITCH_DONTKNOW)
 ,   m_aEncoding(RTL_TEXTENCODING_DONTKNOW)
-,   m_pMetrics(nullptr)
 ,   m_nAscend(0)
 ,   m_nDescend(0)
 ,   m_nLeading(0)
@@ -110,7 +109,6 @@ PrintFontManager::PrintFont::PrintFont()
 ,   m_nYMin(0)
 ,   m_nXMax(0)
 ,   m_nYMax(0)
-,   m_bHaveVerticalSubstitutedGlyphs(false)
 ,   m_bUserOverride( false )
 ,   m_nDirectory(0)
 ,   m_nCollectionEntry(0)
@@ -118,76 +116,6 @@ PrintFontManager::PrintFont::PrintFont()
 {
 }
 
-PrintFontManager::PrintFont::~PrintFont()
-{
-    delete m_pMetrics;
-}
-
-bool PrintFontManager::PrintFont::queryMetricPage( int nPage, MultiAtomProvider* /*pProvider*/ )
-{
-    bool bSuccess = false;
-
-    OString aFile( PrintFontManager::get().getFontFile( this ) );
-
-    TrueTypeFont* pTTFont = nullptr;
-
-    if( OpenTTFontFile( aFile.getStr(), m_nCollectionEntry, &pTTFont ) == SF_OK )
-    {
-        if( ! m_pMetrics )
-        {
-            m_pMetrics = new PrintFontMetrics;
-            memset (m_pMetrics->m_aPages, 0, sizeof(m_pMetrics->m_aPages));
-        }
-        m_pMetrics->m_aPages[ nPage/8 ] |= (1 << ( nPage & 7 ));
-        int i;
-        sal_uInt16 table[256], table_vert[256];
-
-        for( i = 0; i < 256; i++ )
-            table[ i ] = 256*nPage + i;
-
-        int nCharacters = nPage < 255 ? 256 : 254;
-        MapString( pTTFont, table, nCharacters, nullptr, false );
-        TTSimpleGlyphMetrics* pMetrics = GetTTSimpleCharMetrics( pTTFont, nPage*256, nCharacters, false );
-        if( pMetrics )
-        {
-            for( i = 0; i < nCharacters; i++ )
-            {
-                if( table[i] )
-                {
-                    CharacterMetric& rChar = m_pMetrics->m_aMetrics[ nPage*256 + i ];
-                    rChar.width = pMetrics[ i ].adv;
-                    rChar.height = m_aGlobalMetricX.height;
-                }
-            }
-
-            free( pMetrics );
-        }
-
-        for( i = 0; i < 256; i++ )
-            table_vert[ i ] = 256*nPage + i;
-        MapString( pTTFont, table_vert, nCharacters, nullptr, true );
-        pMetrics = GetTTSimpleCharMetrics( pTTFont, nPage*256, nCharacters, true );
-        if( pMetrics )
-        {
-            for( i = 0; i < nCharacters; i++ )
-            {
-                if( table_vert[i] )
-                {
-                    CharacterMetric& rChar = m_pMetrics->m_aMetrics[ nPage*256 + i + ( 1 << 16 ) ];
-                    rChar.width = m_aGlobalMetricY.width;
-                    rChar.height = pMetrics[ i ].adv;
-                    if( table_vert[i] != table[i] )
-                        m_pMetrics->m_bVerticalSubstitutions[ nPage*256 + i ] = true;
-                }
-            }
-            free( pMetrics );
-        }
-        CloseTTFont( pTTFont );
-        bSuccess = true;
-    }
-    return bSuccess;
-}
-
 /*
  *  one instance only
  */
@@ -788,9 +716,6 @@ bool PrintFontManager::analyzeSfntFile( PrintFont* pFont ) const
         // get type flags
         pFont->m_nTypeFlags = (unsigned int)aInfo.typeFlags;
 
-        // get vertical substitutions flag
-        pFont->m_bHaveVerticalSubstitutedGlyphs = DoesVerticalSubstitution( pTTFont, 1 );
-
         CloseTTFont( pTTFont );
         bSuccess = true;
     }
@@ -989,9 +914,7 @@ void PrintFontManager::fillPrintFontInfo( PrintFont* pFont, FastPrintFontInfo& r
 
 void PrintFontManager::fillPrintFontInfo( PrintFont* pFont, PrintFontInfo& rInfo ) const
 {
-    if( ( pFont->m_nAscend == 0 && pFont->m_nDescend == 0 ) ||
-        ! pFont->m_pMetrics || pFont->m_pMetrics->isEmpty()
-        )
+    if (pFont->m_nAscend == 0 && pFont->m_nDescend == 0)
     {
         analyzeSfntFile(pFont);
     }
@@ -1162,39 +1085,6 @@ int PrintFontManager::getFontDescend( fontID nFontID ) const
     return pFont ? pFont->m_nDescend : 0;
 }
 
-bool PrintFontManager::getMetrics( fontID nFontID, const sal_Unicode* pString, int nLen, CharacterMetric* pArray ) const
-{
-    PrintFont* pFont = getFont( nFontID );
-    if( ! pFont )
-        return false;
-
-    if( ( pFont->m_nAscend == 0 && pFont->m_nDescend == 0 )
-        || ! pFont->m_pMetrics || pFont->m_pMetrics->isEmpty()
-        )
-    {
-        analyzeSfntFile(pFont);
-    }
-
-    for( int i = 0; i < nLen; i++ )
-    {
-        if( ! pFont->m_pMetrics ||
-            ! ( pFont->m_pMetrics->m_aPages[ pString[i] >> 11 ] & ( 1 << ( ( pString[i] >> 8 ) & 7 ) ) ) )
-            pFont->queryMetricPage( pString[i] >> 8, m_pAtoms );
-        pArray[i].width = pArray[i].height = -1;
-        if( pFont->m_pMetrics )
-        {
-            int effectiveCode = pString[i];
-            std::unordered_map< int, CharacterMetric >::const_iterator it =
-                  pFont->m_pMetrics->m_aMetrics.find( effectiveCode );
-            // the character metrics are in it->second
-            if( it != pFont->m_pMetrics->m_aMetrics.end() )
-                pArray[ i ] = it->second;
-        }
-    }
-
-    return true;
-}
-
 // TODO: move most of this stuff into the central font-subsetting code
 bool PrintFontManager::createFontSubset(
                                         FontSubsetInfo& rInfo,


More information about the Libreoffice-commits mailing list