xtd 0.2.0
Loading...
Searching...
No Matches
xtd::drawing::font Class Referencefinal
Inheritance diagram for xtd::drawing::font:
xtd::object xtd::iequatable< font > xtd::interface xtd::extensions::equality_operators< type_t, equatable_t >

Definition

Defines a particular format for text, including font face, size, and style attributes. This class cannot be inherited.

class drawing_export_ font final : public xtd::object
Defines a particular format for text, including font face, size, and style attributes....
Definition font.hpp:45
Supports all classes in the xtd class hierarchy and provides low-level services to derived classes....
Definition object.hpp:42
#define drawing_export_
Define shared library export.
Definition drawing_export.hpp:13
Inheritance
xtd::objectxtd::drawing::font
Namespace
xtd::drawing
Library
xtd.drawing
Examples
button_renderer.cpp, calculator.cpp, check_box_renderer.cpp, font.cpp, font_box.cpp, form_paint.cpp, forms_timer.cpp, graphics.cpp, hello_world_emoticons.cpp, minesweeper.cpp, owner_button.cpp, radio_button.cpp, radio_button_renderer.cpp, test_forms.cpp, user_control.cpp, wiggly.cpp, and wnd_proc.cpp.

Public Constructors

 font (const font &prototype, float em_size)
 IInitializes a new Font that uses the specified existing xtd::drawing::font and size.
 
 font (const font &prototype, float em_size, font_style style)
 IInitializes a new Font that uses the specified existing xtd::drawing::font, size and font_style enumeration.
 
 font (const font &prototype, font_style style)
 IInitializes a new Font that uses the specified existing xtd::drawing::font and font_style enumeration.
 
 font (xtd::string family_name, float em_size, font_style style, graphics_unit unit, xtd::byte gdi_char_set, bool gdi_vertical_font)
 IInitializes a new xtd::drawing::font using the specified size, style, unit, and character set.
 
 font (const drawing::font_family &font_family, float em_size, font_style style, graphics_unit unit, xtd::byte gdi_char_set, bool gdi_vertical_font)
 Initializes a new xtd::drawing::font using the specified size, style, unit, and character set.
 
 font (xtd::string family_name, float em_size, font_style style, graphics_unit unit, xtd::byte gdi_char_set)
 Initializes a new xtd::drawing::font using the specified size, style, unit, and character set.
 
 font (const drawing::font_family &font_family, float em_size, font_style style, graphics_unit unit, xtd::byte gdi_char_set)
 Initializes a new xtd::drawing::font using the specified size, style, unit, and character set.
 
 font (xtd::string family_name, float em_size, font_style style, graphics_unit unit)
 Initializes a new xtd::drawing::font using the specified size, style and unit.
 
 font (const drawing::font_family &font_family, float em_size, font_style style, graphics_unit unit)
 Initializes a new xtd::drawing::font using the specified size, style and unit.
 
 font (xtd::string family_name, float em_size, font_style style)
 Initializes a new xtd::drawing::font using the specified size and style.
 
 font (const drawing::font_family &font_family, float em_size, font_style style)
 Initializes a new xtd::drawing::font using the specified size and style.
 
 font (xtd::string family_name, float em_size, graphics_unit unit)
 Initializes a new xtd::drawing::font using the specified size and unit.
 
 font (const drawing::font_family &font_family, float em_size, graphics_unit unit)
 Initializes a new xtd::drawing::font using the specified size and unit.
 
 font (xtd::string family_name, float em_size)
 Initializes a new xtd::drawing::font using the specified size and unit.
 
 font (const drawing::font_family &font_family, float em_size)
 Initializes a new xtd::drawing::font using the specified size.
 

Public Properties

bool bold () const noexcept
 Gets a value that indicates whether this xtd::drawing::font is bold.
 
drawing::font_family font_family () const noexcept
 Gets the xtd::drawing::font_family associated with this xtd::drawing::font.
 
xtd::byte gdi_char_set () const noexcept
 Gets a byte value that specifies the GDI character set that this xtd::drawing::font uses.
 
