Class Font
Defines a particular format for text, including font face, size, and style attributes. This class cannot be inherited.
public class Font : HostedDisposableObject, IBaseObjectWithAttr, IBaseObjectWithId, INotifyPropertyChanged, IDisposableObject, IDisposable, IBaseObject, IEquatable<Font>
- Inheritance
-
Font
- Implements
- Extension Methods
Constructors
- Font(Font, FontStyle)
Initializes a new Font that uses the specified existing Font and FontStyle enumeration.
- Font(Font, float)
Initializes a new Font that uses the specified existing Font and
newSizeparameter.
- Font(FontFamily, float)
Initializes a new Font using a specified size.
- Font(FontFamily, float, FontStyle)
Initializes a new Font using a specified font family, size in points and style.
- Font(FontFamily, float, FontStyle, GraphicsUnit)
Initializes a new Font using a specified size, style, and unit.
- Font(FontFamily, float, FontStyle, GraphicsUnit, byte)
Initializes a new Font using a specified size, style, unit, and character set.
- Font(FontFamily, float, FontStyle, GraphicsUnit, byte, bool)
Initializes a new Font using a specified size, style, unit, and character set.
- Font(FontFamily, float, GraphicsUnit)
Initializes a new Font using a specified size and unit. Sets the style to Regular.
- Font(string, float)
Initializes a new Font using a specified size.
- Font(string, float, FontStyle)
Initializes a new Font using a specified font family name, size in points and style.
- Font(string, float, FontStyle, GraphicsUnit)
Initializes a new Font using a specified size, style, and unit.
- Font(string, float, FontStyle, GraphicsUnit, byte)
Initializes a new Font using a specified size, style, unit, and character set.
- Font(string, float, FontStyle, GraphicsUnit, byte, bool)
Initializes a new Font using the specified size, style, unit, and character set.
- Font(string, float, GraphicsUnit)
Initializes a new Font using a specified size and unit. The style is set to Regular.
Fields
- FontSettingsIteration
Gets font system iteration count. It is used to detect when system font settings are changed.
- SkiaFontScaleFactor
Gets or sets native font scale factor for Skia. It is used when conveting Font size to SKFont size. On WxWidgets platform it is initialized when application is started.
- SmallerLargerSizeScaleFactor
Gets or sets default font size scaling factor for Smaller() and Larger() methods.
Properties
- AsBold
Returns bold version of the font.
- AsUnderlined
Returns underlined version of the font.
- Default
Gets the default font used in the application.
- DefaultFontName
Gets default font name for the platform.
- DefaultMono
Gets the default fixed width font used in the application.
- DefaultMonoFontName
Gets default monospace font name for the platform.
- DisplayName
Gets or sets display font name. This is the name of the font as it is displayed in the font name pickers. It may be different from the actual font name. Value of this property can be a string or a Func<TResult>.
- FontFamily
Gets the FontFamily associated with this Font.
- FontOrigin
Gets the font origin kind. This property can be used to determine whether it is a default font, system font, or a custom font.
- GdiCharSet
Gets a byte value that specifies the character set that this Font uses.
- GdiVerticalFont
Gets a bool value that indicates whether this Font is derived from a vertical font.
- GenericFamily
Gets GenericFontFamily for this font.
- IsDefaultFont
Gets a value indicating whether this font is a default font.
- IsDefaultMonoFont
Gets a value indicating whether this font is a default monospaced font.
- IsFixedWidth
Gets whether this font is a fixed width (or monospaced) font.
- IsStrikeout
Same as IsStrikethrough.
- IsStrikethrough
Gets a value that indicates whether this Font specifies a horizontal line through the font.
- IsUnderlined
Gets a value that indicates whether this Font is underlined.
- IsUsingSizeInPixels
Gets whether font size is in pixels.
- NumericWeight
Gets the font weight as an integer value.
- OriginalFontName
Gets the name of the font originally specified.
- SizeInDips
Gets the size in dips.
- SizeInPixels
Gets the pixel size.
- SizeInPoints
Gets the em-size, in points, of this Font.
- SkiaMetrics
Gets SKFontMetrics for this font.
- UniqueId
Gets unique id of this object.
- Weight
Gets the font weight.
Methods
- AreEqual(Font?, Font?)
Determines whether two Font objects are equal, handling null values.
- ChangeFontStyle(FontStyle, FontStyle, bool)
Turns on or off FontStyle element(s).
- CheckSize(float)
If font size is correct, returns it; otherwise returns default font size.
- CoerceFontParams(FontParams)
Adjusts the specified font parameters to ensure they conform to expected values.
- DisposeManaged()
Override to dispose managed resources. Here we dispose all used object references.
- Equals(Font?)
Indicates whether the current object is equal to another object of the same type.
- Equals(object?)
Determines whether the specified object is equal to the current object.
- Equals(string, float, FontStyle)
Indicates whether the current objects properties are equal to the specified properties.
- Get(string, float, FontStyle)
Creates font with the specified parameters.
- GetDefaultOrNew(string, float, FontStyle, Font?)
Creates new font or gets
defaultFontif its properties are equal to the specified.
- GetEffectiveFontDisplayName(Font?)
Gets the user-readable string representation of the specified font name. Uses DisplayName.
- GetFontStyleArraySize()
Gets size of the array with FontStyle as index.
- GetHashCode()
Serves as the default hash function.
- GetHeight(Graphics)
Calculates the height of the font when rendered in the specified graphics context. Uses the height of the characters "Wg" as a reference.
- GetIsBold(FontWeight)
Determines whether the specified font weight is considered bold.
- GetNumericWeightOf(FontWeight)
Helper function for converting FontWeight enum value to the numeric weight.
- GetSkiaWidthClosestToNumericValue(int)
Helper function for converting arbitrary numeric width to the closest value of SKFontStyleWidth enum.
- GetStyle(IFontHandler)
Determines the combined FontStyle based on the attributes of the specified font.
- GetWeightClosestToNumericValue(int)
Helper function for converting arbitrary numeric weight to the closest value of FontWeight enum.
- GetWidth(Graphics)
Calculates the width of the character "x" when rendered with the current font settings.
- IncSize(float)
Returns this font with same parameters, but with incremented size.
- IsClose(string, float, FontStyle)
Determines whether the current font matches the specified name, style, and size within a close tolerance.
- IsVerticalName(string?)
Gets whether font name is from vertical font (starts with @ char).
- Larger()
Returns a larger version of this font.
- ResetSkiaFont()
Resets the cached SKFont for this font instance.
- Scaled(float)
Returns a scaled version of this font.
- Serialize()
Gets a string representation of the font's attributes, including its name, size, and style.
- Smaller()
Returns a smaller version of this font.
- ToInfoString()
Returns a human-readable string representation of this Font.
- ToSkiaFontInfo()
Converts the current font settings to a SkiaFontInfo object.
- ToString()
Returns a string that represents the current object.
- ToUserAsList(IFontHandler)
Converts the specified font's attributes into a list of strings representing its user-readable properties.
- ToUserString(FontStyle, FontWeight)
Converts the specified font style and weight into a list of user-friendly string descriptions.
- ToUserString(FontWeight)
Converts the specified FontWeight value to its corresponding user-friendly string representation.
- ToUserString(GenericFontFamily)
Converts a GenericFontFamily value to its corresponding user-friendly string representation.
- ToUserString(IFontHandler)
Converts the specified font information to a user-friendly string representation.
- Unscaled(float)
Returns a unscaled version of this font.
- WithBold(bool)
Returns font with same parameters, but with different bold style.
- WithName(string)
Returns font with same parameters, but with different name.
- WithSize(float)
Returns this font with same parameters, but with different size.
- WithStyle(FontStyle)
Returns font with same name and size, but with different FontStyle.
Operators
- operator ==(Font?, Font?)
Returns a value that indicates whether the two objects are equal.
- implicit operator FontNameAndSize(Font)
Converts the specified Font to a FontNameAndSize.
- implicit operator Font(FontNameAndSize)
Converts the specified FontNameAndSize to a Font.
- operator !=(Font?, Font?)
Returns a value that indicates whether the two objects are not equal.