1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 #ifndef _SV_FONTSUBSET_HXX 29 #define _SV_FONTSUBSET_HXX 30 31 #include <tools/gen.hxx> 32 #include <tools/string.hxx> 33 #include <cstdio> 34 35 #include "vcl/dllapi.h" 36 37 namespace vcl { struct _TrueTypeFont; } // SFT's idea of a TTF font 38 39 class VCL_DLLPUBLIC FontSubsetInfo 40 { 41 public: 42 explicit FontSubsetInfo( void ); 43 virtual ~FontSubsetInfo( void ); 44 45 enum FontType { 46 NO_FONT = 0, 47 SFNT_TTF = 1<<1, // SFNT container with TrueType glyphs 48 SFNT_CFF = 1<<2, // SFNT container with CFF-container 49 TYPE1_PFA = 1<<3, // PSType1 Postscript Font Ascii 50 TYPE1_PFB = 1<<4, // PSType1 Postscript Font Binary 51 CFF_FONT = 1<<5, // CFF-container with PSType2 glyphs 52 TYPE3_FONT = 1<<6, // PSType3 Postscript font 53 TYPE42_FONT = 1<<7, // PSType42 wrapper for an SFNT_TTF 54 ANY_SFNT = SFNT_TTF | SFNT_CFF, 55 ANY_TYPE1 = TYPE1_PFA | TYPE1_PFB, 56 ANY_FONT = 0xFF 57 }; 58 59 bool LoadFont( FontType eInFontType, 60 const unsigned char* pFontBytes, int nByteLength ); 61 bool LoadFont( vcl::_TrueTypeFont* pSftTrueTypeFont ); 62 63 bool CreateFontSubset( int nOutFontTypeMask, 64 FILE* pOutFile, const char* pOutFontName, 65 const long* pReqGlyphIds, const sal_uInt8* pEncodedIds, 66 int nReqGlyphCount, sal_Int32* pOutGlyphWidths = NULL ); 67 68 public: // TODO: make subsetter results private and provide accessor methods instead 69 // subsetter-provided subset details needed by e.g. Postscript or PDF 70 String m_aPSName; 71 int m_nAscent; // all metrics in PS font units 72 int m_nDescent; 73 int m_nCapHeight; 74 Rectangle m_aFontBBox; 75 FontType m_nFontType; // font-type of subset result 76 77 private: 78 // input-font-specific details 79 unsigned const char* mpInFontBytes; 80 int mnInByteLength; 81 FontType meInFontType; // allowed mask of input font-types 82 vcl::_TrueTypeFont* mpSftTTFont; 83 84 // subset-request details 85 int mnReqFontTypeMask; // allowed subset-target font types 86 FILE* mpOutFile; 87 const char* mpReqFontName; 88 const long* mpReqGlyphIds; 89 const sal_uInt8* mpReqEncodedIds; 90 int mnReqGlyphCount; 91 92 protected: 93 bool CreateFontSubsetFromCff( sal_Int32* pOutGlyphWidths = NULL ); 94 bool CreateFontSubsetFromSfnt( sal_Int32* pOutGlyphWidths = NULL ); 95 bool CreateFontSubsetFromType1( sal_Int32* pOutGlyphWidths = NULL ); 96 }; 97 98 #endif // _SV_FONTSUBSET_HXX 99 100