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 <rtl/ustring.hxx>
16 #include <tools/fontenum.hxx>
19 namespace com
{ namespace sun
{ namespace star
{ namespace io
{ class XInputStream
; } } } }
20 namespace com
{ namespace sun
{ namespace star
{ namespace uno
{ template <typename
> class Reference
; } } } }
23 Helper functions for handling embedded fonts in documents.
26 class VCL_DLLPUBLIC EmbeddedFontsHelper
29 /// Specification of what kind of operation is allowed when embedding a font
32 ViewingAllowed
, ///< Font may be embedded for viewing the document (but not editing)
33 EditingAllowed
///< Font may be embedded for editing document (implies viewing)
37 Returns URL for a font file for the given font, or empty if it does not exist.
39 static OUString
fontFileUrl( const OUString
& familyName
, FontFamily family
, FontItalic italic
,
40 FontWeight weight
, FontPitch pitch
, FontRights rights
);
43 Reads a font from the input stream, saves it to a temporary font file and activates the font.
44 @param stream stream of font data
45 @param fontName name of the font (e.g. 'Times New Roman')
46 @param extra additional text to use for name (e.g. to distinguish regular from bold, italic,...), "?" for unique
47 @param key key to xor the data with, from the start until the key's length (not repeated)
48 @param eot whether the data is compressed in Embedded OpenType format
50 static bool addEmbeddedFont( const css::uno::Reference
< css::io::XInputStream
>& stream
,
51 const OUString
& fontName
, const char* extra
,
52 std::vector
< unsigned char > key
, bool eot
= false);
55 Returns a URL for a file where to store contents of a given temporary font.
56 The file may or not may not exist yet, and will be cleaned up automatically as appropriate.
57 Use activateTemporaryFont() to actually enable usage of the font.
59 @param fontName name of the font (e.g. 'Times New Roman')
60 @param extra additional text to use for name (e.g. to distinguish regular from bold, italic,...), "?" for unique
62 static OUString
fileUrlForTemporaryFont( const OUString
& fontName
, const char* extra
);
65 Adds the given font to the list of known fonts. The font is used only until application
68 @param fontName name of the font (e.g. 'Times New Roman')
69 @param fileUrl URL of the font file
71 static void activateFont( const OUString
& fontName
, const OUString
& fileUrl
);
74 Returns if the restrictions specified in the font (if present) allow embedding
75 the font for a particular purpose.
77 @param size size of the font data
78 @param rights type of operation to be allowed for the font
80 static bool sufficientTTFRights( const void* data
, long size
, FontRights rights
);
83 Removes all temporary fonts in the path used by fileUrlForTemporaryFont().
86 static void clearTemporaryFontFiles();
91 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */