This file is indexed.

/usr/include/podofo/doc/PdfFontTTFSubset.h is in libpodofo-dev 0.9.4-6.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
/***************************************************************************
 *   Copyright (C) 2008 by Dominik Seichter                                *
 *   domseichter@web.de                                                    *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU Library General Public License as       *
 *   published by the Free Software Foundation; either version 2 of the    *
 *   License, or (at your option) any later version.                       *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU Library General Public     *
 *   License along with this program; if not, write to the                 *
 *   Free Software Foundation, Inc.,                                       *
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
 *                                                                         *
 *   In addition, as a special exception, the copyright holders give       *
 *   permission to link the code of portions of this program with the      *
 *   OpenSSL library under certain conditions as described in each         *
 *   individual source file, and distribute linked combinations            *
 *   including the two.                                                    *
 *   You must obey the GNU General Public License in all respects          *
 *   for all of the code used other than OpenSSL.  If you modify           *
 *   file(s) with this exception, you may extend this exception to your    *
 *   version of the file(s), but you are not obligated to do so.  If you   *
 *   do not wish to do so, delete this exception statement from your       *
 *   version.  If you delete this exception statement from all source      *
 *   files in the program, then also delete it here.                       *
 ***************************************************************************/

#ifndef _PDF_FONT_TTF_SUBSET_H_
#define _PDF_FONT_TTF_SUBSET_H_

#include "podofo/base/PdfDefines.h"
#include "PdfFontMetrics.h"

#include <string>
#include <vector>

namespace PoDoFo {

class PdfInputDevice;
class PdfOutputDevice;

// This code is based heavily on code by ZhangYang 
// (张杨.国际) <zhang_yang@founder.com>
//
// (Do not put this into doxygen documentation blocks
//  as this will break latex documentation generation)

/**
 * This class is able to build a new TTF font with only
 * certain glyphs from an existing font.
 *
 */
class PODOFO_DOC_API PdfFontTTFSubset {
 public:
    /**
     * Internal enum specifying the type of a fontfile.
     */
    enum EFontFileType {
        eFontFileType_TTF,    ///< TrueType Font
        eFontFileType_TTC,    ///< TrueType Collection
        eFontFileType_OTF,    ///< OpenType Font
        eFontFileType_Unknown ///< Unknown
    };


    /** Create a new PdfFontTTFSubset from an existing 
     *  TTF font file.
     *
     *  @param pszFontFileName path to a TTF file
     *  @param pMetrics font metrics object for this font
     *  @param nFaceIndex index of the face inside of the font
     */
    PdfFontTTFSubset( const char* pszFontFileName, PdfFontMetrics* pMetrics, unsigned short nFaceIndex = 0 );

    /** Create a new PdfFontTTFSubset from an existing 
     *  TTF font file using an input device.
     *
     *  @param pDevice a PdfInputDevice
     *  @param pMetrics font metrics object for this font
     *  @param eType the type of the font
     *  @param nFaceIndex index of the face inside of the font
     */
    PdfFontTTFSubset( PdfInputDevice* pDevice, PdfFontMetrics* pMetrics, EFontFileType eType, unsigned short nFaceIndex = 0 );

    ~PdfFontTTFSubset();

    /**
     * Actually generate the subsetted font
     *
     * @param pOutputDevice write the font to this device
     */
    void BuildFont( PdfRefCountedBuffer& outputBuffer, const std::set<pdf_utf16be>& usedChars, std::vector<unsigned char>& cidSet );

 private:
    /** Hide default constructor
     */
    PdfFontTTFSubset() : m_bOwnDevice( false ) {} 

    /** copy constructor, not implemented
     */
    PdfFontTTFSubset(const PdfFontTTFSubset& rhs);
    /** assignment operator, not implemented
     */
    PdfFontTTFSubset& operator=(const PdfFontTTFSubset& rhs);

    void Init();
    
    /** Get the offset of a specified table. 
     *  @param pszTableName name of the table
     */
    unsigned long GetTableOffset( unsigned long tag );

    void GetNumberOfTables();
    void GetNumberOfGlyphs();
    void SeeIfLongLocaOrNot();
    void InitTables();
    void GetStartOfTTFOffsets();

    /** Get sz bytes from the offset'th bytes of the input file
     *
     */
    void GetData(unsigned long offset, void* address, unsigned long sz);


    /** Information of TrueType tables.
     */
    class TTrueTypeTable {
    public:
        TTrueTypeTable()
            : tag( 0L ), checksum( 0L ), length( 0L ), offset( 0L )
        {
        }
        
	    unsigned long tag;
	    unsigned long checksum;
	    unsigned long length;
	    unsigned long offset;
    };

    /** GlyphData contains the glyph address relative 
     *  to the beginning of the glyf table.
     */
    class TGlyphData {
    public:
        TGlyphData()
            : glyphLength( 0L ), glyphAddress( 0L )
        {
        }
        
        unsigned long glyphLength;
	    unsigned long glyphAddress;	//In the original truetype file.
    };

    typedef unsigned short GID;
    typedef unsigned long CodePoint;
    typedef std::map<GID, TGlyphData> GlyphMap;
    typedef std::map<CodePoint, GID> CodePointToGid;

    class CMapv4Range {
    public:
        CMapv4Range()
            : endCode( 0 ), startCode( 0 ), delta( 0 ), offset( 0 )
        {
        }
        
	    unsigned short endCode;
	    unsigned short startCode;
	    short delta;
	    unsigned short offset;
    };

    typedef std::vector<CMapv4Range> CMapRanges;

    class CMap {
    public:
        CMap()
            : segCount( 0 )
        {
        }
        
	    unsigned short segCount;
	    CMapRanges ranges;
	    std::vector<unsigned short> glyphArray;
    };

    class GlyphContext {
    public:
        GlyphContext()
            : ulGlyfTableOffset( 0 ), ulLocaTableOffset( 0 ), contourCount( 0 ) , shortOffset( 0 )
        {
        }
        
        unsigned long ulGlyfTableOffset;
        unsigned long ulLocaTableOffset;
        /* Used internaly during recursive load */
        TGlyphData glyphData;
        short contourCount;
        unsigned short shortOffset;
    };

    void BuildUsedCodes(CodePointToGid& usedCodes, const std::set<pdf_utf16be>& usedChars );
    void LoadGlyphs(GlyphContext& ctx, const CodePointToGid& usedCodes);
    void LoadGID(GlyphContext& ctx, GID gid);
    void LoadCompound(GlyphContext& ctx, unsigned long offset);
    void CreateCmapTable( const CodePointToGid& usedCodes );
    void FillGlyphArray(const CodePointToGid& usedCodes, GID gid, unsigned short count);
    unsigned long GetCmapTableSize();
    unsigned long WriteCmapTable(char*);
    unsigned long GetGlyphTableSize();
    unsigned long WriteGlyphTable(char* bufp, unsigned long ulGlyphTableOffset);
    unsigned long GetLocaTableSize();
    unsigned long WriteLocaTable(char* bufp);
    unsigned long GetHmtxTableSize();
    unsigned long WriteHmtxTable(char* bufp, unsigned long ulHmtxTableOffset);
    unsigned long CalculateSubsetSize();
    void WriteTables(PdfRefCountedBuffer& fontData);

    PdfFontMetrics* m_pMetrics;                ///< FontMetrics object which is required to convert unicode character points to glyph ids
    EFontFileType   m_eFontFileType;
    bool	        m_bIsLongLoca;
    
    unsigned short  m_numTables;
    unsigned short  m_numGlyphs;
    unsigned short  m_numHMetrics;
    
    std::vector<TTrueTypeTable> m_vTable;
    GlyphMap m_mGlyphMap;
    CMap m_sCMap;
    
    /* temp storage during load */

    unsigned short  m_faceIndex;

    unsigned long   m_ulStartOfTTFOffsets;	///< Start address of the truetype offset tables, differs from ttf to ttc.

    PdfInputDevice* m_pDevice;                  ///< Read data from this input device
    const bool      m_bOwnDevice;               ///< If the input device is owned by this object
};

// -----------------------------------------------------
// 
// -----------------------------------------------------


}; /* PoDoFo */

#endif /* _PDF_FONT_TRUE_TYPE_H_ */