|
LibreOffice Module vcl (master) 1
|
Helper functions for handling embedded fonts in documents. More...
#include <embeddedfontshelper.hxx>
Public Types | |
| enum class | FontRights { ViewingAllowed , EditingAllowed } |
| Specification of what kind of operation is allowed when embedding a font. More... | |
Public Member Functions | |
| bool | addEmbeddedFont (const css::uno::Reference< css::io::XInputStream > &stream, const OUString &fontName, std::u16string_view extra, std::vector< unsigned char > const &key, bool eot=false) |
| Reads a font from the input stream, saves it to a temporary font file and adds it to the list of fonts that activateFonts will activate. More... | |
| void | activateFonts () |
| Adds the accumulated fonts to the list of known fonts. More... | |
| ~EmbeddedFontsHelper () COVERITY_NOEXCEPT_FALSE | |
Static Public Member Functions | |
| static OUString | fontFileUrl (std::u16string_view 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 OUString | fileUrlForTemporaryFont (const OUString &fontName, std::u16string_view extra) |
| Returns a URL for a file where to store contents of a given temporary font. More... | |
| static bool | sufficientTTFRights (const void *data, tools::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... | |
Static Private Member Functions | |
| static void | activateFont (const OUString &fontName, const OUString &fileUrl) |
| Adds the given font to the list of known fonts. More... | |
Private Attributes | |
| std::vector< std::pair< OUString, OUString > > | m_aAccumulatedFonts |
Helper functions for handling embedded fonts in documents.
Definition at line 29 of file embeddedfontshelper.hxx.
|
strong |
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 45 of file embeddedfontshelper.hxx.
|
inline |
Definition at line 102 of file embeddedfontshelper.hxx.
|
staticprivate |
Adds the given font to the list of known fonts.
The font is used only until application exit.
| fontName | name of the font (e.g. 'Times New Roman') |
| fileUrl | URL of the font file |
Definition at line 208 of file embeddedfontshelper.cxx.
References OutputDevice::AddTempDevFont(), and Application::GetDefaultDevice().
Referenced by activateFonts().
| void EmbeddedFontsHelper::activateFonts | ( | ) |
Adds the accumulated fonts to the list of known fonts.
The fonts are used only until application exit.
Definition at line 182 of file embeddedfontshelper.cxx.
References activateFont(), and m_aAccumulatedFonts.
| bool EmbeddedFontsHelper::addEmbeddedFont | ( | const css::uno::Reference< css::io::XInputStream > & | stream, |
| const OUString & | fontName, | ||
| std::u16string_view | extra, | ||
| std::vector< unsigned char > const & | key, | ||
| bool | eot = false |
||
| ) |
Reads a font from the input stream, saves it to a temporary font file and adds it to the list of fonts that activateFonts will activate.
| stream | stream of font data |
| fontName | name of the font (e.g. 'Times New Roman') |
| extra | additional text to use for name (e.g. to distinguish regular from bold, italic,...), "?" for unique |
| key | key to xor the data with, from the start until the key's length (not repeated) |
| eot | whether the data is compressed in Embedded OpenType format |
Definition at line 68 of file embeddedfontshelper.cxx.
References EditingAllowed, fileUrlForTemporaryFont(), m_aAccumulatedFonts, pos, SAL_INFO, SAL_WARN, stream, and sufficientTTFRights().
|
static |
Removes all temporary fonts in the path used by fileUrlForTemporaryFont().
Definition at line 59 of file embeddedfontshelper.cxx.
References clearDir(), and SAL_CONFIGFILE.
Referenced by DeInitVCL(), and InitVCL().
|
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.
| fontName | name of the font (e.g. 'Times New Roman') |
| extra | additional text to use for name (e.g. to distinguish regular from bold, italic,...), "?" for unique |
Definition at line 192 of file embeddedfontshelper.cxx.
References SAL_CONFIGFILE, and u.
Referenced by addEmbeddedFont().
|
static |
Returns URL for a font file for the given font, or empty if it does not exist.
Definition at line 242 of file embeddedfontshelper.cxx.
References FAMILY_DONTKNOW, Application::GetDefaultDevice(), SalGraphics::GetDevFontList(), FontAttributes::GetFamilyName(), FontAttributes::GetFamilyType(), OutputDevice::GetGraphics(), FontAttributes::GetItalic(), FontAttributes::GetPitch(), FontAttributes::GetWeight(), i, italic, ITALIC_DONTKNOW, PITCH_DONTKNOW, SAL_CONFIGFILE, size, sufficientTTFRights(), and WEIGHT_DONTKNOW.
|
static |
Returns if the restrictions specified in the font (if present) allow embedding the font for a particular purpose.
| data | font data |
| size | size of the font data |
| rights | type of operation to be allowed for the font |
Definition at line 219 of file embeddedfontshelper.cxx.
References vcl::CloseTTFont(), EditingAllowed, vcl::GetTTGlobalFontInfo(), vcl::OpenTTFontBuffer(), size, vcl::TTGlobalFontInfo_::typeFlags, and ViewingAllowed.
Referenced by addEmbeddedFont(), and fontFileUrl().
|
private |
Definition at line 32 of file embeddedfontshelper.hxx.
Referenced by activateFonts(), and addEmbeddedFont().