Version 4.2.0.1, tag libreoffice-4.2.0.1
[LibreOffice.git] / vcl / inc / fontsubset.hxx
bloba827a95ea7d1891543ae86c9d230a6f59bf78e2f
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef INCLUDED_VCL_INC_FONTSUBSET_HXX
21 #define INCLUDED_VCL_INC_FONTSUBSET_HXX
23 #include <rtl/ustring.hxx>
24 #include <tools/gen.hxx>
25 #include <cstdio>
27 #include "vcl/dllapi.h"
29 namespace vcl { struct _TrueTypeFont; } ///< SFT's idea of a TTF font
31 class VCL_DLLPUBLIC FontSubsetInfo
33 public:
34 explicit FontSubsetInfo( void );
35 virtual ~FontSubsetInfo( void );
37 enum FontType {
38 NO_FONT = 0,
39 SFNT_TTF = 1<<1, ///< SFNT container with TrueType glyphs
40 SFNT_CFF = 1<<2, ///< SFNT container with CFF-container
41 TYPE1_PFA = 1<<3, ///< PSType1 Postscript Font Ascii
42 TYPE1_PFB = 1<<4, ///< PSType1 Postscript Font Binary
43 CFF_FONT = 1<<5, ///< CFF-container with PSType2 glyphs
44 TYPE3_FONT = 1<<6, ///< PSType3 Postscript font
45 TYPE42_FONT = 1<<7, ///< PSType42 wrapper for an SFNT_TTF
46 ANY_SFNT = SFNT_TTF | SFNT_CFF,
47 ANY_TYPE1 = TYPE1_PFA | TYPE1_PFB,
48 ANY_FONT = 0xFF
51 bool LoadFont( FontType eInFontType,
52 const unsigned char* pFontBytes, int nByteLength );
53 bool LoadFont( vcl::_TrueTypeFont* pSftTrueTypeFont );
55 bool CreateFontSubset( int nOutFontTypeMask,
56 FILE* pOutFile, const char* pOutFontName,
57 const long* pReqGlyphIds, const sal_uInt8* pEncodedIds,
58 int nReqGlyphCount, sal_Int32* pOutGlyphWidths = NULL );
60 public: // TODO: make subsetter results private and provide accessor methods instead
61 // subsetter-provided subset details needed by e.g. Postscript or PDF
62 OUString m_aPSName;
63 int m_nAscent; ///< all metrics in PS font units
64 int m_nDescent;
65 int m_nCapHeight;
66 Rectangle m_aFontBBox;
67 FontType m_nFontType; ///< font-type of subset result
69 private:
70 // input-font-specific details
71 unsigned const char* mpInFontBytes;
72 int mnInByteLength;
73 FontType meInFontType; ///< allowed mask of input font-types
74 vcl::_TrueTypeFont* mpSftTTFont;
76 // subset-request details
77 int mnReqFontTypeMask; ///< allowed subset-target font types
78 FILE* mpOutFile;
79 const char* mpReqFontName;
80 const long* mpReqGlyphIds;
81 const sal_uInt8* mpReqEncodedIds;
82 int mnReqGlyphCount;
84 protected:
85 bool CreateFontSubsetFromCff( sal_Int32* pOutGlyphWidths = NULL );
86 bool CreateFontSubsetFromSfnt( sal_Int32* pOutGlyphWidths = NULL );
87 bool CreateFontSubsetFromType1( sal_Int32* pOutGlyphWidths = NULL );
90 #endif // INCLUDED_VCL_INC_FONTSUBSET_HXX
92 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */