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