Represents font object. More...

Inherits System::Object.

Public Member Functions

System::String get_FontName () const
 Gets font name of the Font object. More...
 
System::String get_DecodedFontName ()
 Sometimes PDF fonts(usually Chinese/Japanese/Korean fonts) could have specificical font name. This name is value of PDF font property "BaseFont" and sometimes this property could be represented in hexademical form. If read this name directly it could be represented in non-readable form. To get readable form it's necessary to decode font's name by rules specifical for this font. This property returns decoded font name, so use it for cases when you meet with a non-readable FontName. If property FontName has readable form this property will be the same as FontName, so you can use this property for any cases when you need to get font name in a readable form. More...
 
bool get_IsEmbedded () const
 Gets a value that indicates whether the font is embedded. More...
 
void set_IsEmbedded (bool value)
 Sets a value that indicates whether the font is embedded. More...
 
bool get_IsSubset ()
 Gets a value that indicates whether the font is a subset. More...
 
void set_IsSubset (bool value)
 Sets a value that indicates whether the font is a subset. More...
 
bool get_IsAccessible () const
 Gets indicating whether the font is present (installed) in the system. More...
 
System::SharedPtr< IFontOptionsget_FontOptions ()
 Useful properties to tune Font behaviour More...
 
System::String GetLastFontEmbeddingError ()
 An objective of this method - to return description of error if an attempt to embed font was failed. If there are no error cases it returns empty string. More...
 
void Save (System::SharedPtr< System::IO::Stream > stream)
 Saves the font into the stream. Note that the font is saved to intermediate TTF format intended to be used in a converted copy of the original document only. The font file is not intended to be used outside the original document context. More...
 
double MeasureString (System::String str, float fontSize)
 Measures the string. More...
 
- Public Member Functions inherited from System::Object
ASPOSECPP_SHARED_API Object ()
 Creates object. Initializes all internal data structures. More...
 
virtual ASPOSECPP_SHARED_API ~Object ()
 Destroys object. Frees all internal data structures. More...
 
ASPOSECPP_SHARED_API Object (Object const &x)
 Copy constructor. Doesn't copy anything, really, just initializes new object and enables copy constructing subclasses. More...
 
Objectoperator= (Object const &x)
 Assignment operator. Doesn't copy anything, really, just initializes new object and enables copy constructing subclasses. More...
 
ObjectSharedRefAdded ()
 Increments shared reference count. Shouldn't be called directly; instead, use smart pointers or ThisProtector. More...
 
int SharedRefRemovedSafe ()
 Decrements and returns shared reference count. Shouldn't be called directly; instead, use smart pointers or ThisProtector. More...
 
int RemovedSharedRefs (int count)
 Decreases shared reference count by specified value. More...
 
Detail::SmartPtrCounter * WeakRefAdded ()
 Increments weak reference count. Shouldn't be called directly; instead, use smart pointers or ThisProtector. More...
 
void WeakRefRemoved ()
 Decrements weak reference count. Shouldn't be called directly; instead, use smart pointers or ThisProtector. More...
 
Detail::SmartPtrCounter * GetCounter ()
 Gets reference counter data structure associated with the object. More...
 
int SharedCount () const
 Gets current value of shared refernce counter. More...
 
ASPOSECPP_SHARED_API void Lock ()
 Implements C# lock() statement locking. Call directly or use LockContext sentry object. More...
 
ASPOSECPP_SHARED_API void Unlock ()
 Implements C# lock() statement unlocking. Call directly or use LockContext sentry object. More...
 
virtual ASPOSECPP_SHARED_API bool Equals (ptr obj)
 Compares objects using C# Object.Equals semantics. More...
 
virtual ASPOSECPP_SHARED_API int GetHashCode () const
 Analog of C# Object.GetHashCode() method. Enables hashing of custom objects. More...
 
virtual ASPOSECPP_SHARED_API String ToString () const
 Analog of C# Object.ToString() method. Enables converting custom objects to string. More...
 
virtual ASPOSECPP_SHARED_API ptr MemberwiseClone () const
 Analog of C# Object.MemberwiseClone() method. Enables cloning custom types. More...
 
virtual ASPOSECPP_SHARED_API const TypeInfoGetType () const
 Gets actual type of object. Analog of C# System.Object.GetType() call. More...
 
virtual ASPOSECPP_SHARED_API bool Is (const TypeInfo &targetType) const
 Check if object represents an instance of type described by targetType. Analog of C# 'is' operator. More...
 
virtual ASPOSECPP_SHARED_API void SetTemplateWeakPtr (unsigned int argument)
 Set n'th template argument a weak pointer (rather than shared). Allows switching pointers in containers to weak mode. More...
 
template<>
bool Equals (float const &objA, float const &objB)
 
template<>
bool Equals (double const &objA, double const &objB)
 
template<>
bool ReferenceEquals (String const &str, std::nullptr_t)
 
template<>
bool ReferenceEquals (String const &str1, String const &str2)
 

Protected Member Functions

System::SharedPtr< Aspose::Pdf::Engine::CommonData::Text::Fonts::IPdfFont > get_iPdfFont () const
 
void set_iPdfFont (System::SharedPtr< Aspose::Pdf::Engine::CommonData::Text::Fonts::IPdfFont > value)
 
System::SharedPtr< Aspose::Fonts::IFont > get_iFont () const
 
void set_iFont (System::SharedPtr< Aspose::Fonts::IFont > value)
 
System::SharedPtr< Aspose::Pdf::Engine::CommonData::Text::Fonts::IPdfFont > get_IPdfFont ()
 Pdf font object. More...
 
System::SharedPtr< Aspose::Fonts::IFont > get_IFont ()
 System font object. More...
 
System::String get_UniqueId ()
 
 Font (System::SharedPtr< Aspose::Pdf::Engine::Data::IPdfPrimitive > fontObj)
 
 Font (System::SharedPtr< Aspose::Pdf::Engine::CommonData::Text::Fonts::IPdfFont > iPdfFont)
 
 Font (System::SharedPtr< Aspose::Fonts::IFont > font)
 
 Font (System::SharedPtr< Aspose::Pdf::Engine::Data::ITrailerable > trailerable, System::SharedPtr< Aspose::Pdf::Engine::CommonData::Text::Fonts::IPdfFont > iPdfFont)
 
void InitWithIPdfFont (System::SharedPtr< Aspose::Pdf::Engine::Data::ITrailerable > trailerable, System::SharedPtr< Aspose::Pdf::Engine::CommonData::Text::Fonts::IPdfFont > iPdfFont)
 
System::SharedPtr< FontClone ()
 
virtual ~Font ()
 

Protected Attributes

System::EventHandler FontPropertiesChanged
 

Additional Inherited Members

- Public Types inherited from System::Object
typedef SmartPtr< Objectptr
 Alias for smart pointer type. More...
 
typedef System::Details::SharedMembersType shared_members_type
 structure to keep list of shared pointers contained in object. More...
 
- Static Public Member Functions inherited from System::Object
static bool ReferenceEquals (ptr const &objA, ptr const &objB)
 Compares objects by reference. More...
 
template<typename T >
static std::enable_if<!IsSmartPtr< T >::value, bool >::type ReferenceEquals (T const &objA, T const &objB)
 Compares objects by reference. More...
 
template<typename T >
static std::enable_if<!IsSmartPtr< T >::value, bool >::type ReferenceEquals (T const &objA, std::nullptr_t)
 Reference-compares value type object with nullptr. More...
 
template<typename T1 , typename T2 >
static std::enable_if< IsSmartPtr< T1 >::value &&IsSmartPtr< T2 >::value, bool >::type Equals (T1 const &objA, T2 const &objB)
 Compares reference type objects in C# style. More...
 
template<typename T1 , typename T2 >
static std::enable_if<!IsSmartPtr< T1 >::value &&!IsSmartPtr< T2 >::value, bool >::type Equals (T1 const &objA, T2 const &objB)
 Compares value type objects in C# style. More...
 
static const TypeInfoType ()
 Impleemnts C# typeof(System.Object) construct. More...
 

Detailed Description

Represents font object.

The example demonstrates how to search text on first page and change font of a first search occurrence.

// Open document
Document doc = new Document(@"D:\Tests\input.pdf");
// Create TextFragmentAbsorber object to find all "hello world" text occurrences
TextFragmentAbsorber absorber = new TextFragmentAbsorber("hello world");
// Accept the absorber for first page
doc.Pages[1].Accept(absorber);
// Create font and mark it to be embedded
Font font = FontRepository.FindFont("Arial");
font.IsEmbedded = true;
// Change font of the first text occurrence
absorber.TextFragments[1].TextState.Font = font;
// Save document
doc.Save(@"D:\Tests\output.pdf");
See also
TextFragmentAbsorber
See also
FontRepository
See also
Document

Constructor & Destructor Documentation

◆ Font() [1/4]

Aspose::Pdf::Text::Font::Font ( System::SharedPtr< Aspose::Pdf::Engine::Data::IPdfPrimitive >  fontObj)
protected

◆ Font() [2/4]

