LibreOffice Module vcl (master)  1
Public Types | Static Public Member Functions | List of all members
EmbeddedFontsHelper Class Reference

Helper functions for handling embedded fonts in documents. More...

#include <embeddedfontshelper.hxx>

Public Types

enum  FontRights {
  FontRights::ViewingAllowed,
  FontRights::EditingAllowed
}
 Specification of what kind of operation is allowed when embedding a font. More...
 

Static Public Member Functions

static OUString fontFileUrl (const OUString &familyName, FontFamily family, FontItalic italic, FontWeight weight, FontPitch pitch, FontRights rights)
 Returns URL for a font file for the given font, or empty if it does not exist. More...
 
static bool addEmbeddedFont (const css::uno::Reference< css::io::XInputStream > &stream, const OUString &fontName, const char *extra, std::vector< unsigned char > key, bool eot=false)
 Reads a font from the input stream, saves it to a temporary font file and activates the font. More...
 
static OUString fileUrlForTemporaryFont (const OUString &fontName, const char *extra)
 Returns a URL for a file where to store contents of a given temporary font. More...
 
static void activateFont (const OUString &fontName, const OUString &fileUrl)
 Adds the given font to the list of known fonts. More...
 
static bool sufficientTTFRights (const void *data, long size, FontRights rights)
 Returns if the restrictions specified in the font (if present) allow embedding the font for a particular purpose. More...
 
static void clearTemporaryFontFiles ()
 Removes all temporary fonts in the path used by fileUrlForTemporaryFont(). More...
 

Detailed Description

Helper functions for handling embedded fonts in documents.

Definition at line 26 of file embeddedfontshelper.hxx.

Member Enumeration Documentation

Specification of what kind of operation is allowed when embedding a font.

Enumerator
ViewingAllowed 

Font may be embedded for viewing the document (but not editing)

EditingAllowed 

Font may be embedded for editing document (implies viewing)

Definition at line 30 of file embeddedfontshelper.hxx.

Member Function Documentation

void EmbeddedFontsHelper::activateFont ( const OUString &  fontName,
const OUString &  fileUrl 
)
static

Adds the given font to the list of known fonts.

The font is used only until application exit.

Parameters
fontNamename of the font (e.g. 'Times New Roman')
fileUrlURL of the font file

Definition at line 179 of file embeddedfontshelper.cxx.

References OutputDevice::AddTempDevFont(), and Application::GetDefaultDevice().

Referenced by addEmbeddedFont().

bool EmbeddedFontsHelper::addEmbeddedFont ( const css::uno::Reference< css::io::XInputStream > &  stream,
const OUString &  fontName,
const char *  extra,
std::vector< unsigned char >  key,
bool  eot = false 
)
static

Reads a font from the input stream, saves it to a temporary font file and activates the font.

Parameters
streamstream of font data
fontNamename of the font (e.g. 'Times New Roman')
extraadditional text to use for name (e.g. to distinguish regular from bold, italic,...), "?" for unique
keykey to xor the data with, from the start until the key's length (not repeated)
eotwhether the data is compressed in Embedded OpenType format

Definition at line 66 of file embeddedfontshelper.cxx.

References activateFont(), fileUrlForTemporaryFont(), SAL_INFO, and SAL_WARN.

void EmbeddedFontsHelper::clearTemporaryFontFiles ( )
static

Removes all temporary fonts in the path used by fileUrlForTemporaryFont().

Definition at line 57 of file embeddedfontshelper.cxx.

References clearDir(), and SAL_CONFIGFILE.

Referenced by DeInitVCL(), and InitVCL().

OUString EmbeddedFontsHelper::fileUrlForTemporaryFont ( const OUString &  fontName,
const char *  extra 
)
static

Returns a URL for a file where to store contents of a given temporary font.

The file may or not may not exist yet, and will be cleaned up automatically as appropriate. Use activateTemporaryFont() to actually enable usage of the font.

Parameters
fontNamename of the font (e.g. 'Times New Roman')
extraadditional text to use for name (e.g. to distinguish regular from bold, italic,...), "?" for unique

Definition at line 163 of file embeddedfontshelper.cxx.

References SAL_CONFIGFILE.

Referenced by addEmbeddedFont().

OUString EmbeddedFontsHelper::fontFileUrl ( const OUString &  familyName,
FontFamily  family,
FontItalic  italic,
FontWeight  weight,
FontPitch  pitch,
FontRights  rights 
)
static
bool EmbeddedFontsHelper::sufficientTTFRights ( const void data,
long  size,
FontRights  rights 
)
static

Returns if the restrictions specified in the font (if present) allow embedding the font for a particular purpose.

Parameters
datafont data
sizesize of the font data
rightstype of operation to be allowed for the font

Definition at line 190 of file embeddedfontshelper.cxx.

References vcl::CloseTTFont(), vcl::GetTTGlobalFontInfo(), vcl::OpenTTFontBuffer(), and vcl::TTGlobalFontInfo::typeFlags.


The documentation for this class was generated from the following files: