LCOV - code coverage report
Current view: top level - vcl/source/fontsubset - fontsubset.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 51 0.0 %
Date: 2012-08-25 Functions: 0 8 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 26 0.0 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : 
      30                 :            : #include <tools/debug.hxx>
      31                 :            : 
      32                 :            : #include <fontsubset.hxx>
      33                 :            : #include <sft.hxx>
      34                 :            : 
      35                 :            : // ====================================================================
      36                 :            : 
      37                 :          0 : FontSubsetInfo::FontSubsetInfo()
      38                 :            : :   m_nAscent( 0)
      39                 :            : ,   m_nDescent( 0)
      40                 :            : ,   m_nCapHeight( 0)
      41                 :            : ,   m_nFontType( FontSubsetInfo::NO_FONT)
      42                 :            : ,   mpInFontBytes( NULL)
      43                 :            : ,   mnInByteLength( 0)
      44                 :            : ,   meInFontType( FontSubsetInfo::NO_FONT)
      45         [ #  # ]:          0 : ,   mpSftTTFont( NULL)
      46                 :          0 : {}
      47                 :            : 
      48                 :            : // --------------------------------------------------------------------
      49                 :            : 
      50                 :          0 : FontSubsetInfo::~FontSubsetInfo()
      51         [ #  # ]:          0 : {}
      52                 :            : 
      53                 :            : // --------------------------------------------------------------------
      54                 :            : 
      55                 :            : // prepare subsetting for fonts where the input font file is mapped
      56                 :          0 : bool FontSubsetInfo::LoadFont(
      57                 :            :     FontSubsetInfo::FontType eInFontType,
      58                 :            :     const unsigned char* pInFontBytes, int nInByteLength)
      59                 :            : {
      60                 :            :     DBG_ASSERT( (mpSftTTFont == NULL), "Subset from SFT and from mapped font-file requested");
      61                 :          0 :     meInFontType = eInFontType;
      62                 :          0 :     mpInFontBytes = pInFontBytes;
      63                 :          0 :     mnInByteLength = nInByteLength;
      64                 :          0 :     return (mnInByteLength > 0);
      65                 :            : }
      66                 :            : 
      67                 :            : // --------------------------------------------------------------------
      68                 :            : 
      69                 :            : // prepare subsetting for fonts that are known to the SFT-parser
      70                 :          0 : bool FontSubsetInfo::LoadFont( vcl::_TrueTypeFont* pSftTTFont )
      71                 :            : {
      72                 :            :     DBG_ASSERT( (mpInFontBytes == NULL), "Subset from SFT and from mapped font-file requested");
      73                 :          0 :     mpSftTTFont = pSftTTFont;
      74                 :          0 :     meInFontType = ANY_SFNT;
      75                 :          0 :     return (mpSftTTFont == NULL);
      76                 :            : }
      77                 :            : 
      78                 :            : // --------------------------------------------------------------------
      79                 :            : 
      80                 :          0 : bool FontSubsetInfo::CreateFontSubset(
      81                 :            :     int nReqFontTypeMask,
      82                 :            :     FILE* pOutFile, const char* pReqFontName,
      83                 :            :     const long* pReqGlyphIds, const sal_uInt8* pReqEncodedIds, int nReqGlyphCount,
      84                 :            :     sal_Int32* pOutGlyphWidths)
      85                 :            : {
      86                 :            :     // prepare request details needed by all underlying subsetters
      87                 :          0 :     mnReqFontTypeMask = nReqFontTypeMask;
      88                 :          0 :     mpOutFile       = pOutFile;
      89                 :          0 :     mpReqFontName   = pReqFontName;
      90                 :          0 :     mpReqGlyphIds   = pReqGlyphIds;
      91                 :          0 :     mpReqEncodedIds = pReqEncodedIds;
      92                 :          0 :     mnReqGlyphCount = nReqGlyphCount;
      93                 :            : 
      94                 :            :     // TODO: move the glyphid/encid/notdef reshuffling from the callers to here
      95                 :            : 
      96                 :            :     // dispatch to underlying subsetters
      97                 :          0 :     bool bOK = false;
      98                 :            : 
      99                 :            :     // TODO: better match available input-type to possible subset-types
     100   [ #  #  #  # ]:          0 :     switch( meInFontType) {
     101                 :            :     case SFNT_TTF:
     102                 :            :     case SFNT_CFF:
     103                 :            :     case ANY_SFNT:
     104                 :          0 :         bOK = CreateFontSubsetFromSfnt( pOutGlyphWidths);
     105                 :          0 :         break;
     106                 :            :     case CFF_FONT:
     107                 :          0 :         bOK = CreateFontSubsetFromCff( pOutGlyphWidths);
     108                 :          0 :         break;
     109                 :            :     case TYPE1_PFA:
     110                 :            :     case TYPE1_PFB:
     111                 :            :     case ANY_TYPE1:
     112                 :          0 :         bOK = CreateFontSubsetFromType1( pOutGlyphWidths);
     113                 :          0 :         break;
     114                 :            :         // fall trough
     115                 :            :     case NO_FONT:
     116                 :            :         // fall trough
     117                 :            :     default:
     118                 :            :         OSL_FAIL( "unhandled type in CreateFontSubset()");
     119                 :          0 :         break;
     120                 :            :     }
     121                 :            : 
     122                 :          0 :     return bOK;
     123                 :            : }
     124                 :            : 
     125                 :            : // --------------------------------------------------------------------
     126                 :            : 
     127                 :            : // TODO: move function to sft.cxx to replace dummy implementation
     128                 :          0 : bool FontSubsetInfo::CreateFontSubsetFromSfnt( sal_Int32* pOutGlyphWidths )
     129                 :            : {
     130                 :            :     // handle SFNT_CFF fonts
     131                 :          0 :     int nCffLength = 0;
     132                 :          0 :     const sal_uInt8* pCffBytes = NULL;
     133 [ #  # ][ #  # ]:          0 :     if( GetSfntTable( mpSftTTFont, O_CFF, &pCffBytes, &nCffLength))
     134                 :            :     {
     135         [ #  # ]:          0 :         LoadFont( CFF_FONT, pCffBytes, nCffLength);
     136         [ #  # ]:          0 :         const bool bOK = CreateFontSubsetFromCff( pOutGlyphWidths);
     137                 :          0 :         return bOK;
     138                 :            :     }
     139                 :            : 
     140                 :            :     // handle SFNT_TTF fonts
     141                 :            :     // by forwarding the subset request to AG's sft subsetter
     142                 :            : #if 1 // TODO: remove conversion tp 16bit glyphids when sft-subsetter has been updated
     143                 :            :     sal_uInt16 aShortGlyphIds[256];
     144         [ #  # ]:          0 :     for( int i = 0; i < mnReqGlyphCount; ++i)
     145                 :          0 :         aShortGlyphIds[i] = (sal_uInt16)mpReqGlyphIds[i];
     146                 :            :     // remove const_cast when sft-subsetter is const-correct
     147                 :          0 :     sal_uInt8* pEncArray = const_cast<sal_uInt8*>( mpReqEncodedIds );
     148                 :            : #endif
     149                 :          0 :     int nSFTErr = vcl::SF_BADARG;
     150         [ #  # ]:          0 :     if( (mnReqFontTypeMask & TYPE42_FONT) != 0 )
     151                 :            :     {
     152                 :            :         nSFTErr = CreateT42FromTTGlyphs( mpSftTTFont, mpOutFile, mpReqFontName,
     153         [ #  # ]:          0 :             aShortGlyphIds, pEncArray, mnReqGlyphCount );
     154                 :            :     }
     155         [ #  # ]:          0 :     else if( (mnReqFontTypeMask & TYPE3_FONT) != 0 )
     156                 :            :     {
     157                 :            :         nSFTErr = CreateT3FromTTGlyphs( mpSftTTFont, mpOutFile, mpReqFontName,
     158                 :            :             aShortGlyphIds, pEncArray, mnReqGlyphCount,
     159         [ #  # ]:          0 :                     0 /* 0 = horizontal, 1 = vertical */ );
     160                 :            :     }
     161                 :          0 :     else if( (mnReqFontTypeMask & SFNT_TTF) != 0 )
     162                 :            :     {
     163                 :            :         // TODO: use CreateTTFromTTGlyphs()
     164                 :            :         // TODO: move functionality from callers here
     165                 :            :     }
     166                 :            : 
     167                 :          0 :     return (nSFTErr != vcl::SF_OK);
     168                 :            : }
     169                 :            : 
     170                 :            : // --------------------------------------------------------------------
     171                 :            : 
     172                 :            : // TODO: replace dummy implementation
     173                 :          0 : bool FontSubsetInfo::CreateFontSubsetFromType1( sal_Int32* pOutGlyphWidths)
     174                 :            : {
     175                 :            :     (void)pOutGlyphWidths;
     176                 :          0 :     fprintf(stderr,"CreateFontSubsetFromType1: replace dummy implementation\n");
     177                 :          0 :     return false;
     178                 :            : }
     179                 :            : 
     180                 :            : // ====================================================================
     181                 :            : 
     182                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10