bool gdi_vertical_font () const noexcept
 Gets a Boolean value that indicates whether this xtd::drawing::font is derived from a GDI vertical font.
 
intptr handle () const noexcept
 Gets the window handle that the font is bound to.
 
int32 height () const noexcept
 Gets the line spacing of this font.
 
bool is_system_font () const noexcept
 Gets a value indicating whether the font is a member of xtd::drawing::system_fonts.
 
bool italic () const noexcept
 Gets a value that indicates whether this xtd::drawing::font is italic.
 
const xtd::stringname () const noexcept
 Gets the face name of this xtd::drawing::font.
 
const xtd::stringoriginal_font_name () const noexcept
 Gets the face name of this Font.
 
float size () const noexcept
 Gets the em-size of this xtd::drawing::font measured in the units specified by the unit property.
 
float size_in_points () const noexcept
 Gets the em-size, in points, of this xtd::drawing::font.
 
bool strikeout () const noexcept
 Gets a value that indicates whether this xtd::drawing::font is strikeout.
 
font_style style () const noexcept
 Gets style information for this xtd::drawing::font.
 
bool underline () const noexcept
 Gets a value that indicates whether this xtd::drawing::font is underline.
 
graphics_unit unit () const noexcept
 Gets the unit of measure for this xtd::drawing::font.
 

Public Methods

bool equals (const font &value) const noexcept override
 
float get_height () const
 Returns the line spacing, in pixels, of this font.
 
float get_height (const graphics &graphics) const
 Returns the line spacing, in the current unit of a specified xtd::drawing::graphics, of this font.
 
float get_height (float dpi) const
 Returns the height, in pixels, of this Font when drawn to a device with the specified vertical resolution.
 
intptr to_hfont () const
 
xtd::string to_string () const noexcept override
 Converts this font_family to a human-readable string representation.
 
virtual bool equals (const object &obj) const noexcept
 Determines whether the specified object is equal to the current object.
 
template<typename object_a_t , typename object_b_t >
static bool equals (const object_a_t &object_a, const object_b_t &object_b) noexcept
 Determines whether the specified object instances are considered equal.
 

Public Static Methods

static font from_hdc (const intptr hdc)
 Creates a font from the specified Windows handle to a device context.
 
static font from_hfont (const intptr hfont)
 Creates a font from the specified Windows handle.
 

Additional Inherited Members

- Public Member Functions inherited from xtd::object
 object ()=default
 Create a new instance of the ultimate base class object.
 
virtual size_t get_hash_code () const noexcept
 Serves as a hash function for a particular type.
 
virtual type_object get_type () const noexcept
 Gets the type of the current instance.
 
template<typename object_t >
xtd::uptr< object_t > memberwise_clone () const
 Creates a shallow copy of the current object.
 
- Public Member Functions inherited from xtd::iequatable< font >
virtual bool equals (const font &) const noexcept=0
 Indicates whether the current object is equal to another object of the same type.
 
- Static Public Member Functions inherited from xtd::object
template<typename object_a_t , typename object_b_t >
static bool equals (const object_a_t &object_a, const object_b_t &object_b) noexcept
 Determines whether the specified object instances are considered equal.
 
template<typename object_a_t , typename object_b_t >
static bool reference_equals (const object_a_t &object_a, const object_b_t &object_b) noexcept
 Determines whether the specified object instances are the same instance.
 

Constructor & Destructor Documentation

◆ font() [1/15]

xtd::drawing::font::font ( const font prototype,
float  em_size 
)

IInitializes a new Font that uses the specified existing xtd::drawing::font and size.

Parameters
prototypeThe existing xtd::drawing::font from which to create the new xtd::drawing::font.
em_sizeThe em-size of the new font in the units specified by the unit parameter.

◆ font() [2/15]

xtd::drawing::font::font ( const font prototype,
float  em_size,
font_style  style 
)

IInitializes a new Font that uses the specified existing xtd::drawing::font, size and font_style enumeration.

Parameters
prototypeThe existing xtd::drawing::font from which to create the new xtd::drawing::font.
em_sizeThe em-size of the new font in the units specified by the unit parameter.
styleThe font_style to apply to the new xtd::drawing::font. Multiple values of the font_style enumeration can be combined with the OR operator.

◆ font() [3/15]

xtd::drawing::font::font ( const font prototype,
font_style  style 
)

IInitializes a new Font that uses the specified existing xtd::drawing::font and font_style enumeration.

Parameters
prototypeThe existing xtd::drawing::font from which to create the new xtd::drawing::font.
styleThe font_style to apply to the new xtd::drawing::font. Multiple values of the font_style enumeration can be combined with the OR operator.

◆ font() [4/15]

xtd::drawing::font::font ( xtd::string  family_name,
float  em_size,
font_style  style,
graphics_unit  unit,
xtd::byte  gdi_char_set,
bool  gdi_vertical_font 
)

IInitializes a new xtd::drawing::font using the specified size, style, unit, and character set.

Parameters
family_nameA string representation of the font_family for the new xtd::drawing::font.
em_sizeThe em-size of the new font in the units specified by the unit parameter.
styleThe font_style of the new xtd::drawing::font.
unitThe graphics_unit of the new xtd::drawing::font.
gdi_char_setA byte that specifies a GDI character set to use for this font.
gdi_vertical_fontA boolean value indicating whether the new xtd::drawing::font is derived from a GDI vertical font.
Exceptions
std::invalid_paramemSize is less than or equal to 0, evaluates to infinity, or is not a valid number.
Remarks
The gdiCharSet parameter takes a value from the list defined in the Windows SDK header file WinGDI.h. If the familyName parameter specifies a font that is not installed on the machine running the application or is not supported, Microsoft Sans Serif will be substituted.

◆ font() [5/15]

xtd::drawing::font::font ( const drawing::font_family font_family,
float  em_size,
font_style  style,
graphics_unit  unit,
xtd::byte  gdi_char_set,
bool  gdi_vertical_font 
)

Initializes a new xtd::drawing::font using the specified size, style, unit, and character set.

Parameters
font_familyThe font_family of the new Font.
em_sizeThe em-size of the new font in the units specified by the unit parameter.
styleThe font_style of the new xtd::drawing::font.
unitThe graphics_unit of the new xtd::drawing::font.
gdi_char_setA byte that specifies a GDI character set to use for this font.
gdi_vertical_fontA boolean value indicating whether the new xtd::drawing::font is derived from a GDI vertical font.
Exceptions
std::invalid_paramemSize is less than or equal to 0, evaluates to infinity, or is not a valid number.
Remarks
The gdiCharSet parameter takes a value from the list defined in the Windows SDK header file WinGDI.h. If the familyName parameter specifies a font that is not installed on the machine running the application or is not supported, Microsoft Sans Serif will be substituted.

◆ font() [6/15]

xtd::drawing::font::font ( xtd::string  family_name,
float  em_size,
font_style  style,
graphics_unit  unit,
xtd::byte  gdi_char_set 
)

Initializes a new xtd::drawing::font using the specified size, style, unit, and character set.

Parameters
family_nameA string representation of the font_family for the new xtd::drawing::font.
em_sizeThe em-size of the new font in the units specified by the unit parameter.
styleThe font_style of the new xtd::drawing::font.
unitThe graphics_unit of the new xtd::drawing::font.
gdi_char_setA byte that specifies a GDI character set to use for this font.
Exceptions
std::invalid_paramemSize is less than or equal to 0, evaluates to infinity, or is not a valid number.
Remarks
The gdiCharSet parameter takes a value from the list defined in the Windows SDK header file WinGDI.h. If the familyName parameter specifies a font that is not installed on the machine running the application or is not supported, Microsoft Sans Serif will be substituted.

◆ font() [7/15]

xtd::drawing::font::font ( const drawing::font_family font_family,
float  em_size,
font_style  style,
graphics_unit  unit,
xtd::byte  gdi_char_set 
)

Initializes a new xtd::drawing::font using the specified size, style, unit, and character set.

Parameters
font_familyThe font_family of the new Font.
em_sizeThe em-size of the new font in the units specified by the unit parameter.
styleThe font_style of the new xtd::drawing::font.
unitThe graphics_unit of the new xtd::drawing::font.
gdi_char_setA byte that specifies a GDI character set to use for this font.
Exceptions
std::invalid_paramemSize is less than or equal to 0, evaluates to infinity, or is not a valid number.
Remarks
The gdiCharSet parameter takes a value from the list defined in the Windows SDK header file WinGDI.h. If the familyName parameter specifies a font that is not installed on the machine running the application or is not supported, Microsoft Sans Serif will be substituted.

◆ font() [8/15]

xtd::drawing::font::font ( xtd::string  family_name,
float  em_size,
font_style  style,
graphics_unit  unit 
)

Initializes a new xtd::drawing::font using the specified size, style and unit.

Parameters
family_nameA string representation of the font_family for the new xtd::drawing::font.
em_sizeThe em-size of the new font in the units specified by the unit parameter.
styleThe font_style of the new xtd::drawing::font.
unitThe graphics_unit of the new xtd::drawing::font.
Exceptions
std::invalid_paramemSize is less than or equal to 0, evaluates to infinity, or is not a valid number.

◆ font() [9/15]

xtd::drawing::font::font ( const drawing::font_family font_family,
float  em_size,
font_style  style,
graphics_unit  unit 
)

Initializes a new xtd::drawing::font using the specified size, style and unit.

Parameters
font_familyThe font_family of the new Font.
em_sizeThe em-size of the new font in the units specified by the unit parameter.
styleThe font_style of the new xtd::drawing::font.
unitThe graphics_unit of the new xtd::drawing::font.
Exceptions
std::invalid_paramemSize is less than or equal to 0, evaluates to infinity, or is not a valid number.

◆ font() [10/15]

xtd::drawing::font::font ( xtd::string  family_name,
float  em_size,
font_style  style 
)

Initializes a new xtd::drawing::font using the specified size and style.

Parameters
family_nameA string representation of the font_family for the new xtd::drawing::font.
em_sizeThe em-size of the new font in the units specified by the unit parameter.
styleThe font_style of the new xtd::drawing::font.
Exceptions
std::invalid_paramemSize is less than or equal to 0, evaluates to infinity, or is not a valid number.

◆ font() [11/15]

xtd::drawing::font::font ( const drawing::font_family font_family,
float  em_size,
font_style  style 
)

Initializes a new xtd::drawing::font using the specified size and style.

Parameters
font_familyThe font_family of the new Font.
em_sizeThe em-size of the new font in the units specified by the unit parameter.
styleThe font_style of the new xtd::drawing::font.
Exceptions
std::invalid_paramemSize is less than or equal to 0, evaluates to infinity, or is not a valid number.

◆ font() [12/15]

xtd::drawing::font::font ( xtd::string  family_name,
float  em_size,
graphics_unit  unit 
)

Initializes a new xtd::drawing::font using the specified size and unit.

Parameters
family_nameA string representation of the font_family for the new xtd::drawing::font.
em_sizeThe em-size of the new font in the units specified by the unit parameter.
unitThe graphics_unit of the new xtd::drawing::font.
Exceptions
std::invalid_paramemSize is less than or equal to 0, evaluates to infinity, or is not a valid number.

◆ font() [13/15]

xtd::drawing::font::font ( const drawing::font_family font_family,
float  em_size,
graphics_unit  unit 
)

Initializes a new xtd::drawing::font using the specified size and unit.

Parameters
font_familyThe font_family of the new Font.
em_sizeThe em-size of the new font in the units specified by the unit parameter.
unitThe graphics_unit of the new xtd::drawing::font.
Exceptions
std::invalid_paramemSize is less than or equal to 0, evaluates to infinity, or is not a valid number.

◆ font() [14/15]

xtd::drawing::font::font ( xtd::string  family_name,
float  em_size 
)

Initializes a new xtd::drawing::font using the specified size and unit.

Parameters
family_nameA string representation of the font_family for the new xtd::drawing::font.
em_sizeThe em-size of the new font in the units specified by the unit parameter.
Exceptions
std::invalid_paramemSize is less than or equal to 0, evaluates to infinity, or is not a valid number.

