build fix
[LibreOffice.git] / vcl / inc / fontsubset.hxx
blob11f58107a5e2c3a01ba856135cf7daa098722925
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>
26 #include "salglyphid.hxx"
28 namespace vcl { struct TrueTypeFont; } ///< SFT's idea of a TTF font
30 class FontSubsetInfo final
32 public:
33 explicit FontSubsetInfo();
34 ~FontSubsetInfo();
36 enum FontType {
37 NO_FONT = 0,
38 SFNT_TTF = 1<<1, ///< SFNT container with TrueType glyphs
39 SFNT_CFF = 1<<2, ///< SFNT container with CFF-container
40 TYPE1_PFA = 1<<3, ///< PSType1 Postscript Font Ascii
41 TYPE1_PFB = 1<<4, ///< PSType1 Postscript Font Binary
42 CFF_FONT = 1<<5, ///< CFF-container with PSType2 glyphs
43 TYPE3_FONT = 1<<6, ///< PSType3 Postscript font
44 TYPE42_FONT = 1<<7, ///< PSType42 wrapper for an SFNT_TTF
45 ANY_SFNT = SFNT_TTF | SFNT_CFF,
46 ANY_TYPE1 = TYPE1_PFA | TYPE1_PFB
49 bool LoadFont( FontType eInFontType,
50 const unsigned char* pFontBytes, int nByteLength );
51 bool LoadFont( vcl::TrueTypeFont* pSftTrueTypeFont );
53 bool CreateFontSubset( int nOutFontTypeMask,
54 FILE* pOutFile, const char* pOutFontName,
55 const sal_GlyphId* pGlyphIds, const sal_uInt8* pEncodedIds,
56 int nReqGlyphCount, sal_Int32* pOutGlyphWidths = nullptr );
58 public: // TODO: make subsetter results private and provide accessor methods instead
59 // subsetter-provided subset details needed by e.g. Postscript or PDF
60 OUString m_aPSName;
61 int m_nAscent; ///< all metrics in PS font units
62 int m_nDescent;
63 int m_nCapHeight;
64 Rectangle m_aFontBBox;
65 FontType m_nFontType; ///< font-type of subset result
67 private:
68 // input-font-specific details
69 unsigned const char* mpInFontBytes;
70 int mnInByteLength;
71 FontType meInFontType; ///< allowed mask of input font-types
72 vcl::TrueTypeFont* mpSftTTFont;
74 // subset-request details
75 int mnReqFontTypeMask; ///< allowed subset-target font types
76 FILE* mpOutFile;
77 const char* mpReqFontName;
78 const sal_GlyphId* mpReqGlyphIds;
79 const sal_uInt8* mpReqEncodedIds;
80 int mnReqGlyphCount;
82 bool CreateFontSubsetFromCff( sal_Int32* pOutGlyphWidths );
83 bool CreateFontSubsetFromSfnt( sal_Int32* pOutGlyphWidths );
84 static bool CreateFontSubsetFromType1( sal_Int32* pOutGlyphWidths );
87 #endif // INCLUDED_VCL_INC_FONTSUBSET_HXX
89 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */