Struct qt_gui::QGlyphRun

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

The QGlyphRun class provides direct access to the internal glyphs in a font.

C++ class: QGlyphRun.

C++ documentation:

The QGlyphRun class provides direct access to the internal glyphs in a font.

When Qt displays a string of text encoded in Unicode, it will first convert the Unicode points into a list of glyph indexes and a list of positions based on one or more fonts. The Unicode representation of the text and the QFont object will in this case serve as a convenient abstraction that hides the details of what actually takes place when displaying the text on-screen. For instance, by the time the text actually reaches the screen, it may be represented by a set of fonts in addition to the one specified by the user, e.g. in case the originally selected font did not support all the writing systems contained in the text.

Under certain circumstances, it can be useful as an application developer to have more low-level control over which glyphs in a specific font are drawn to the screen. This could for instance be the case in applications that use an external font engine and text shaper together with Qt. QGlyphRun provides an interface to the raw data needed to get text on the screen. It contains a list of glyph indexes, a position for each glyph and a font.

It is the user's responsibility to ensure that the selected font actually contains the provided glyph indexes.

QTextLayout::glyphRuns() or QTextFragment::glyphRuns() can be used to convert unicode encoded text into a list of QGlyphRun objects, and QPainter::drawGlyphRun() can be used to draw the glyphs.

Note: Please note that QRawFont is considered local to the thread in which it is constructed. This in turn means that a new QRawFont will have to be created and set on the QGlyphRun if it is moved to a different thread. If the QGlyphRun contains a reference to a QRawFont from a different thread than the current, it will not be possible to draw the glyphs using a QPainter, as the QRawFont is considered invalid and inaccessible in this case.

Implementations§

source§

impl QGlyphRun

source

pub unsafe fn bounding_rect(&self) -> CppBox<QRectF>

Returns the smallest rectangle that contains all glyphs in this QGlyphRun. If a bounding rect has been set using setBoundingRect(), then this will be returned. Otherwise the bounding rect will be calculated based on the font metrics of the glyphs in the glyph run.

Calls C++ function: QRectF QGlyphRun::boundingRect() const.

C++ documentation:

Returns the smallest rectangle that contains all glyphs in this QGlyphRun. If a bounding rect has been set using setBoundingRect(), then this will be returned. Otherwise the bounding rect will be calculated based on the font metrics of the glyphs in the glyph run.

This function was introduced in Qt 5.0.

See also setBoundingRect().

source

pub unsafe fn clear(&self)

Clears all data in the QGlyphRun object.

Calls C++ function: void QGlyphRun::clear().

C++ documentation:

Clears all data in the QGlyphRun object.

source

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

Assigns other to this QGlyphRun object.

Calls C++ function: QGlyphRun& QGlyphRun::operator=(const QGlyphRun& other).

C++ documentation:

Assigns other to this QGlyphRun object.

source

pub unsafe fn flags(&self) -> QFlags<GlyphRunFlag>

Returns the flags set for this QGlyphRun.

Calls C++ function: QFlags<QGlyphRun::GlyphRunFlag> QGlyphRun::flags() const.

C++ documentation:

Returns the flags set for this QGlyphRun.

This function was introduced in Qt 5.0.

See also setFlags(), setFlag(), and setFlag().

source

pub unsafe fn glyph_indexes(&self) -> CppBox<QVectorOfU32>

Returns the glyph indexes for this QGlyphRun object.

Calls C++ function: QVector<quint32> QGlyphRun::glyphIndexes() const.

C++ documentation:

Returns the glyph indexes for this QGlyphRun object.

See also setGlyphIndexes() and setPositions().

source

pub unsafe fn is_empty(&self) -> bool

Returns true if the QGlyphRun does not contain any glyphs.

Calls C++ function: bool QGlyphRun::isEmpty() const.

C++ documentation:

Returns true if the QGlyphRun does not contain any glyphs.

This function was introduced in Qt 5.0.

source

pub unsafe fn is_right_to_left(&self) -> bool

Returns true if this QGlyphRun contains glyphs that are painted from the right to the left.

Calls C++ function: bool QGlyphRun::isRightToLeft() const.

C++ documentation:

Returns true if this QGlyphRun contains glyphs that are painted from the right to the left.

This function was introduced in Qt 5.0.

See also setRightToLeft() and flags().

source

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

Constructs an empty QGlyphRun object.

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

C++ documentation:

Constructs an empty QGlyphRun object.

source

pub unsafe fn new_copy( other: impl CastInto<Ref<QGlyphRun>> ) -> CppBox<QGlyphRun>

Constructs a QGlyphRun object which is a copy of other.

Calls C++ function: [constructor] void QGlyphRun::QGlyphRun(const QGlyphRun& other).

C++ documentation:

Constructs a QGlyphRun object which is a copy of other.

source

pub unsafe fn overline(&self) -> bool

Returns true if this QGlyphRun should be painted with an overline decoration.

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

C++ documentation:

Returns true if this QGlyphRun should be painted with an overline decoration.

See also setOverline() and flags().

source

pub unsafe fn positions(&self) -> CppBox<QVectorOfQPointF>

Returns the position of the edge of the baseline for each glyph in this set of glyph indexes.

Calls C++ function: QVector<QPointF> QGlyphRun::positions() const.

C++ documentation:

Returns the position of the edge of the baseline for each glyph in this set of glyph indexes.

See also setPositions().

source

pub unsafe fn raw_font(&self) -> CppBox<QRawFont>

Returns the font selected for this QGlyphRun object.

Calls C++ function: QRawFont QGlyphRun::rawFont() const.

C++ documentation:

Returns the font selected for this QGlyphRun object.

See also setRawFont().

source

pub unsafe fn set_bounding_rect( &self, bounding_rect: impl CastInto<Ref<QRectF>> )

Sets the bounding rect of the glyphs in this QGlyphRun to be boundingRect. This rectangle will be returned by boundingRect() unless it is empty, in which case the bounding rectangle of the glyphs in the glyph run will be returned instead.

Calls C++ function: void QGlyphRun::setBoundingRect(const QRectF& boundingRect).

C++ documentation:

Sets the bounding rect of the glyphs in this QGlyphRun to be boundingRect. This rectangle will be returned by boundingRect() unless it is empty, in which case the bounding rectangle of the glyphs in the glyph run will be returned instead.

Note: Unless you are implementing text shaping, you should not have to use this function. It is used specifically when the QGlyphRun should represent an area which is smaller than the area of the glyphs it contains. This could happen e.g. if the glyph run is retrieved by calling QTextLayout::glyphRuns() and the specified range only includes part of a ligature (where two or more characters are combined to a single glyph.) When this is the case, the bounding rect should only include the appropriate part of the ligature glyph, based on a calculation of the average width of the characters in the ligature.

In order to support such a case (an example is selections which should be drawn with a different color than the main text color), it is necessary to clip the painting mechanism to the rectangle returned from boundingRect() to avoid drawing the entire ligature glyph.

This function was introduced in Qt 5.0.

See also boundingRect().

source

pub unsafe fn set_flag_2a(&self, flag: GlyphRunFlag, enabled: bool)

If enabled is true, then flag is enabled; otherwise, it is disabled.

Calls C++ function: void QGlyphRun::setFlag(QGlyphRun::GlyphRunFlag flag, bool enabled = …).

C++ documentation:

If enabled is true, then flag is enabled; otherwise, it is disabled.

This function was introduced in Qt 5.0.

See also flags() and setFlags().

source

pub unsafe fn set_flag_1a(&self, flag: GlyphRunFlag)

If enabled is true, then flag is enabled; otherwise, it is disabled.

Calls C++ function: void QGlyphRun::setFlag(QGlyphRun::GlyphRunFlag flag).

C++ documentation:

If enabled is true, then flag is enabled; otherwise, it is disabled.

This function was introduced in Qt 5.0.

See also flags() and setFlags().

source

pub unsafe fn set_flags(&self, flags: QFlags<GlyphRunFlag>)

Sets the flags of this QGlyphRun to flags.

Calls C++ function: void QGlyphRun::setFlags(QFlags<QGlyphRun::GlyphRunFlag> flags).

C++ documentation:

Sets the flags of this QGlyphRun to flags.

This function was introduced in Qt 5.0.

See also setFlag() and flags().

source

pub unsafe fn set_glyph_indexes( &self, glyph_indexes: impl CastInto<Ref<QVectorOfU32>> )

Set the glyph indexes for this QGlyphRun object to glyphIndexes. The glyph indexes must be valid for the selected font.

Calls C++ function: void QGlyphRun::setGlyphIndexes(const QVector<quint32>& glyphIndexes).

C++ documentation:

Set the glyph indexes for this QGlyphRun object to glyphIndexes. The glyph indexes must be valid for the selected font.

See also glyphIndexes().

source

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

Indicates that this QGlyphRun should be painted with an overline decoration if overline is true. Otherwise the QGlyphRun should be painted with no overline decoration.

Calls C++ function: void QGlyphRun::setOverline(bool overline).

C++ documentation:

Indicates that this QGlyphRun should be painted with an overline decoration if overline is true. Otherwise the QGlyphRun should be painted with no overline decoration.

See also overline(), setFlag(), and setFlags().

source

pub unsafe fn set_positions( &self, positions: impl CastInto<Ref<QVectorOfQPointF>> )

Sets the positions of the edge of the baseline for each glyph in this set of glyph indexes to positions.

Calls C++ function: void QGlyphRun::setPositions(const QVector<QPointF>& positions).

C++ documentation:

Sets the positions of the edge of the baseline for each glyph in this set of glyph indexes to positions.

See also positions().

source

pub unsafe fn set_raw_data( &self, glyph_index_array: *const u32, glyph_position_array: impl CastInto<Ptr<QPointF>>, size: c_int )

Sets the glyph indexes and positions of this QGlyphRun to use the first size elements in the arrays glyphIndexArray and glyphPositionArray. The data is not copied. The caller must guarantee that the arrays are not deleted as long as this QGlyphRun and any copies of it exists.

Calls C++ function: void QGlyphRun::setRawData(const quint32* glyphIndexArray, const QPointF* glyphPositionArray, int size).

C++ documentation:

Sets the glyph indexes and positions of this QGlyphRun to use the first size elements in the arrays glyphIndexArray and glyphPositionArray. The data is not copied. The caller must guarantee that the arrays are not deleted as long as this QGlyphRun and any copies of it exists.

See also setGlyphIndexes() and setPositions().

source

pub unsafe fn set_raw_font(&self, raw_font: impl CastInto<Ref<QRawFont>>)

Sets the font in which to look up the glyph indexes to the rawFont specified.

Calls C++ function: void QGlyphRun::setRawFont(const QRawFont& rawFont).

C++ documentation:

Sets the font in which to look up the glyph indexes to the rawFont specified.

See also rawFont() and setGlyphIndexes().

source

pub unsafe fn set_right_to_left(&self, on: bool)

Indicates that this QGlyphRun contains glyphs that should be ordered from the right to left if rightToLeft is true. Otherwise the order of the glyphs is assumed to be left to right.

Calls C++ function: void QGlyphRun::setRightToLeft(bool on).

C++ documentation:

Indicates that this QGlyphRun contains glyphs that should be ordered from the right to left if rightToLeft is true. Otherwise the order of the glyphs is assumed to be left to right.

This function was introduced in Qt 5.0.

See also isRightToLeft(), setFlag(), and setFlags().

source

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

Indicates that this QGlyphRun should be painted with an strike out decoration if strikeOut is true. Otherwise the QGlyphRun should be painted with no strike out decoration.

Calls C++ function: void QGlyphRun::setStrikeOut(bool strikeOut).

C++ documentation:

Indicates that this QGlyphRun should be painted with an strike out decoration if strikeOut is true. Otherwise the QGlyphRun should be painted with no strike out decoration.

See also strikeOut(), setFlag(), and setFlags().

source

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

Indicates that this QGlyphRun should be painted with an underline decoration if underline is true. Otherwise the QGlyphRun should be painted with no underline decoration.

Calls C++ function: void QGlyphRun::setUnderline(bool underline).

C++ documentation:

Indicates that this QGlyphRun should be painted with an underline decoration if underline is true. Otherwise the QGlyphRun should be painted with no underline decoration.

See also underline(), setFlag(), and setFlags().

source

pub unsafe fn strike_out(&self) -> bool

Returns true if this QGlyphRun should be painted with a strike out decoration.

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

C++ documentation:

Returns true if this QGlyphRun should be painted with a strike out decoration.

See also setStrikeOut() and flags().

source

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

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

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

C++ documentation:

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

This function was introduced in Qt 5.0.

source

pub unsafe fn underline(&self) -> bool

Returns true if this QGlyphRun should be painted with an underline decoration.

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

C++ documentation:

Returns true if this QGlyphRun should be painted with an underline decoration.

See also setUnderline() and flags().

Trait Implementations§

source§

impl CppDeletable for QGlyphRun

source§

unsafe fn delete(&self)

Destroys the QGlyphRun.

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

C++ documentation:

Destroys the QGlyphRun.

source§

impl PartialEq<Ref<QGlyphRun>> for QGlyphRun

source§

fn eq(&self, other: &Ref<QGlyphRun>) -> bool

Compares other to this QGlyphRun object. Returns true if the list of glyph indexes, the list of positions and the font are all equal, otherwise returns false.

Calls C++ function: bool QGlyphRun::operator==(const QGlyphRun& other) const.

C++ documentation:

Compares other to this QGlyphRun object. Returns true if the list of glyph indexes, the list of positions and the font are all equal, otherwise returns false.

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§

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.