◆ font() [15/15]

xtd::drawing::font::font ( const drawing::font_family font_family,
float  em_size 
)

Initializes a new xtd::drawing::font using the specified size.

Parameters
font_familyThe font_family of the new Font.
em_sizeThe em-size of the new font in the units specified by the unit parameter.
Exceptions
std::invalid_paramemSize is less than or equal to 0, evaluates to infinity, or is not a valid number.

Member Function Documentation

◆ bold()

bool xtd::drawing::font::bold ( ) const
noexcept

Gets a value that indicates whether this xtd::drawing::font is bold.

Returns
true if this xtd::drawing::font is bold; otherwise, false.

◆ font_family()

drawing::font_family xtd::drawing::font::font_family ( ) const
noexcept

Gets the xtd::drawing::font_family associated with this xtd::drawing::font.

Returns
The font_family associated with this Font.
Remarks
A font_family represents a group of fonts that have a similar font face, but may have different sizes and styles (for example, Arial, Times New Roman, and Verdana).
Examples
wnd_proc.cpp.

◆ gdi_char_set()

xtd::byte xtd::drawing::font::gdi_char_set ( ) const
noexcept

Gets a byte value that specifies the GDI character set that this xtd::drawing::font uses.

Returns
A byte value that specifies the GDI character set that this xtd::drawing::font uses. The default is 1.
Remarks
This property returns 1, unless a different character set is specified in the font(string, float, font_style, graphics_unit, xtd::byte) constructor. This property takes a value from the list defined in the Windows SDK header file WinGDI.h. The character sets and byte values are listed in the following table.
 Character set  Value
ANSI 0
DEFAULT 1
SYMBOL  2
SHIFTJIS 128
HANGEUL 129
HANGUL 129
GB2312 134
CHINESEBIG5 136
OEM  255
JOHAB  130
HEBREW 177
ARABIC  178
GREEK  161
TURKISH 162
VIETNAMESE 163
THAI  222
EASTEUROPE  238
RUSSIAN  204
MAC 77
BALTIC  186

◆ gdi_vertical_font()

bool xtd::drawing::font::gdi_vertical_font ( ) const
noexcept

Gets a Boolean value that indicates whether this xtd::drawing::font is derived from a GDI vertical font.

Returns
true if this xtd::drawing::font is derived from a GDI vertical font; otherwise, false.
Remarks
Use this property to determine if a font is compatible with native Win32 controls on non-Unicode platforms.
gdi_vertical_font only returns true if this font was created from a classic GDI font definition, like a LOGFONT or HFONT.

◆ handle()

intptr xtd::drawing::font::handle ( ) const
noexcept

Gets the window handle that the font is bound to.

Returns
An intptr that contains the window handle (hfont) of the font.

◆ height()

int32 xtd::drawing::font::height ( ) const
noexcept

Gets the line spacing of this font.

Returns
The line spacing, in pixels, of this font.
Remarks
The line spacing is the vertical distance between the base lines of two consecutive lines of text. Thus, the line spacing includes the blank space between lines along with the height of the character itself.
If the unit property of the font is set to anything other than graphics_unit::pixel, the height (in pixels) is calculated using the vertical resolution of the screen display. For example, suppose the font unit is inches and the font size is 0.3. Also suppose that for the corresponding font family, the em-height is 2048 and the line spacing is 2355. For a screen display that has a vertical resolution of 96 dots per inch, you can calculate the height as follows:
2355*(0.3/2048)*96 = 33.11719
The value returned by the get_height method would be 33.11719, and the value returned by the height property would be 34. The height property is the value returned by get_height, rounded up to the nearest integer.
Examples
graphics.cpp.

◆ is_system_font()

bool xtd::drawing::font::is_system_font ( ) const
noexcept

Gets a value indicating whether the font is a member of xtd::drawing::system_fonts.

Returns
true if the font is a member of xtd::drawing::system_fonts; otherwise, false. The default is false.
Remarks
When the user changes the system font, the is_system_font property could return true, even if the font is not actually a system font.

◆ italic()

bool xtd::drawing::font::italic ( ) const
noexcept

Gets a value that indicates whether this xtd::drawing::font is italic.

Returns
true if this xtd::drawing::font is italic; otherwise, false.

◆ name()

const xtd::string & xtd::drawing::font::name ( ) const
noexcept

Gets the face name of this xtd::drawing::font.

Returns
A string representation of the face name of this xtd::drawing::font.

◆ original_font_name()

const xtd::string & xtd::drawing::font::original_font_name ( ) const
noexcept

Gets the face name of this Font.

Returns
A string representation of the face name of this Font.

◆ size()

float xtd::drawing::font::size ( ) const
noexcept

Gets the em-size of this xtd::drawing::font measured in the units specified by the unit property.

Returns
The em-size of this xtd::drawing::font.
Examples
wiggly.cpp.

◆ size_in_points()

float xtd::drawing::font::size_in_points ( ) const
noexcept

Gets the em-size, in points, of this xtd::drawing::font.

Returns
The em-size, in points, of this xtd::drawing::font.

◆ strikeout()

bool xtd::drawing::font::strikeout ( ) const
noexcept

Gets a value that indicates whether this xtd::drawing::font is strikeout.

Returns
true if this xtd::drawing::font is strikeout; otherwise, false.

◆ style()

font_style xtd::drawing::font::style ( ) const
noexcept

Gets style information for this xtd::drawing::font.

Returns
A font_style enumeration that contains style information for this xtd::drawing::font.

◆ underline()

bool xtd::drawing::font::underline ( ) const
noexcept

Gets a value that indicates whether this xtd::drawing::font is underline.

Returns
true if this xtd::drawing::font is underline; otherwise, false.

◆ unit()

graphics_unit xtd::drawing::font::unit ( ) const
noexcept

Gets the unit of measure for this xtd::drawing::font.

Returns
A graphics_unit that represents the unit of measure for this xtd::drawing::font.

◆ get_height() [1/3]

float xtd::drawing::font::get_height ( ) const

Returns the line spacing, in pixels, of this font.

Returns
The line spacing, in pixels, of this font.
Remarks
The line spacing of a xtd::drawing::font is the vertical distance between the base lines of two consecutive lines of text. Thus, the line spacing includes the blank space between lines along with the height of the character itself.
If the unit property of the font is set to anything other than graphics_unit::pixel, the height (in pixels) is calculated using the vertical resolution of the screen display. For example, suppose the font unit is inches and the font size is 0.3. Also suppose that for the corresponding font family, the em-height is 2048 and the line spacing is 2355. For a screen display that has a vertical resolution of 96 dots per inch, you can calculate the height as follows:
2355*(0.3/2048)*96 = 33.11719

◆ get_height() [2/3]

float xtd::drawing::font::get_height ( const graphics graphics) const

Returns the line spacing, in the current unit of a specified xtd::drawing::graphics, of this font.

Parameters
graphicsA xtd::drawing::graphics that holds the vertical resolution, in dots per inch, of the display device as well as settings for page unit and page scale.
Returns
The line spacing, in pixels, of this font.
Remarks
The line spacing of a xtd::drawing::font is the vertical distance between the base lines of two consecutive lines of text. Thus, the line spacing includes the blank space between lines along with the height of the character itself.
If the unit property of the font is set to anything other than graphics_unit::pixel, the height (in pixels) is calculated using the vertical resolution of the screen display. For example, suppose the font unit is inches and the font size is 0.3. Also suppose that for the corresponding font family, the em-height is 2048 and the line spacing is 2355. For a screen display that has a vertical resolution of 96 dots per inch, you can calculate the height as follows:
2355*(0.3/2048)*96 = 33.11719

◆ get_height() [3/3]

float xtd::drawing::font::get_height ( float  dpi) const

Returns the height, in pixels, of this Font when drawn to a device with the specified vertical resolution.

