Gtk-WARNING gtktreestore.c:1047: Invalid column number 1 added to iter
[LibreOffice.git] / vcl / inc / fontsubset.hxx
blob490d4839f711e112508b33a9ba5cbdb421641a01
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 #pragma once
22 #include <rtl/ustring.hxx>
23 #include <tools/gen.hxx>
24 #include <o3tl/typed_flags_set.hxx>
26 #include <vcl/dllapi.h>
28 #include "glyphid.hxx"
30 namespace vcl { class TrueTypeFont; } ///< SFT's idea of a TTF font
31 class SvStream;
33 enum class FontType {
34 NO_FONT = 0,
35 SFNT_TTF = 1<<1, ///< SFNT container with TrueType glyphs
36 SFNT_CFF = 1<<2, ///< SFNT container with CFF-container
37 TYPE1_PFA = 1<<3, ///< PSType1 Postscript Font Ascii
38 TYPE1_PFB = 1<<4, ///< PSType1 Postscript Font Binary
39 CFF_FONT = 1<<5, ///< CFF-container with PSType2 glyphs
40 ANY_SFNT = SFNT_TTF | SFNT_CFF,
41 ANY_TYPE1 = TYPE1_PFA | TYPE1_PFB
43 namespace o3tl {
44 template<> struct typed_flags<FontType> : is_typed_flags<FontType, (1<<8)-1> {};
47 class VCL_DLLPUBLIC FontSubsetInfo final
49 public:
50 SAL_DLLPRIVATE explicit FontSubsetInfo();
51 SAL_DLLPRIVATE ~FontSubsetInfo();
53 SAL_DLLPRIVATE void LoadFont( FontType eInFontType,
54 const unsigned char* pFontBytes, int nByteLength );
56 SAL_DLLPRIVATE bool CreateFontSubset( FontType nOutFontTypeMask,
57 SvStream* pOutFile,
58 const sal_GlyphId* pGlyphIds, const sal_uInt8* pEncodedIds,
59 int nReqGlyphCount);
61 public: // TODO: make subsetter results private and provide accessor methods instead
62 // subsetter-provided subset details needed by e.g. Postscript or PDF
63 OUString m_aPSName;
64 int m_nAscent; ///< all metrics in PS font units
65 int m_nDescent;
66 int m_nCapHeight;
67 tools::Rectangle m_aFontBBox;
68 FontType m_nFontType; ///< font-type of subset result
69 bool m_bFilled;
71 private:
72 // input-font-specific details
73 unsigned const char* mpInFontBytes;
74 int mnInByteLength;
75 FontType meInFontType; ///< allowed mask of input font-types
77 // subset-request details
78 FontType mnReqFontTypeMask; ///< allowed subset-target font types
79 SvStream* mpOutFile;
80 OString maReqFontName;
81 const sal_GlyphId* mpReqGlyphIds;
82 const sal_uInt8* mpReqEncodedIds;
83 int mnReqGlyphCount;
85 SAL_DLLPRIVATE bool CreateFontSubsetFromCff();
88 int VCL_DLLPUBLIC TestFontSubset(const void* data, sal_uInt32 size);
90 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */