pub struct FontInfo<'a> { /* private fields */ }
Expand description
Notice these docs are heavy WIP and not very relevent yet
The QFontInfo class provides the same access functions as QFont, e.g. family(), pointSize(), italic(), weight(), fixedPitch(), styleHint() etc. But whilst the QFont access functions return the values that were set, a QFontInfo object returns the values that apply to the font that will actually be used to draw the text.
For example, when the program asks for a 25pt Courier font on a machine that has a non-scalable 24pt Courier font, QFont will (normally) use the 24pt Courier for rendering. In this case, QFont::pointSize() returns 25 and QFontInfo::pointSize() returns 24.
There are three ways to create a QFontInfo object.
- Calling the QFontInfo constructor with a QFont creates a font info object for a screen-compatible font, i.e. the font cannot be a printer font. If the font is changed later, the font info object is not updated. (Note: If you use a printer font the values returned may be inaccurate. Printer fonts are not always accessible so the nearest screen font is used if a printer font is supplied.)
- QWidget::fontInfo() returns the font info for a widget’s font. This is equivalent to calling QFontInfo(widget->font()). If the widget’s font is changed later, the font info object is not updated.
- QPainter::fontInfo() returns the font info for a painter’s current font. If the painter’s font is changed later, the font info object is not updated.
See also: QFont QFontMetrics QFontDatabase
Licence
The documentation is an adoption of the original Qt Documentation and provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation.
Implementations
sourceimpl<'a> FontInfo<'a>
impl<'a> FontInfo<'a>
sourcepub fn swap<F: FontInfoTrait<'a>>(&self, other: &F) -> &Self
pub fn swap<F: FontInfoTrait<'a>>(&self, other: &F) -> &Self
Swaps this font info instance with other. This function is very fast and never fails.
sourcepub fn family(&self) -> String
pub fn family(&self) -> String
Returns the family name of the matched window system font.
See also: QFont::family()
sourcepub fn style_name(&self) -> String
pub fn style_name(&self) -> String
Returns the style name of the matched window system font on systems that support it.
See also: QFont::styleName()
sourcepub fn pixel_size(&self) -> i32
pub fn pixel_size(&self) -> i32
Returns the pixel size of the matched window system font.
See also: QFont::pointSize()
sourcepub fn point_size(&self) -> i32
pub fn point_size(&self) -> i32
Returns the point size of the matched window system font.
See also: pointSizeF() QFont::pointSize()
Returns the point size of the matched window system font.
See also: QFont::pointSizeF()
sourcepub fn point_size_f(&self) -> f32
pub fn point_size_f(&self) -> f32
Returns the point size of the matched window system font.
See also: QFont::pointSizeF()
sourcepub fn italic(&self) -> bool
pub fn italic(&self) -> bool
Returns the italic value of the matched window system font.
See also: QFont::italic()
sourcepub fn weight(&self) -> i32
pub fn weight(&self) -> i32
Returns the style name of the matched window system font on systems that support it.
See also: QFont::styleName()
Returns the style value of the matched window system font.
See also: QFont::style()
Returns the style of the matched window system font.
Currently only returns the style hint set in QFont.
See also: QFont::styleHint() QFont::StyleHint
Returns the weight of the matched window system font.
See also: QFont::weight() bold()
sourcepub fn bold(&self) -> bool
pub fn bold(&self) -> bool
Returns true
if weight() would return a value greater than
QFont::Normal; otherwise returns false.
See also: weight() QFont::bold()
pub fn underline(&self) -> bool
pub fn overline(&self) -> bool
sourcepub fn fixed_pitch(&self) -> bool
pub fn fixed_pitch(&self) -> bool
Returns the fixed pitch value of the matched window system font.
See also: QFont::fixedPitch()
sourcepub fn style_hint(&self) -> StyleHint
pub fn style_hint(&self) -> StyleHint
Returns the style of the matched window system font.
Currently only returns the style hint set in QFont.
See also: QFont::styleHint() QFont::StyleHint
sourcepub fn raw_mode(&self) -> bool
pub fn raw_mode(&self) -> bool
Returns true
if the font is a raw mode font; otherwise returns
false.
If it is a raw mode font, all other functions in QFontInfo will return the same values set in the QFont, regardless of the font actually used.
See also: QFont::rawMode()
sourcepub fn exact_match(&self) -> bool
pub fn exact_match(&self) -> bool
Returns true
if the matched window system font is exactly the same
as the one specified by the font; otherwise returns false.
See also: QFont::exactMatch()