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 #include <vcl/glyphitem.hxx>
29 
30 namespace vcl { struct TrueTypeFont; }
31 
32 enum class FontType {
33  NO_FONT = 0,
34  SFNT_TTF = 1<<1,
35  SFNT_CFF = 1<<2,
36  TYPE1_PFA = 1<<3,
37  TYPE1_PFB = 1<<4,
38  CFF_FONT = 1<<5,
39  TYPE3_FONT = 1<<6,
40  TYPE42_FONT = 1<<7,
43 };
44 namespace o3tl {
45  template<> struct typed_flags<FontType> : is_typed_flags<FontType, (1<<8)-1> {};
46 }
47 
48 class VCL_DLLPUBLIC FontSubsetInfo final
49 {
50 public:
51  explicit FontSubsetInfo();
52  ~FontSubsetInfo();
53 
54  void LoadFont( FontType eInFontType,
55  const unsigned char* pFontBytes, int nByteLength );
56  void LoadFont( vcl::TrueTypeFont* pSftTrueTypeFont );
57 
58  bool CreateFontSubset( FontType nOutFontTypeMask,
59  FILE* pOutFile, const char* pOutFontName,
60  const sal_GlyphId* pGlyphIds, const sal_uInt8* pEncodedIds,
61  int nReqGlyphCount, sal_Int32* pOutGlyphWidths = nullptr );
62 
63 public: // TODO: make subsetter results private and provide accessor methods instead
64  // subsetter-provided subset details needed by e.g. Postscript or PDF
65  OUString m_aPSName;
66  int m_nAscent;
67  int m_nDescent;
68  int m_nCapHeight;
69  tools::Rectangle m_aFontBBox;
70  FontType m_nFontType;
71 
72 private:
73  // input-font-specific details
74  unsigned const char* mpInFontBytes;
75  int mnInByteLength;
76  FontType meInFontType;
77  vcl::TrueTypeFont* mpSftTTFont;
78 
79  // subset-request details
80  FontType mnReqFontTypeMask;
81  FILE* mpOutFile;
82  const char* mpReqFontName;
83  const sal_GlyphId* mpReqGlyphIds;
84  const sal_uInt8* mpReqEncodedIds;
85  int mnReqGlyphCount;
86 
87  bool CreateFontSubsetFromCff( sal_Int32* pOutGlyphWidths );
88  bool CreateFontSubsetFromSfnt( sal_Int32* pOutGlyphWidths );
89  static bool CreateFontSubsetFromType1( const sal_Int32* pOutGlyphWidths );
90 };
91 
92 #endif // INCLUDED_VCL_INC_FONTSUBSET_HXX
93 
94 /* 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:32
PSType3 Postscript font.
PSType1 Postscript Font Ascii.
SFNT container with TrueType glyphs.
PSType42 wrapper for an SFNT_TTF.
PSType1 Postscript Font Binary.