1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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/.
10 #ifndef INCLUDED_VCL_EMBEDDEDFONTSHELPER_HXX
11 #define INCLUDED_VCL_EMBEDDEDFONTSHELPER_HXX
13 #include <vcl/dllapi.h>
15 #include <com/sun/star/io/XInputStream.hpp>
16 #include <com/sun/star/uno/Reference.hxx>
17 #include <rtl/ustring.hxx>
18 #include <tools/fontenum.hxx>
22 Helper functions for handling embedded fonts in documents.
25 class VCL_DLLPUBLIC EmbeddedFontsHelper
28 /// Specification of what kind of operation is allowed when embedding a font
31 ViewingAllowed
, ///< Font may be embedded for viewing the document (but not editing)
32 EditingAllowed
///< Font may be embedded for editing document (implies viewing)
36 Returns URL for a font file for the given font, or empty if it does not exist.
38 static OUString
fontFileUrl( const OUString
& familyName
, FontFamily family
, FontItalic italic
,
39 FontWeight weight
, FontPitch pitch
, rtl_TextEncoding encoding
, FontRights rights
);
42 Reads a font from the input stream, saves it to a temporary font file and activates the font.
43 @param stream stream of font data
44 @param fontName name of the font (e.g. 'Times New Roman')
45 @param extra additional text to use for name (e.g. to distinguish regular from bold, italic,...), "?" for unique
46 @param key key to xor the data with, from the start until the key's length (not repeated)
47 @param eot whether the data is compressed in Embedded OpenType format
49 static bool addEmbeddedFont( com::sun::star::uno::Reference
< com::sun::star::io::XInputStream
> stream
,
50 const OUString
& fontName
, const char* extra
,
51 std::vector
< unsigned char > key
= std::vector
< unsigned char >(), bool eot
= false);
54 Returns an URL for a file where to store contents of a given temporary font.
55 The file may or not may not exist yet, and will be cleaned up automatically as appropriate.
56 Use activateTemporaryFont() to actually enable usage of the font.
58 @param fontName name of the font (e.g. 'Times New Roman')
59 @param extra additional text to use for name (e.g. to distinguish regular from bold, italic,...), "?" for unique
61 static OUString
fileUrlForTemporaryFont( const OUString
& fontName
, const char* extra
);
64 Adds the given font to the list of known fonts. The font is used only until application
67 @param fontName name of the font (e.g. 'Times New Roman')
68 @param fileUrl URL of the font file
70 static void activateFont( const OUString
& fontName
, const OUString
& fileUrl
);
73 Returns if the restrictions specified in the font (if present) allow embedding
74 the font for a particular purpose.
76 @param size size of the font data
77 @param rights type of operation to be allowed for the font
79 static bool sufficientTTFRights( const void* data
, long size
, FontRights rights
);
82 Removes all temporary fonts in the path used by fileUrlForTemporaryFont().
85 static void clearTemporaryFontFiles();
90 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */