LibreOffice Module vcl (master)  1
fontsubset.hxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
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/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
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 .
18  */
19 
20 #ifndef INCLUDED_VCL_INC_FONTSUBSET_HXX
21 #define INCLUDED_VCL_INC_FONTSUBSET_HXX
22 
23 #include <rtl/ustring.hxx>
24 #include <tools/gen.hxx>
25 #include <o3tl/typed_flags_set.hxx>
26 
27 #include <vcl/dllapi.h>
28 
29 #include "glyphid.hxx"
30 
31 namespace vcl { class TrueTypeFont; }
32 
33 enum class FontType {
34  NO_FONT = 0,
35  SFNT_TTF = 1<<1,
36  SFNT_CFF = 1<<2,
37  TYPE1_PFA = 1<<3,
38  TYPE1_PFB = 1<<4,
39  CFF_FONT = 1<<5,
40  TYPE3_FONT = 1<<6,
41  TYPE42_FONT = 1<<7,
44 };
45 namespace o3tl {
46  template<> struct typed_flags<FontType> : is_typed_flags<FontType, (1<<8)-1> {};
47 }
48 
49 class VCL_DLLPUBLIC FontSubsetInfo final
50 {
51 public:
52  explicit FontSubsetInfo();
53  ~FontSubsetInfo();
54 
55  void LoadFont( FontType eInFontType,
56  const unsigned char* pFontBytes, int nByteLength );
57  void LoadFont( vcl::TrueTypeFont* pSftTrueTypeFont );
58 
59  bool CreateFontSubset( FontType nOutFontTypeMask,
60  FILE* pOutFile, const char* pOutFontName,
61  const sal_GlyphId* pGlyphIds, const sal_uInt8* pEncodedIds,
62  int nReqGlyphCount, sal_Int32* pOutGlyphWidths = nullptr );
63 
64 public: // TODO: make subsetter results private and provide accessor methods instead
65  // subsetter-provided subset details needed by e.g. Postscript or PDF
66  OUString m_aPSName;
67  int m_nAscent;
68  int m_nDescent;
69  int m_nCapHeight;
70  tools::Rectangle m_aFontBBox;
71  FontType m_nFontType;
72 
73 private:
74  // input-font-specific details
75  unsigned const char* mpInFontBytes;
76  int mnInByteLength;
77  FontType meInFontType;
78  vcl::TrueTypeFont* mpSftTTFont;
79 
80  // subset-request details
81  FontType mnReqFontTypeMask;
82  FILE* mpOutFile;
83  const char* mpReqFontName;
84  const sal_GlyphId* mpReqGlyphIds;
85  const sal_uInt8* mpReqEncodedIds;
86  int mnReqGlyphCount;
87 
88  bool CreateFontSubsetFromCff( sal_Int32* pOutGlyphWidths );
89  bool CreateFontSubsetFromSfnt( sal_Int32* pOutGlyphWidths );
90  static bool CreateFontSubsetFromType1( const sal_Int32* pOutGlyphWidths );
91 };
92 
93 int VCL_DLLPUBLIC TestFontSubset(const void* data, sal_uInt32 size);
94 
95 #endif // INCLUDED_VCL_INC_FONTSUBSET_HXX
96 
97 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
CFF-container with PSType2 glyphs.
SFNT container with CFF-container.
FontType
< SFT's idea of a TTF font
Definition: fontsubset.hxx:33
PSType3 Postscript font.
PSType1 Postscript Font Ascii.
SFNT container with TrueType glyphs.
PSType42 wrapper for an SFNT_TTF.
PSType1 Postscript Font Binary.