Aspose::Pdf::Text::Font::Font ( System::SharedPtr< Aspose::Pdf::Engine::CommonData::Text::Fonts::IPdfFont >  iPdfFont)
protected

◆ Font() [3/4]

Aspose::Pdf::Text::Font::Font ( System::SharedPtr< Aspose::Fonts::IFont >  font)
protected

◆ Font() [4/4]

Aspose::Pdf::Text::Font::Font ( System::SharedPtr< Aspose::Pdf::Engine::Data::ITrailerable >  trailerable,
System::SharedPtr< Aspose::Pdf::Engine::CommonData::Text::Fonts::IPdfFont >  iPdfFont 
)
protected

◆ ~Font()

virtual Aspose::Pdf::Text::Font::~Font ( )
protectedvirtual

Member Function Documentation

◆ Clone()

System::SharedPtr<Font> Aspose::Pdf::Text::Font::Clone ( )
protected

◆ get_DecodedFontName()

System::String Aspose::Pdf::Text::Font::get_DecodedFontName ( )

Sometimes PDF fonts(usually Chinese/Japanese/Korean fonts) could have specificical font name. This name is value of PDF font property "BaseFont" and sometimes this property could be represented in hexademical form. If read this name directly it could be represented in non-readable form. To get readable form it's necessary to decode font's name by rules specifical for this font. This property returns decoded font name, so use it for cases when you meet with a non-readable FontName. If property FontName has readable form this property will be the same as FontName, so you can use this property for any cases when you need to get font name in a readable form.

◆ get_FontName()

System::String Aspose::Pdf::Text::Font::get_FontName ( ) const

Gets font name of the Font object.

The example demonstrates how to search text on first page and view font name of a first text occurrence.

// Open document
Document doc = new Document(@"D:\Tests\input.pdf");
// Create TextFragmentAbsorber object to find all "hello world" text occurrences
TextFragmentAbsorber absorber = new TextFragmentAbsorber("hello world");
// Accept the absorber for first page
doc.Pages[1].Accept(absorber);
// View font name of first text occurrence
Console.Out.WriteLine(absorber.TextFragments[1].TextState.Font.FontName);
See also
TextFragmentAbsorber
See also
Document

◆ get_FontOptions()

System::SharedPtr<IFontOptions> Aspose::Pdf::Text::Font::get_FontOptions ( )

Useful properties to tune Font behaviour

◆ get_iFont()

System::SharedPtr<Aspose::Fonts::IFont> Aspose::Pdf::Text::Font::get_iFont ( ) const
protected

◆ get_IFont()

System::SharedPtr<Aspose::Fonts::IFont> Aspose::Pdf::Text::Font::get_IFont ( )
protected

System font object.

For internal usage only

◆ get_iPdfFont()

System::SharedPtr<Aspose::Pdf::Engine::CommonData::Text::Fonts::IPdfFont> Aspose::Pdf::Text::Font::get_iPdfFont ( ) const
protected

◆ get_IPdfFont()

System::SharedPtr<Aspose::Pdf::Engine::CommonData::Text::Fonts::IPdfFont> Aspose::Pdf::Text::Font::get_IPdfFont ( )
protected

Pdf font object.

For internal usage only

◆ get_IsAccessible()

bool Aspose::Pdf::Text::Font::get_IsAccessible ( ) const

Gets indicating whether the font is present (installed) in the system.

Some operations are not available with fonts that could not be found in the system.

The example demonstrates how to search text on first page and get the value that indicates whether the font is installed in the system.

// Open document
Document doc = new Document(@"D:\Tests\input.pdf");
// Create TextFragmentAbsorber object to find all "hello world" text occurrences
TextFragmentAbsorber absorber = new TextFragmentAbsorber("hello world");
// Accept the absorber for first page
doc.Pages[1].Accept(absorber);
// View font's IsSubset value of first text occurrence
if(absorber.TextFragments[1].TextState.Font.IsAccessible)
Console.Out.WriteLine("the font is installed in the system");
See also
TextFragmentAbsorber
See also
Document

◆ get_IsEmbedded()

bool Aspose::Pdf::Text::Font::get_IsEmbedded ( ) const

Gets a value that indicates whether the font is embedded.

The following example demonstrates how to find a font, mark it as embedded, search text on the document's page and replace the text font.

// Create font and mark it to be embedded
Font font = FontRepository.FindFont("Arial");
font.IsEmbedded = true;
// open document
Document doc = new Document(@"D:\Tests\input.pdf");
// create TextFragmentAbsorber object to find all "hello world" text occurrences
TextFragmentAbsorber absorber = new TextFragmentAbsorber("hello world");
// accept the absorber for first page
doc.Pages[1].Accept(absorber);
// change font for the first text occurrence
absorber.TextFragments[1].TextState.Font = font;
// save document
doc.Save(@"D:\Tests\output.pdf");
See also
TextFragmentAbsorber
See also
FontRepository
See also
Document

◆ get_IsSubset()

bool Aspose::Pdf::Text::Font::get_IsSubset ( )

Gets a value that indicates whether the font is a subset.

The example demonstrates how to search text on first page and get the value that indicates whether the font is a subset.

// Open document
Document doc = new Document(@"D:\Tests\input.pdf");
// Create TextFragmentAbsorber object to find all "hello world" text occurrences
TextFragmentAbsorber absorber = new TextFragmentAbsorber("hello world");
// Accept the absorber for first page
doc.Pages[1].Accept(absorber);
// View font's IsSubset value of first text occurrence
if(absorber.TextFragments[1].TextState.Font.IsSubset)
Console.Out.WriteLine("the font is a subset");
See also
TextFragmentAbsorber
See also
Document

◆ get_UniqueId()

System::String Aspose::Pdf::Text::Font::get_UniqueId ( )
protected

◆ GetLastFontEmbeddingError()

System::String Aspose::Pdf::Text::Font::GetLastFontEmbeddingError ( )

An objective of this method - to return description of error if an attempt to embed font was failed. If there are no error cases it returns empty string.

Returns
Error description

◆ InitWithIPdfFont()

void Aspose::Pdf::Text::Font::InitWithIPdfFont ( System::SharedPtr< Aspose::Pdf::Engine::Data::ITrailerable >  trailerable,
System::SharedPtr< Aspose::Pdf::Engine::CommonData::Text::Fonts::IPdfFont >  iPdfFont 
)
protected

◆ MeasureString()

double Aspose::Pdf::Text::Font::MeasureString ( System::String  str,
float  fontSize 
)

Measures the string.

Parameters
strThe string.
fontSizeFont size.
Returns
Width of the string represented with this font and the specified size.

◆ Save()

void Aspose::Pdf::Text::Font::Save ( System::SharedPtr< System::IO::Stream stream)

Saves the font into the stream. Note that the font is saved to intermediate TTF format intended to be used in a converted copy of the original document only. The font file is not intended to be used outside the original document context.

Parameters
streamStream to save the font.

◆ set_iFont()

void Aspose::Pdf::Text::Font::set_iFont ( System::SharedPtr< Aspose::Fonts::IFont >  value)
protected

◆ set_iPdfFont()

void Aspose::Pdf::Text::Font::set_iPdfFont ( System::SharedPtr< Aspose::Pdf::Engine::CommonData::Text::Fonts::IPdfFont >  value)
protected

◆ set_IsEmbedded()

void Aspose::Pdf::Text::Font::set_IsEmbedded ( bool  value)

Sets a value that indicates whether the font is embedded.

The following example demonstrates how to find a font, mark it as embedded, search text on the document's page and replace the text font.

// Create font and mark it to be embedded
Font font = FontRepository.FindFont("Arial");
font.IsEmbedded = true;
// open document
Document doc = new Document(@"D:\Tests\input.pdf");
// create TextFragmentAbsorber object to find all "hello world" text occurrences
TextFragmentAbsorber absorber = new TextFragmentAbsorber("hello world");
// accept the absorber for first page
doc.Pages[1].Accept(absorber);
// change font for the first text occurrence
absorber.TextFragments[1].TextState.Font = font;
// save document
doc.Save(@"D:\Tests\output.pdf");
See also
TextFragmentAbsorber
See also
FontRepository
See also
Document

◆ set_IsSubset()

void Aspose::Pdf::Text::Font::set_IsSubset ( bool  value)

Sets a value that indicates whether the font is a subset.

The example demonstrates how to search text on first page and get the value that indicates whether the font is a subset.

// Open document
Document doc = new Document(@"D:\Tests\input.pdf");
// Create TextFragmentAbsorber object to find all "hello world" text occurrences
TextFragmentAbsorber absorber = new TextFragmentAbsorber("hello world");
// Accept the absorber for first page
doc.Pages[1].Accept(absorber);
// View font's IsSubset value of first text occurrence
if(absorber.TextFragments[1].TextState.Font.IsSubset)
Console.Out.WriteLine("the font is a subset");
See also
TextFragmentAbsorber
See also
Document

Member Data Documentation

◆ FontPropertiesChanged

System::EventHandler Aspose::Pdf::Text::Font::FontPropertiesChanged
protected