Parameters
dpiThe vertical resolution, in dots per inch, used to calculate the height of the font.
Returns
The height, in pixels, of this xtd::drawing::font.
Remarks
If the unit property of the font is set to anything other than graphics_unit::pixel, the height (in pixels) is calculated using the vertical resolution of the screen display. For example, suppose the font unit is inches and the font size is 0.3. Also suppose that for the corresponding font family, the em-height is 2048 and the line spacing is 2355. If the specified vertical resolution is 96 dots per inch, the height is calculated as follows:
2355*(0.3/2048)*96 = 33.1171875

◆ to_hfont()

intptr xtd::drawing::font::to_hfont ( ) const
Returns
Returns a handle to this xtd::drawing::font.
A Windows handle to this xtd::drawing::font.
Remarks
When using this method, you must dispose of the resulting Hfont using the GDI DeleteObject method to ensure the resources are released.

◆ to_string()

xtd::string xtd::drawing::font::to_string ( ) const
overridevirtualnoexcept

Converts this font_family to a human-readable string representation.

Returns
The string that represents this font_family.

Reimplemented from xtd::object.

◆ from_hdc()

static font xtd::drawing::font::from_hdc ( const intptr  hdc)
static

Creates a font from the specified Windows handle to a device context.

Parameters
hdcA handle to a device context.
Returns
The font this method creates.

◆ from_hfont()

static font xtd::drawing::font::from_hfont ( const intptr  hfont)
static

Creates a font from the specified Windows handle.

Parameters
hfontA Windows handle to a GDI font.
Returns
The font this method creates.

◆ equals() [1/2]

virtual bool xtd::object::equals ( const object obj) const
virtualnoexcept

Determines whether the specified object is equal to the current object.

Parameters
objThe object to compare with the current object.
Returns
true if the specified object is equal to the current object. otherwise, false.
Examples
The following code example compares the current instance with another object.
#include <xtd/console>
using namespace xtd;
auto main() -> int {
auto object1 = new_ptr<object>();
auto object2 = new_ptr<object>();
auto object3 = object2;
console::write_line(object1->equals(*object3));
console::write_line(*object1 == *object3);
object3 = object1;
console::write_line(object1->equals(*object3));
console::write_line(*object1 == *object3);
}
// This code produces the following output :
//
// false
// false
// true
// true
static void write_line()
Writes the current line terminator to the standard output stream using the specified format informati...
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition xtd_about_box.hpp:10

Reimplemented from xtd::object.

◆ equals() [2/2]

template<typename object_a_t , typename object_b_t >
static bool xtd::object::equals ( const object_a_t &  object_a,
const object_b_t &  object_b 
)
inlinestaticnoexcept

Determines whether the specified object instances are considered equal.

Parameters
object_aThe first object to compare.
object_bThe second object to compare.
Returns
true if object_a is the same instance as object_b or if both are null references or if object_a(object_b) returns true. otherwise, false.
Examples
The following code example compares different objects.
#include <xtd/console>
using namespace xtd;
auto main() -> int {
string s1 = "Tom";
string s2 = "Carol";
console::write_line("object::equals(\"{0}\", \"{1}\") => {2}", s1, s2, object::equals(s1, s2));
s1 = "Tom";
s2 = "Tom";
console::write_line("object::equals(\"{0}\", \"{1}\") => {2}", s1, s2, object::equals(s1, s2));
s1 = "";
s2 = "Tom";
console::write_line("object::equals(\"{0}\", \"{1}\") => {2}", s1, s2, object::equals(s1, s2));
s1 = "Carol";
s2 = "";
console::write_line("object::equals(\"{0}\", \"{1}\") => {2}", s1, s2, object::equals(s1, s2));
s1 = "";
s2 = "";
console::write_line("object::equals(\"{0}\", \"{1}\") => {2}", s1, s2, object::equals(s1, s2));
}
// This code produces the following output :
//
// object::equals("Tom", "Carol") => false
// object::equals("Tom", "Tom") => true
// object::equals("", "Tom") => false
// object::equals("Carol", "") => false
// object::equals("", "") => true
virtual bool equals(const object &obj) const noexcept
Determines whether the specified object is equal to the current object.

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