Struct qt_gui::QFont

source ·
#[repr(C)]
pub struct QFont { /* private fields */ }
Expand description

The QFont class specifies a font used for drawing text.

C++ class: QFont.

C++ documentation:

The QFont class specifies a font used for drawing text.

When you create a QFont object you specify various attributes that you want the font to have. Qt will use the font with the specified attributes, or if no matching font exists, Qt will use the closest matching installed font. The attributes of the font that is actually used are retrievable from a QFontInfo object. If the window system provides an exact match exactMatch() returns true. Use QFontMetrics to get measurements, e.g. the pixel length of a string using QFontMetrics::width().

Note that a QGuiApplication instance must exist before a QFont can be used. You can set the application's default font with QGuiApplication::setFont().

If a chosen font does not include all the characters that need to be displayed, QFont will try to find the characters in the nearest equivalent fonts. When a QPainter draws a character from a font the QFont will report whether or not it has the character; if it does not, QPainter will draw an unfilled square.

Create QFonts like this:

QFont serifFont(“Times”, 10, QFont::Bold); QFont sansFont(“Helvetica [Cronyx]”, 12);

The attributes set in the constructor can also be set later, e.g. setFamily(), setPointSize(), setPointSizeF(), setWeight() and setItalic(). The remaining attributes must be set after contstruction, e.g. setBold(), setUnderline(), setOverline(), setStrikeOut() and setFixedPitch(). QFontInfo objects should be created after the font's attributes have been set. A QFontInfo object will not change, even if you change the font's attributes. The corresponding "get" functions, e.g. family(), pointSize(), etc., return the values that were set, even though the values used may differ. The actual values are available from a QFontInfo object.

If the requested font family is unavailable you can influence the font matching algorithm by choosing a particular QFont::StyleHint and QFont::StyleStrategy with setStyleHint(). The default family (corresponding to the current style hint) is returned by defaultFamily().

The font-matching algorithm has a lastResortFamily() and lastResortFont() in cases where a suitable match cannot be found. You can provide substitutions for font family names using insertSubstitution() and insertSubstitutions(). Substitutions can be removed with removeSubstitutions(). Use substitute() to retrieve a family's first substitute, or the family name itself if it has no substitutes. Use substitutes() to retrieve a list of a family's substitutes (which may be empty).

Every QFont has a key() which you can use, for example, as the key in a cache or dictionary. If you want to store a user's font preferences you could use QSettings, writing the font information with toString() and reading it back with fromString(). The operator<<() and operator>>() functions are also available, but they work on a data stream.

It is possible to set the height of characters shown on the screen to a specified number of pixels with setPixelSize(); however using setPointSize() has a similar effect and provides device independence.

Loading fonts can be expensive, especially on X11. QFont contains extensive optimizations to make the copying of QFont objects fast, and to cache the results of the slow window system functions it depends upon.

The font matching algorithm works as follows:

  1. The specified font family is searched for.
  2. If not found, the styleHint() is used to select a replacement family.
  3. Each replacement font family is searched for.
  4. If none of these are found or there was no styleHint(), "helvetica" will be searched for.
  5. If "helvetica" isn't found Qt will try the lastResortFamily().
  6. If the lastResortFamily() isn't found Qt will try the lastResortFont() which will always return a name of some kind.

Note that the actual font matching algorithm varies from platform to platform.

In Windows a request for the "Courier" font is automatically changed to "Courier New", an improved version of Courier that allows for smooth scaling. The older "Courier" bitmap font can be selected by setting the PreferBitmap style strategy (see setStyleStrategy()).

Once a font is found, the remaining attributes are matched in order of priority:

  1. fixedPitch()
  2. pointSize() (see below)
  3. weight()
  4. style()

If you have a font which matches on family, even if none of the other attributes match, this font will be chosen in preference to a font which doesn't match on family but which does match on the other attributes. This is because font family is the dominant search criteria.

The point size is defined to match if it is within 20% of the requested point size. When several fonts match and are only distinguished by point size, the font with the closest point size to the one requested will be chosen.

The actual family, font size, weight and other font attributes used for drawing text will depend on what's available for the chosen family under the window system. A QFontInfo object can be used to determine the actual values used for drawing the text.

Examples:

QFont f(“Helvetica”);

If you had both an Adobe and a Cronyx Helvetica, you might get either.

QFont f(“Helvetica [Cronyx]”);

You can specify the foundry you want in the family name. The font f in the above example will be set to "Helvetica [Cronyx]".

To determine the attributes of the font actually used in the window system, use a QFontInfo object, e.g.

QFontInfo info(f1); QString family = info.family();

To find out font metrics use a QFontMetrics object, e.g.

QFontMetrics fm(f1); int textWidthInPixels = fm.width(“How many pixels wide is this text?”); int textHeightInPixels = fm.height();

For more general information on fonts, see the comp.fonts FAQ. Information on encodings can be found from Roman Czyborra's page.

Implementations§

source§

impl QFont

source

pub unsafe fn bold(&self) -> bool

Returns true if weight() is a value greater than QFont::Medium; otherwise returns false.

Calls C++ function: bool QFont::bold() const.

C++ documentation:

Returns true if weight() is a value greater than QFont::Medium; otherwise returns false.

See also weight(), setBold(), and QFontInfo::bold().

source

pub unsafe fn cache_statistics()

Calls C++ function: static void QFont::cacheStatistics().

source

pub unsafe fn capitalization(&self) -> Capitalization

Returns the current capitalization type of the font.

Calls C++ function: QFont::Capitalization QFont::capitalization() const.

C++ documentation:

Returns the current capitalization type of the font.

This function was introduced in Qt 4.4.

See also setCapitalization().

source

pub unsafe fn cleanup()

Calls C++ function: static void QFont::cleanup().

source

pub unsafe fn copy_from(&self, arg1: impl CastInto<Ref<QFont>>) -> Ref<QFont>

Assigns font to this font and returns a reference to it.

Calls C++ function: QFont& QFont::operator=(const QFont& arg1).

C++ documentation:

Assigns font to this font and returns a reference to it.

source

pub unsafe fn default_family(&self) -> CppBox<QString>

Returns the family name that corresponds to the current style hint.

Calls C++ function: QString QFont::defaultFamily() const.

C++ documentation:

Returns the family name that corresponds to the current style hint.

See also StyleHint, styleHint(), and setStyleHint().

source

pub unsafe fn exact_match(&self) -> bool

Returns true if a window system font exactly matching the settings of this font is available.

Calls C++ function: bool QFont::exactMatch() const.

C++ documentation:

Returns true if a window system font exactly matching the settings of this font is available.

See also QFontInfo.

source

pub unsafe fn families(&self) -> CppBox<QStringList>

Available on cpp_lib_version="5.13.0" or cpp_lib_version="5.14.0" only.

Returns the requested font family names, i.e. the names set in the last setFamilies() call or via the constructor. Otherwise it returns an empty list.

Calls C++ function: QStringList QFont::families() const.

C++ documentation:

Returns the requested font family names, i.e. the names set in the last setFamilies() call or via the constructor. Otherwise it returns an empty list.

This function was introduced in Qt 5.13.

See also setFamily(), setFamilies(), family(), substitutes(), and substitute().

source

pub unsafe fn family(&self) -> CppBox<QString>

Returns the requested font family name, i.e. the name set in the constructor or the last setFont() call.

Calls C++ function: QString QFont::family() const.

C++ documentation:

Returns the requested font family name, i.e. the name set in the constructor or the last setFont() call.

See also setFamily(), substitutes(), and substitute().

source

pub unsafe fn fixed_pitch(&self) -> bool

Returns true if fixed pitch has been set; otherwise returns false.

Calls C++ function: bool QFont::fixedPitch() const.

C++ documentation:

Returns true if fixed pitch has been set; otherwise returns false.

See also setFixedPitch() and QFontInfo::fixedPitch().

source

pub unsafe fn from_string(&self, arg1: impl CastInto<Ref<QString>>) -> bool

Sets this font to match the description descrip. The description is a comma-separated list of the font attributes, as returned by toString().

Calls C++ function: bool QFont::fromString(const QString& arg1).

C++ documentation:

Sets this font to match the description descrip. The description is a comma-separated list of the font attributes, as returned by toString().

See also toString().

source

pub unsafe fn hinting_preference(&self) -> HintingPreference

Returns the currently preferred hinting level for glyphs rendered with this font.

Calls C++ function: QFont::HintingPreference QFont::hintingPreference() const.

C++ documentation:

Returns the currently preferred hinting level for glyphs rendered with this font.

This function was introduced in Qt 4.8.

See also setHintingPreference().

source

pub unsafe fn initialize()

Calls C++ function: static void QFont::initialize().

source

pub unsafe fn insert_substitution( arg1: impl CastInto<Ref<QString>>, arg2: impl CastInto<Ref<QString>> )

Inserts substituteName into the substitution table for the family familyName.

Calls C++ function: static void QFont::insertSubstitution(const QString& arg1, const QString& arg2).

C++ documentation:

Inserts substituteName into the substitution table for the family familyName.

See also insertSubstitutions(), removeSubstitutions(), substitutions(), substitute(), and substitutes().

source

pub unsafe fn insert_substitutions( arg1: impl CastInto<Ref<QString>>, arg2: impl CastInto<Ref<QStringList>> )

Inserts the list of families substituteNames into the substitution list for familyName.

Calls C++ function: static void QFont::insertSubstitutions(const QString& arg1, const QStringList& arg2).

C++ documentation:

Inserts the list of families substituteNames into the substitution list for familyName.

See also insertSubstitution(), removeSubstitutions(), substitutions(), and substitute().

source

pub unsafe fn is_copy_of(&self, arg1: impl CastInto<Ref<QFont>>) -> bool

Returns true if this font and f are copies of each other, i.e. one of them was created as a copy of the other and neither has been modified since. This is much stricter than equality.

Calls C++ function: bool QFont::isCopyOf(const QFont& arg1) const.

C++ documentation:

Returns true if this font and f are copies of each other, i.e. one of them was created as a copy of the other and neither has been modified since. This is much stricter than equality.

See also operator=() and operator==().

source

pub unsafe fn italic(&self) -> bool

Returns true if the style() of the font is not QFont::StyleNormal

Calls C++ function: bool QFont::italic() const.

C++ documentation:

Returns true if the style() of the font is not QFont::StyleNormal

See also setItalic() and style().

source

pub unsafe fn kerning(&self) -> bool

Returns true if kerning should be used when drawing text with this font.

Calls C++ function: bool QFont::kerning() const.

C++ documentation:

Returns true if kerning should be used when drawing text with this font.

See also setKerning().

source

pub unsafe fn key(&self) -> CppBox<QString>

Returns the font's key, a textual representation of a font. It is typically used as the key for a cache or dictionary of fonts.

Calls C++ function: QString QFont::key() const.

C++ documentation:

Returns the font’s key, a textual representation of a font. It is typically used as the key for a cache or dictionary of fonts.

See also QMap.

source

pub unsafe fn last_resort_family(&self) -> CppBox<QString>

Returns the "last resort" font family name.

Calls C++ function: QString QFont::lastResortFamily() const.

C++ documentation:

Returns the “last resort” font family name.

The current implementation tries a wide variety of common fonts, returning the first one it finds. Is is possible that no family is found in which case an empty string is returned.

See also lastResortFont().

source

pub unsafe fn last_resort_font(&self) -> CppBox<QString>

Returns a "last resort" font name for the font matching algorithm. This is used if the last resort family is not available. It will always return a name, if necessary returning something like "fixed" or "system".

Calls C++ function: QString QFont::lastResortFont() const.

C++ documentation:

Returns a “last resort” font name for the font matching algorithm. This is used if the last resort family is not available. It will always return a name, if necessary returning something like “fixed” or “system”.

The current implementation tries a wide variety of common fonts, returning the first one it finds. The implementation may change at any time, but this function will always return a string containing something.

It is theoretically possible that there really isn't a lastResortFont() in which case Qt will abort with an error message. We have not been able to identify a case where this happens. Please report it as a bug if it does, preferably with a list of the fonts you have installed.

See also lastResortFamily().

source

pub unsafe fn letter_spacing(&self) -> c_double

Returns the letter spacing for the font.

Calls C++ function: double QFont::letterSpacing() const.

C++ documentation:

Returns the letter spacing for the font.

This function was introduced in Qt 4.4.

See also setLetterSpacing(), letterSpacingType(), and setWordSpacing().

source

pub unsafe fn letter_spacing_type(&self) -> SpacingType

Returns the spacing type used for letter spacing.

Calls C++ function: QFont::SpacingType QFont::letterSpacingType() const.

C++ documentation:

Returns the spacing type used for letter spacing.

This function was introduced in Qt 4.4.

See also letterSpacing(), setLetterSpacing(), and setWordSpacing().

source

pub unsafe fn new() -> CppBox<QFont>

Constructs a font object that uses the application's default font.

Calls C++ function: [constructor] void QFont::QFont().

C++ documentation:

Constructs a font object that uses the application’s default font.

See also QGuiApplication::setFont() and QGuiApplication::font().

source

pub unsafe fn from_q_string2_int_bool( family: impl CastInto<Ref<QString>>, point_size: c_int, weight: c_int, italic: bool ) -> CppBox<QFont>

Constructs a font object with the specified family, pointSize, weight and italic settings.

Calls C++ function: [constructor] void QFont::QFont(const QString& family, int pointSize = …, int weight = …, bool italic = …).

C++ documentation:

Constructs a font object with the specified family, pointSize, weight and italic settings.

If pointSize is zero or negative, the point size of the font is set to a system-dependent default value. Generally, this is 12 points.

The family name may optionally also include a foundry name, e.g. "Helvetica [Cronyx]". If the family is available from more than one foundry and the foundry isn't specified, an arbitrary foundry is chosen. If the family isn't available a family will be set using the font matching algorithm.

See also Weight, setFamily(), setPointSize(), setWeight(), setItalic(), setStyleHint(), and QGuiApplication::font().

source

pub unsafe fn from_q_font_q_paint_device( arg1: impl CastInto<Ref<QFont>>, pd: impl CastInto<Ptr<QPaintDevice>> ) -> CppBox<QFont>

Constructs a font from font for use on the paint device pd.

Calls C++ function: [constructor] void QFont::QFont(const QFont& arg1, QPaintDevice* pd).

C++ documentation:

Constructs a font from font for use on the paint device pd.

source

pub unsafe fn from_q_string2_int( family: impl CastInto<Ref<QString>>, point_size: c_int, weight: c_int ) -> CppBox<QFont>

Constructs a font object with the specified family, pointSize, weight and italic settings.

Calls C++ function: [constructor] void QFont::QFont(const QString& family, int pointSize = …, int weight = …).

C++ documentation:

Constructs a font object with the specified family, pointSize, weight and italic settings.

If pointSize is zero or negative, the point size of the font is set to a system-dependent default value. Generally, this is 12 points.

The family name may optionally also include a foundry name, e.g. "Helvetica [Cronyx]". If the family is available from more than one foundry and the foundry isn't specified, an arbitrary foundry is chosen. If the family isn't available a family will be set using the font matching algorithm.

See also Weight, setFamily(), setPointSize(), setWeight(), setItalic(), setStyleHint(), and QGuiApplication::font().

source

pub unsafe fn from_q_string_int( family: impl CastInto<Ref<QString>>, point_size: c_int ) -> CppBox<QFont>

Constructs a font object with the specified family, pointSize, weight and italic settings.

Calls C++ function: [constructor] void QFont::QFont(const QString& family, int pointSize = …).

C++ documentation:

Constructs a font object with the specified family, pointSize, weight and italic settings.

If pointSize is zero or negative, the point size of the font is set to a system-dependent default value. Generally, this is 12 points.

The family name may optionally also include a foundry name, e.g. "Helvetica [Cronyx]". If the family is available from more than one foundry and the foundry isn't specified, an arbitrary foundry is chosen. If the family isn't available a family will be set using the font matching algorithm.

See also Weight, setFamily(), setPointSize(), setWeight(), setItalic(), setStyleHint(), and QGuiApplication::font().

source

pub unsafe fn from_q_string( family: impl CastInto<Ref<QString>> ) -> CppBox<QFont>

Constructs a font object with the specified family, pointSize, weight and italic settings.

Calls C++ function: [constructor] void QFont::QFont(const QString& family).

C++ documentation:

Constructs a font object with the specified family, pointSize, weight and italic settings.

If pointSize is zero or negative, the point size of the font is set to a system-dependent default value. Generally, this is 12 points.

The family name may optionally also include a foundry name, e.g. "Helvetica [Cronyx]". If the family is available from more than one foundry and the foundry isn't specified, an arbitrary foundry is chosen. If the family isn't available a family will be set using the font matching algorithm.

See also Weight, setFamily(), setPointSize(), setWeight(), setItalic(), setStyleHint(), and QGuiApplication::font().

source

pub unsafe fn from_q_font_q_paint_device2( font: impl CastInto<Ref<QFont>>, pd: impl CastInto<Ptr<QPaintDevice>> ) -> CppBox<QFont>

Available on cpp_lib_version="5.13.0" or cpp_lib_version="5.14.0" only.

Constructs a font from font for use on the paint device pd.

Calls C++ function: [constructor] void QFont::QFont(const QFont& font, const QPaintDevice* pd).

C++ documentation:

Constructs a font from font for use on the paint device pd.

This function was introduced in Qt 5.13.

source

pub unsafe fn new_copy(arg1: impl CastInto<Ref<QFont>>) -> CppBox<QFont>

Constructs a font that is a copy of font.

Calls C++ function: [constructor] void QFont::QFont(const QFont& arg1).

C++ documentation:

Constructs a font that is a copy of font.

source

pub unsafe fn overline(&self) -> bool

Returns true if overline has been set; otherwise returns false.

Calls C++ function: bool QFont::overline() const.

C++ documentation:

Returns true if overline has been set; otherwise returns false.

See also setOverline().

source

pub unsafe fn pixel_size(&self) -> c_int

Returns the pixel size of the font if it was set with setPixelSize(). Returns -1 if the size was set with setPointSize() or setPointSizeF().

Calls C++ function: int QFont::pixelSize() const.

C++ documentation:

Returns the pixel size of the font if it was set with setPixelSize(). Returns -1 if the size was set with setPointSize() or setPointSizeF().

See also setPixelSize(), pointSize(), QFontInfo::pointSize(), and QFontInfo::pixelSize().

source

pub unsafe fn point_size(&self) -> c_int

Returns the point size of the font. Returns -1 if the font size was specified in pixels.

Calls C++ function: int QFont::pointSize() const.

C++ documentation:

Returns the point size of the font. Returns -1 if the font size was specified in pixels.

See also setPointSize() and pointSizeF().

source

pub unsafe fn point_size_f(&self) -> c_double

Returns the point size of the font. Returns -1 if the font size was specified in pixels.

Calls C++ function: double QFont::pointSizeF() const.

C++ documentation:

Returns the point size of the font. Returns -1 if the font size was specified in pixels.

See also pointSize(), setPointSizeF(), pixelSize(), QFontInfo::pointSize(), and QFontInfo::pixelSize().

source

pub unsafe fn raw_mode(&self) -> bool

Returns true if raw mode is used for font name matching; otherwise returns false.

Calls C++ function: bool QFont::rawMode() const.

C++ documentation:

Returns true if raw mode is used for font name matching; otherwise returns false.

See also setRawMode().

source

pub unsafe fn raw_name(&self) -> CppBox<QString>

Returns the name of the font within the underlying window system.

Calls C++ function: QString QFont::rawName() const.

C++ documentation:

Returns the name of the font within the underlying window system.

On X11, this function will return an empty string.

Using the return value of this function is usually not portable.

See also setRawName().

source

pub unsafe fn remove_substitutions(arg1: impl CastInto<Ref<QString>>)

Removes all the substitutions for familyName.

Calls C++ function: static void QFont::removeSubstitutions(const QString& arg1).

C++ documentation:

Removes all the substitutions for familyName.

This function was introduced in Qt 5.0.

See also insertSubstitutions(), insertSubstitution(), substitutions(), and substitute().

source

pub unsafe fn resolve_1a( &self, arg1: impl CastInto<Ref<QFont>> ) -> CppBox<QFont>

Returns a new QFont that has attributes copied from other that have not been previously set on this font.

Calls C++ function: QFont QFont::resolve(const QFont& arg1) const.

C++ documentation:

Returns a new QFont that has attributes copied from other that have not been previously set on this font.

source

pub unsafe fn resolve_0a(&self) -> c_uint

Returns a new QFont that has attributes copied from other that have not been previously set on this font.

Calls C++ function: unsigned int QFont::resolve() const.

Warning: no exact match found in C++ documentation. Below is the C++ documentation for QFont QFont::resolve(const QFont &other) const:

Returns a new QFont that has attributes copied from other that have not been previously set on this font.

source

pub unsafe fn resolve_1a_mut(&self, mask: c_uint)

Returns a new QFont that has attributes copied from other that have not been previously set on this font.

Calls C++ function: void QFont::resolve(unsigned int mask).

Warning: no exact match found in C++ documentation. Below is the C++ documentation for QFont QFont::resolve(const QFont &other) const:

Returns a new QFont that has attributes copied from other that have not been previously set on this font.

source

pub unsafe fn set_bold(&self, arg1: bool)

If enable is true sets the font's weight to QFont::Bold; otherwise sets the weight to QFont::Normal.

Calls C++ function: void QFont::setBold(bool arg1).

C++ documentation:

If enable is true sets the font’s weight to QFont::Bold; otherwise sets the weight to QFont::Normal.

For finer boldness control use setWeight().

Note: If styleName() is set, this value may be ignored, or if supported on the platform, the font artificially embolded.

See also bold() and setWeight().

source

pub unsafe fn set_capitalization(&self, arg1: Capitalization)

Sets the capitalization of the text in this font to caps.

Calls C++ function: void QFont::setCapitalization(QFont::Capitalization arg1).

C++ documentation:

Sets the capitalization of the text in this font to caps.

A font's capitalization makes the text appear in the selected capitalization mode.

This function was introduced in Qt 4.4.

See also capitalization().

source

pub unsafe fn set_families(&self, arg1: impl CastInto<Ref<QStringList>>)

Available on cpp_lib_version="5.13.0" or cpp_lib_version="5.14.0" only.

Sets the list of family names for the font. The names are case insensitive and may include a foundry name. The first family in families will be set as the main family for the font.

Calls C++ function: void QFont::setFamilies(const QStringList& arg1).

C++ documentation:

Sets the list of family names for the font. The names are case insensitive and may include a foundry name. The first family in families will be set as the main family for the font.

Each family name entry in families may optionally also include a foundry name, e.g. "Helvetica [Cronyx]". If the family is available from more than one foundry and the foundry isn't specified, an arbitrary foundry is chosen. If the family isn't available a family will be set using the font matching algorithm.

This function was introduced in Qt 5.13.

See also family(), families(), setFamily(), setStyleHint(), and QFontInfo.

source

pub unsafe fn set_family(&self, arg1: impl CastInto<Ref<QString>>)

Sets the family name of the font. The name is case insensitive and may include a foundry name.

Calls C++ function: void QFont::setFamily(const QString& arg1).

C++ documentation:

Sets the family name of the font. The name is case insensitive and may include a foundry name.

The family name may optionally also include a foundry name, e.g. "Helvetica [Cronyx]". If the family is available from more than one foundry and the foundry isn't specified, an arbitrary foundry is chosen. If the family isn't available a family will be set using the font matching algorithm.

See also family(), setStyleHint(), and QFontInfo.

source

pub unsafe fn set_fixed_pitch(&self, arg1: bool)

If enable is true, sets fixed pitch on; otherwise sets fixed pitch off.

Calls C++ function: void QFont::setFixedPitch(bool arg1).

C++ documentation:

If enable is true, sets fixed pitch on; otherwise sets fixed pitch off.

See also fixedPitch() and QFontInfo.

source

pub unsafe fn set_hinting_preference( &self, hinting_preference: HintingPreference )

Set the preference for the hinting level of the glyphs to hintingPreference. This is a hint to the underlying font rendering system to use a certain level of hinting, and has varying support across platforms. See the table in the documentation for QFont::HintingPreference for more details.

Calls C++ function: void QFont::setHintingPreference(QFont::HintingPreference hintingPreference).

C++ documentation:

Set the preference for the hinting level of the glyphs to hintingPreference. This is a hint to the underlying font rendering system to use a certain level of hinting, and has varying support across platforms. See the table in the documentation for QFont::HintingPreference for more details.

The default hinting preference is QFont::PreferDefaultHinting.

This function was introduced in Qt 4.8.

See also hintingPreference().

source

pub unsafe fn set_italic(&self, b: bool)

Sets the style() of the font to QFont::StyleItalic if enable is true; otherwise the style is set to QFont::StyleNormal.

Calls C++ function: void QFont::setItalic(bool b).

C++ documentation:

Sets the style() of the font to QFont::StyleItalic if enable is true; otherwise the style is set to QFont::StyleNormal.

Note: If styleName() is set, this value may be ignored, or if supported on the platform, the font may be rendered tilted instead of picking a designed italic font-variant.

See also italic() and QFontInfo.

source

pub unsafe fn set_kerning(&self, arg1: bool)

Enables kerning for this font if enable is true; otherwise disables it. By default, kerning is enabled.

Calls C++ function: void QFont::setKerning(bool arg1).

C++ documentation:

Enables kerning for this font if enable is true; otherwise disables it. By default, kerning is enabled.

When kerning is enabled, glyph metrics do not add up anymore, even for Latin text. In other words, the assumption that width('a') + width('b') is equal to width("ab") is not necessarily true.

See also kerning() and QFontMetrics.

source

pub unsafe fn set_letter_spacing(&self, type_: SpacingType, spacing: c_double)

Sets the letter spacing for the font to spacing and the type of spacing to type.

Calls C++ function: void QFont::setLetterSpacing(QFont::SpacingType type, double spacing).

C++ documentation:

Sets the letter spacing for the font to spacing and the type of spacing to type.

Letter spacing changes the default spacing between individual letters in the font. The spacing between the letters can be made smaller as well as larger either in percentage of the character width or in pixels, depending on the selected spacing type.

This function was introduced in Qt 4.4.

See also letterSpacing(), letterSpacingType(), and setWordSpacing().

source

pub unsafe fn set_overline(&self, arg1: bool)

If enable is true, sets overline on; otherwise sets overline off.

Calls C++ function: void QFont::setOverline(bool arg1).

C++ documentation:

If enable is true, sets overline on; otherwise sets overline off.

See also overline() and QFontInfo.

source

pub unsafe fn set_pixel_size(&self, arg1: c_int)

Sets the font size to pixelSize pixels.

Calls C++ function: void QFont::setPixelSize(int arg1).

C++ documentation:

Sets the font size to pixelSize pixels.

Using this function makes the font device dependent. Use setPointSize() or setPointSizeF() to set the size of the font in a device independent manner.

See also pixelSize().

source

pub unsafe fn set_point_size(&self, arg1: c_int)

Sets the point size to pointSize. The point size must be greater than zero.

Calls C++ function: void QFont::setPointSize(int arg1).

C++ documentation:

Sets the point size to pointSize. The point size must be greater than zero.

See also pointSize() and setPointSizeF().

source

pub unsafe fn set_point_size_f(&self, arg1: c_double)

Sets the point size to pointSize. The point size must be greater than zero. The requested precision may not be achieved on all platforms.

Calls C++ function: void QFont::setPointSizeF(double arg1).

C++ documentation:

Sets the point size to pointSize. The point size must be greater than zero. The requested precision may not be achieved on all platforms.

See also pointSizeF(), setPointSize(), and setPixelSize().

source

pub unsafe fn set_raw_mode(&self, arg1: bool)

If enable is true, turns raw mode on; otherwise turns raw mode off. This function only has an effect under X11.

Calls C++ function: void QFont::setRawMode(bool arg1).

C++ documentation:

If enable is true, turns raw mode on; otherwise turns raw mode off. This function only has an effect under X11.

If raw mode is enabled, Qt will search for an X font with a complete font name matching the family name, ignoring all other values set for the QFont. If the font name matches several fonts, Qt will use the first font returned by X. QFontInfo cannot be used to fetch information about a QFont using raw mode (it will return the values set in the QFont for all parameters, including the family name).

Warning: Enabling raw mode has no effect since Qt 5.0.

See also rawMode().

source

pub unsafe fn set_raw_name(&self, arg1: impl CastInto<Ref<QString>>)

Sets a font by its system specific name.

Calls C++ function: void QFont::setRawName(const QString& arg1).

C++ documentation:

Sets a font by its system specific name.

A font set with setRawName() is still a full-featured QFont. It can be queried (for example with italic()) or modified (for example with setItalic()) and is therefore also suitable for rendering rich text.

If Qt's internal font database cannot resolve the raw name, the font becomes a raw font with name as its family.

See also rawName() and setFamily().

source

pub unsafe fn set_stretch(&self, arg1: c_int)

Sets the stretch factor for the font.

Calls C++ function: void QFont::setStretch(int arg1).

C++ documentation:

Sets the stretch factor for the font.

The stretch factor matches a condensed or expanded version of the font or applies a stretch transform that changes the width of all characters in the font by factor percent. For example, setting factor to 150 results in all characters in the font being 1.5 times (ie. 150%) wider. The minimum stretch factor is 1, and the maximum stretch factor is 4000. The default stretch factor is AnyStretch, which will accept any stretch factor and not apply any transform on the font.

The stretch factor is only applied to outline fonts. The stretch factor is ignored for bitmap fonts.

Note: When matching a font with a native non-default stretch factor, requesting a stretch of 100 will stretch it back to a medium width font.

See also stretch() and QFont::Stretch.

source

pub unsafe fn set_strike_out(&self, arg1: bool)

If enable is true, sets strikeout on; otherwise sets strikeout off.

Calls C++ function: void QFont::setStrikeOut(bool arg1).

C++ documentation:

If enable is true, sets strikeout on; otherwise sets strikeout off.

See also strikeOut() and QFontInfo.

source

pub unsafe fn set_style(&self, style: Style)

Sets the style of the font to style.

Calls C++ function: void QFont::setStyle(QFont::Style style).

C++ documentation:

Sets the style of the font to style.

See also style(), italic(), and QFontInfo.

source

pub unsafe fn set_style_hint_2a(&self, arg1: StyleHint, arg2: StyleStrategy)

Sets the style hint and strategy to hint and strategy, respectively.

Calls C++ function: void QFont::setStyleHint(QFont::StyleHint arg1, QFont::StyleStrategy arg2 = …).

C++ documentation:

Sets the style hint and strategy to hint and strategy, respectively.

If these aren't set explicitly the style hint will default to AnyStyle and the style strategy to PreferDefault.

Qt does not support style hints on X11 since this information is not provided by the window system.

See also StyleHint, styleHint(), StyleStrategy, styleStrategy(), and QFontInfo.

source

pub unsafe fn set_style_hint_1a(&self, arg1: StyleHint)

Sets the style hint and strategy to hint and strategy, respectively.

Calls C++ function: void QFont::setStyleHint(QFont::StyleHint arg1).

C++ documentation:

Sets the style hint and strategy to hint and strategy, respectively.

If these aren't set explicitly the style hint will default to AnyStyle and the style strategy to PreferDefault.

Qt does not support style hints on X11 since this information is not provided by the window system.

See also StyleHint, styleHint(), StyleStrategy, styleStrategy(), and QFontInfo.

source

pub unsafe fn set_style_name(&self, arg1: impl CastInto<Ref<QString>>)

Sets the style name of the font to styleName. When set, other style properties like style() and weight() will be ignored for font matching, though they may be simulated afterwards if supported by the platform's font engine.

Calls C++ function: void QFont::setStyleName(const QString& arg1).

C++ documentation:

Sets the style name of the font to styleName. When set, other style properties like style() and weight() will be ignored for font matching, though they may be simulated afterwards if supported by the platform’s font engine.

Due to the lower quality of artificially simulated styles, and the lack of full cross platform support, it is not recommended to use matching by style name together with matching by style properties

This function was introduced in Qt 4.8.

See also styleName().

source

pub unsafe fn set_style_strategy(&self, s: StyleStrategy)

Sets the style strategy for the font to s.

Calls C++ function: void QFont::setStyleStrategy(QFont::StyleStrategy s).

C++ documentation:

Sets the style strategy for the font to s.

See also styleStrategy() and QFont::StyleStrategy.

source

pub unsafe fn set_underline(&self, arg1: bool)

If enable is true, sets underline on; otherwise sets underline off.

Calls C++ function: void QFont::setUnderline(bool arg1).

C++ documentation:

If enable is true, sets underline on; otherwise sets underline off.

See also underline() and QFontInfo.

source

pub unsafe fn set_weight(&self, arg1: c_int)

Sets the weight of the font to weight, using the scale defined by QFont::Weight enumeration.

Calls C++ function: void QFont::setWeight(int arg1).

C++ documentation:

Sets the weight of the font to weight, using the scale defined by QFont::Weight enumeration.

Note: If styleName() is set, this value may be ignored for font selection.

See also weight() and QFontInfo.

source

pub unsafe fn set_word_spacing(&self, spacing: c_double)

Sets the word spacing for the font to spacing.

Calls C++ function: void QFont::setWordSpacing(double spacing).

C++ documentation:

Sets the word spacing for the font to spacing.

Word spacing changes the default spacing between individual words. A positive value increases the word spacing by a corresponding amount of pixels, while a negative value decreases the inter-word spacing accordingly.

Word spacing will not apply to writing systems, where indiviaul words are not separated by white space.

This function was introduced in Qt 4.4.

See also wordSpacing() and setLetterSpacing().

source

pub unsafe fn static_meta_object() -> Ref<QMetaObject>

Returns a reference to the staticMetaObject field.

source

pub unsafe fn stretch(&self) -> c_int

Returns the stretch factor for the font.

Calls C++ function: int QFont::stretch() const.

C++ documentation:

Returns the stretch factor for the font.

See also setStretch().

source

pub unsafe fn strike_out(&self) -> bool

Returns true if strikeout has been set; otherwise returns false.

Calls C++ function: bool QFont::strikeOut() const.

C++ documentation:

Returns true if strikeout has been set; otherwise returns false.

See also setStrikeOut().

source

pub unsafe fn style(&self) -> Style

Returns the style of the font.

Calls C++ function: QFont::Style QFont::style() const.

C++ documentation:

Returns the style of the font.

See also setStyle().

source

pub unsafe fn style_hint(&self) -> StyleHint

Returns the StyleHint.

Calls C++ function: QFont::StyleHint QFont::styleHint() const.

C++ documentation:

Returns the StyleHint.

The style hint affects the font matching algorithm. See QFont::StyleHint for the list of available hints.

See also setStyleHint(), QFont::StyleStrategy, and QFontInfo::styleHint().

source

pub unsafe fn style_name(&self) -> CppBox<QString>

Returns the requested font style name. This can be used to match the font with irregular styles (that can't be normalized in other style properties).

Calls C++ function: QString QFont::styleName() const.

C++ documentation:

Returns the requested font style name. This can be used to match the font with irregular styles (that can’t be normalized in other style properties).

This function was introduced in Qt 4.8.

See also setStyleName(), setFamily(), and setStyle().

source

pub unsafe fn style_strategy(&self) -> StyleStrategy

Returns the StyleStrategy.

Calls C++ function: QFont::StyleStrategy QFont::styleStrategy() const.

C++ documentation:

Returns the StyleStrategy.

The style strategy affects the font matching algorithm. See QFont::StyleStrategy for the list of available strategies.

See also setStyleStrategy(), setStyleHint(), and QFont::StyleHint.

source

pub unsafe fn substitute(arg1: impl CastInto<Ref<QString>>) -> CppBox<QString>

Returns the first family name to be used whenever familyName is specified. The lookup is case insensitive.

Calls C++ function: static QString QFont::substitute(const QString& arg1).

C++ documentation:

Returns the first family name to be used whenever familyName is specified. The lookup is case insensitive.

If there is no substitution for familyName, familyName is returned.

To obtain a list of substitutions use substitutes().

See also setFamily(), insertSubstitutions(), insertSubstitution(), and removeSubstitutions().

source

pub unsafe fn substitutes( arg1: impl CastInto<Ref<QString>> ) -> CppBox<QStringList>

Returns a list of family names to be used whenever familyName is specified. The lookup is case insensitive.

Calls C++ function: static QStringList QFont::substitutes(const QString& arg1).

C++ documentation:

Returns a list of family names to be used whenever familyName is specified. The lookup is case insensitive.

If there is no substitution for familyName, an empty list is returned.

See also substitute(), insertSubstitutions(), insertSubstitution(), and removeSubstitutions().

source

pub unsafe fn substitutions() -> CppBox<QStringList>

Returns a sorted list of substituted family names.

Calls C++ function: static QStringList QFont::substitutions().

C++ documentation:

Returns a sorted list of substituted family names.

See also insertSubstitution(), removeSubstitution(), and substitute().

source

pub unsafe fn swap(&self, other: impl CastInto<Ref<QFont>>)

Swaps this font instance with other. This function is very fast and never fails.

Calls C++ function: void QFont::swap(QFont& other).

C++ documentation:

Swaps this font instance with other. This function is very fast and never fails.

This function was introduced in Qt 5.0.

source

pub unsafe fn to_q_variant(&self) -> CppBox<QVariant>

Returns the font as a QVariant

Calls C++ function: QVariant QFont::operator QVariant() const.

C++ documentation:

Returns the font as a QVariant

source

pub unsafe fn to_string(&self) -> CppBox<QString>

Returns a description of the font. The description is a comma-separated list of the attributes, perfectly suited for use in QSettings.

Calls C++ function: QString QFont::toString() const.

C++ documentation:

Returns a description of the font. The description is a comma-separated list of the attributes, perfectly suited for use in QSettings.

See also fromString().

source

pub unsafe fn underline(&self) -> bool

Returns true if underline has been set; otherwise returns false.

Calls C++ function: bool QFont::underline() const.

C++ documentation:

Returns true if underline has been set; otherwise returns false.

See also setUnderline().

source

pub unsafe fn weight(&self) -> c_int

Returns the weight of the font, using the same scale as the QFont::Weight enumeration.

Calls C++ function: int QFont::weight() const.

C++ documentation:

Returns the weight of the font, using the same scale as the QFont::Weight enumeration.

See also setWeight(), Weight, and QFontInfo.

source

pub unsafe fn word_spacing(&self) -> c_double

Returns the word spacing for the font.

Calls C++ function: double QFont::wordSpacing() const.

C++ documentation:

Returns the word spacing for the font.

This function was introduced in Qt 4.4.

See also setWordSpacing() and setLetterSpacing().

Trait Implementations§

source§

impl CppDeletable for QFont

source§

unsafe fn delete(&self)

Destroys the font object and frees all allocated resources.

Calls C++ function: [destructor] void QFont::~QFont().

C++ documentation:

Destroys the font object and frees all allocated resources.

source§

impl Lt<Ref<QFont>> for QFont

source§

unsafe fn lt(&self, arg1: &Ref<QFont>) -> bool

Provides an arbitrary comparison of this font and font f. All that is guaranteed is that the operator returns false if both fonts are equal and that (f1 < f2) == !(f2 < f1) if the fonts are not equal.

Calls C++ function: bool QFont::operator<(const QFont& arg1) const.

C++ documentation:

Provides an arbitrary comparison of this font and font f. All that is guaranteed is that the operator returns false if both fonts are equal and that (f1 < f2) == !(f2 < f1) if the fonts are not equal.

This function is useful in some circumstances, for example if you want to use QFont objects as keys in a QMap.

See also operator==(), operator!=(), and isCopyOf().

source§

impl PartialEq<Ref<QFont>> for QFont

source§

fn eq(&self, arg1: &Ref<QFont>) -> bool

Returns true if this font is equal to f; otherwise returns false.

Calls C++ function: bool QFont::operator==(const QFont& arg1) const.

C++ documentation:

Returns true if this font is equal to f; otherwise returns false.

Two QFonts are considered equal if their font attributes are equal.

See also operator!=() and isCopyOf().

1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.

Auto Trait Implementations§

§

impl RefUnwindSafe for QFont

§

impl Send for QFont

§

impl Sync for QFont

§

impl Unpin for QFont

§

impl UnwindSafe for QFont

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T, U> CastInto<U> for T
where U: CastFrom<T>,

source§

unsafe fn cast_into(self) -> U

Performs the conversion. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> StaticUpcast<T> for T

source§

unsafe fn static_upcast(ptr: Ptr<T>) -> Ptr<T>

Convert type of a const pointer. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.