Aspose::Words::Fonts::MemoryFontSource Class Reference

Detailed Description

Represents the single TrueType font file stored in memory.

Examples

Shows how to use a byte array with data from a font file as a font source.

ArrayPtr<uint8_t> fontBytes = System::IO::File::ReadAllBytes(MyDir + u"Alte DIN 1451 Mittelschrift.ttf");
auto memoryFontSource = MakeObject<MemoryFontSource>(fontBytes, 0);
auto doc = MakeObject<Document>();
doc->set_FontSettings(MakeObject<FontSettings>());
doc->get_FontSettings()->SetFontsSources(MakeArray<SharedPtr<FontSourceBase>>({memoryFontSource}));
ASSERT_EQ(FontSourceType::MemoryFont, memoryFontSource->get_Type());
ASSERT_EQ(0, memoryFontSource->get_Priority());

#include <Aspose.Words.Cpp/Fonts/MemoryFontSource.h>

+ Inheritance diagram for Aspose::Words::Fonts::MemoryFontSource:

Public Member Functions

 MemoryFontSource (const ArrayPtr< uint8_t > &fontData)
 Ctor. More...
 
 MemoryFontSource (const ArrayPtr< uint8_t > &fontData, int32_t priority)
 Ctor. More...
 
 MemoryFontSource (const ArrayPtr< uint8_t > &fontData, int32_t priority, const String &cacheKey)
 Ctor. More...
 
String get_CacheKey () const
 The key of this source in the cache. More...
 
ArrayPtr< uint8_t > get_FontData () const
 Binary font data. More...
 
FontSourceType get_Type () override
 Returns the type of the font source. More...
 
virtual const TypeInfoGetType () const override
 
virtual bool Is (const TypeInfo &target) const override
 
- Public Member Functions inherited from FontSourceBase
int32_t get_Priority () const
 Returns the font source priority. More...
 
virtual FontSourceType get_Type ()=0
 Returns the type of the font source. More...
 
SharedPtr< IWarningCallbackget_WarningCallback () const
 Called during processing of font source when an issue is detected that might result in formatting fidelity loss. More...
 
SharedPtr< IList< SharedPtr< PhysicalFontInfo > > > GetAvailableFonts ()
 Returns list of fonts available via this source. More...
 
virtual const TypeInfoGetType () const override
 
virtual bool Is (const TypeInfo &target) const override
 
void set_WarningCallback (const SharedPtr< IWarningCallback > &value)
 Setter for get_WarningCallback. More...
 

Static Public Member Functions

static const TypeInfoType ()
 
- Static Public Member Functions inherited from FontSourceBase
static const TypeInfoType ()
 

Constructor & Destructor Documentation

◆ MemoryFontSource() [1/3]

Aspose::Words::Fonts::MemoryFontSource::MemoryFontSource ( const System::ArrayPtr< uint8_t > &  fontData)

Ctor.

Parameters
fontDataBinary font data.
Examples

Shows how to use a byte array with data from a font file as a font source.

ArrayPtr<uint8_t> fontBytes = System::IO::File::ReadAllBytes(MyDir + u"Alte DIN 1451 Mittelschrift.ttf");
auto memoryFontSource = MakeObject<MemoryFontSource>(fontBytes, 0);
auto doc = MakeObject<Document>();
doc->set_FontSettings(MakeObject<FontSettings>());
doc->get_FontSettings()->SetFontsSources(MakeArray<SharedPtr<FontSourceBase>>({memoryFontSource}));
ASSERT_EQ(FontSourceType::MemoryFont, memoryFontSource->get_Type());
ASSERT_EQ(0, memoryFontSource->get_Priority());

◆ MemoryFontSource() [2/3]

Aspose::Words::Fonts::MemoryFontSource::MemoryFontSource ( const System::ArrayPtr< uint8_t > &  fontData,
int32_t  priority 
)

Ctor.

Parameters
fontDataBinary font data.
priorityFont source priority. See the Priority property description for more information.
Examples

Shows how to use a byte array with data from a font file as a font source.

ArrayPtr<uint8_t> fontBytes = System::IO::File::ReadAllBytes(MyDir + u"Alte DIN 1451 Mittelschrift.ttf");
auto memoryFontSource = MakeObject<MemoryFontSource>(fontBytes, 0);
auto doc = MakeObject<Document>();
doc->set_FontSettings(MakeObject<FontSettings>());
doc->get_FontSettings()->SetFontsSources(MakeArray<SharedPtr<FontSourceBase>>({memoryFontSource}));
ASSERT_EQ(FontSourceType::MemoryFont, memoryFontSource->get_Type());
ASSERT_EQ(0, memoryFontSource->get_Priority());

◆ MemoryFontSource() [3/3]

Aspose::Words::Fonts::MemoryFontSource::MemoryFontSource ( const System::ArrayPtr< uint8_t > &  fontData,
int32_t  priority,
const System::String cacheKey 
)

Ctor.

Parameters
fontDataBinary font data.
priorityFont source priority. See the Priority property description for more information.
cacheKeyThe key of this source in the cache. See CacheKey property description for more information.

Member Function Documentation

◆ get_CacheKey()

System::String Aspose::Words::Fonts::MemoryFontSource::get_CacheKey ( ) const

The key of this source in the cache.

◆ get_FontData()

System::ArrayPtr< uint8_t > Aspose::Words::Fonts::MemoryFontSource::get_FontData ( ) const

Binary font data.

Examples

Shows how to use a byte array with data from a font file as a font source.

ArrayPtr<uint8_t> fontBytes = System::IO::File::ReadAllBytes(MyDir + u"Alte DIN 1451 Mittelschrift.ttf");
auto memoryFontSource = MakeObject<MemoryFontSource>(fontBytes, 0);
auto doc = MakeObject<Document>();
doc->set_FontSettings(MakeObject<FontSettings>());
doc->get_FontSettings()->SetFontsSources(MakeArray<SharedPtr<FontSourceBase>>({memoryFontSource}));
ASSERT_EQ(FontSourceType::MemoryFont, memoryFontSource->get_Type());
ASSERT_EQ(0, memoryFontSource->get_Priority());

◆ get_Type()

Aspose::Words::Fonts::FontSourceType Aspose::Words::Fonts::MemoryFontSource::get_Type ( )
overridevirtual

Returns the type of the font source.

Examples

Shows how to use a byte array with data from a font file as a font source.

ArrayPtr<uint8_t> fontBytes = System::IO::File::ReadAllBytes(MyDir + u"Alte DIN 1451 Mittelschrift.ttf");
auto memoryFontSource = MakeObject<MemoryFontSource>(fontBytes, 0);
auto doc = MakeObject<Document>();
doc->set_FontSettings(MakeObject<FontSettings>());
doc->get_FontSettings()->SetFontsSources(MakeArray<SharedPtr<FontSourceBase>>({memoryFontSource}));
ASSERT_EQ(FontSourceType::MemoryFont, memoryFontSource->get_Type());
ASSERT_EQ(0, memoryFontSource->get_Priority());

Implements Aspose::Words::Fonts::FontSourceBase.

◆ GetType()

virtual const System::TypeInfo & Aspose::Words::Fonts::MemoryFontSource::GetType ( ) const
overridevirtual

◆ Is()

virtual bool Aspose::Words::Fonts::MemoryFontSource::Is ( const System::TypeInfo target) const
overridevirtual

◆ Type()

static const System::TypeInfo & Aspose::Words::Fonts::MemoryFontSource::Type ( )
static