Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support CSS background property in labels/text renderer #59450

Merged
merged 4 commits into from
Nov 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,13 @@ Sets the block ``format`` for the fragment.
Applies a ``capitalization`` style to the block's text.

.. versionadded:: 3.16
%End

bool hasBackgrounds() const;
%Docstring
Returns ``True`` if the block or any of the fragments in the block have background brushes set.

.. versionadded:: 3.42
%End

Py_ssize_t __len__() const;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,63 @@ Sets the block margins, in points.

.. seealso:: :py:func:`margins`

.. versionadded:: 3.42
%End

bool hasBackground() const;
%Docstring
Returns ``True`` if the block has a background set.

.. seealso:: :py:func:`backgroundBrush`

.. versionadded:: 3.42
%End

QBrush backgroundBrush() const;
%Docstring
Returns the brush used for rendering the background of the block.

Alternatively, the format may have a :py:func:`~QgsTextBlockFormat.backgroundBrush` set.

.. seealso:: :py:func:`hasBackground`

.. seealso:: :py:func:`setBackgroundBrush`

.. versionadded:: 3.42
%End

void setBackgroundBrush( const QBrush &brush );
%Docstring
Sets the ``brush`` used for rendering the background of the block.

Alternatively, the format may have a :py:func:`~QgsTextBlockFormat.backgroundBrush` set.

.. seealso:: :py:func:`backgroundBrush`

.. versionadded:: 3.42
%End

QString backgroundImagePath() const;
%Docstring
Returns the path for the image to be used for rendering the background of the fragment.

Alternatively, the format may have a :py:func:`~QgsTextBlockFormat.backgroundBrush` set.

.. seealso:: :py:func:`hasBackground`

.. seealso:: :py:func:`setBackgroundImagePath`

.. versionadded:: 3.42
%End

void setBackgroundImagePath( const QString &path );
%Docstring
Sets the ``path`` for the image to be used for rendering the background of the fragment.

Alternatively, the format may have a :py:func:`~QgsTextBlockFormat.backgroundBrush` set.

.. seealso:: :py:func:`backgroundImagePath`

.. versionadded:: 3.42
%End

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,63 @@ This property is only respected if :py:func:`~QgsTextCharacterFormat.hasVertical
.. seealso:: :py:func:`verticalAlignment`

.. versionadded:: 3.30
%End

bool hasBackground() const;
%Docstring
Returns ``True`` if the fragment has a background set.

.. seealso:: :py:func:`backgroundBrush`

.. versionadded:: 3.42
%End

QBrush backgroundBrush() const;
%Docstring
Returns the brush used for rendering the background of the fragment.

Alternatively, the format may have a :py:func:`~QgsTextCharacterFormat.backgroundImagePath` set.

.. seealso:: :py:func:`hasBackground`

.. seealso:: :py:func:`setBackgroundBrush`

.. versionadded:: 3.42
%End

void setBackgroundBrush( const QBrush &brush );
%Docstring
Sets the ``brush`` used for rendering the background of the fragment.

Alternatively, the format may have a :py:func:`~QgsTextCharacterFormat.backgroundImagePath` set.

.. seealso:: :py:func:`backgroundBrush`

.. versionadded:: 3.42
%End

QString backgroundImagePath() const;
%Docstring
Returns the path for the image to be used for rendering the background of the fragment.

Alternatively, the format may have a :py:func:`~QgsTextCharacterFormat.backgroundBrush` set.

.. seealso:: :py:func:`hasBackground`

.. seealso:: :py:func:`setBackgroundImagePath`

.. versionadded:: 3.42
%End

void setBackgroundImagePath( const QString &path );
%Docstring
Sets the ``path`` for the image to be used for rendering the background of the fragment.

Alternatively, the format may have a :py:func:`~QgsTextCharacterFormat.backgroundBrush` set.

.. seealso:: :py:func:`backgroundImagePath`

.. versionadded:: 3.42
%End

void updateFontForFormat( QFont &font, const QgsRenderContext &context, double scaleFactor = 1.0 ) const;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,13 @@ Applies a ``capitalization`` style to the document's text.
.. versionadded:: 3.16
%End

bool hasBackgrounds() const;
%Docstring
Returns ``True`` if any blocks or fragments in the document have background brushes set.

.. versionadded:: 3.42
%End


};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,24 @@ to the fragment at the specified index within that block.
Returns the fixed height of the fragment at the specified block and fragment index, or -1 if the fragment does not have a fixed height.

.. versionadded:: 3.40
%End

double fragmentAscent( int blockIndex, int fragmentIndex, Qgis::TextLayoutMode mode ) const;
%Docstring
Returns the ascent of the fragment at the specified block and fragment index.

.. seealso:: :py:func:`fragmentDescent`

.. versionadded:: 3.42
%End

double fragmentDescent( int blockIndex, int fragmentIndex, Qgis::TextLayoutMode mode ) const;
%Docstring
Returns the descent of the fragment at the specified block and fragment index.

.. seealso:: :py:func:`fragmentAscent`

.. versionadded:: 3.42
%End

double verticalOrientationXOffset( int blockIndex ) const;
Expand All @@ -187,6 +205,17 @@ Returns the maximum character width for the specified block.
double blockMaximumDescent( int blockIndex ) const;
%Docstring
Returns the maximum descent encountered in the specified block.

.. seealso:: :py:func:`blockMaximumAscent`
%End

double blockMaximumAscent( int blockIndex ) const;
%Docstring
Returns the maximum ascent encountered in the specified block.

.. seealso:: :py:func:`blockMaximumDescent`

.. versionadded:: 3.42
%End

QFont fragmentFont( int blockIndex, int fragmentIndex ) const;
Expand Down
7 changes: 7 additions & 0 deletions python/core/auto_generated/textrenderer/qgstextblock.sip.in
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,13 @@ Sets the block ``format`` for the fragment.
Applies a ``capitalization`` style to the block's text.

.. versionadded:: 3.16
%End

bool hasBackgrounds() const;
%Docstring
Returns ``True`` if the block or any of the fragments in the block have background brushes set.

.. versionadded:: 3.42
%End

int __len__() const;
Expand Down
57 changes: 57 additions & 0 deletions python/core/auto_generated/textrenderer/qgstextblockformat.sip.in
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,63 @@ Sets the block margins, in points.

.. seealso:: :py:func:`margins`

.. versionadded:: 3.42
%End

bool hasBackground() const;
%Docstring
Returns ``True`` if the block has a background set.

.. seealso:: :py:func:`backgroundBrush`

.. versionadded:: 3.42
%End

QBrush backgroundBrush() const;
%Docstring
Returns the brush used for rendering the background of the block.

Alternatively, the format may have a :py:func:`~QgsTextBlockFormat.backgroundBrush` set.

.. seealso:: :py:func:`hasBackground`

.. seealso:: :py:func:`setBackgroundBrush`

.. versionadded:: 3.42
%End

void setBackgroundBrush( const QBrush &brush );
%Docstring
Sets the ``brush`` used for rendering the background of the block.

Alternatively, the format may have a :py:func:`~QgsTextBlockFormat.backgroundBrush` set.

.. seealso:: :py:func:`backgroundBrush`

.. versionadded:: 3.42
%End

QString backgroundImagePath() const;
%Docstring
Returns the path for the image to be used for rendering the background of the fragment.

Alternatively, the format may have a :py:func:`~QgsTextBlockFormat.backgroundBrush` set.

.. seealso:: :py:func:`hasBackground`

.. seealso:: :py:func:`setBackgroundImagePath`

.. versionadded:: 3.42
%End

void setBackgroundImagePath( const QString &path );
%Docstring
Sets the ``path`` for the image to be used for rendering the background of the fragment.

Alternatively, the format may have a :py:func:`~QgsTextBlockFormat.backgroundBrush` set.

.. seealso:: :py:func:`backgroundImagePath`

.. versionadded:: 3.42
%End

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,63 @@ This property is only respected if :py:func:`~QgsTextCharacterFormat.hasVertical
.. seealso:: :py:func:`verticalAlignment`

.. versionadded:: 3.30
%End

bool hasBackground() const;
%Docstring
Returns ``True`` if the fragment has a background set.

.. seealso:: :py:func:`backgroundBrush`

.. versionadded:: 3.42
%End

QBrush backgroundBrush() const;
%Docstring
Returns the brush used for rendering the background of the fragment.

Alternatively, the format may have a :py:func:`~QgsTextCharacterFormat.backgroundImagePath` set.

.. seealso:: :py:func:`hasBackground`

.. seealso:: :py:func:`setBackgroundBrush`

.. versionadded:: 3.42
%End

void setBackgroundBrush( const QBrush &brush );
%Docstring
Sets the ``brush`` used for rendering the background of the fragment.

Alternatively, the format may have a :py:func:`~QgsTextCharacterFormat.backgroundImagePath` set.

.. seealso:: :py:func:`backgroundBrush`

.. versionadded:: 3.42
%End

QString backgroundImagePath() const;
%Docstring
Returns the path for the image to be used for rendering the background of the fragment.

Alternatively, the format may have a :py:func:`~QgsTextCharacterFormat.backgroundBrush` set.

.. seealso:: :py:func:`hasBackground`

.. seealso:: :py:func:`setBackgroundImagePath`

.. versionadded:: 3.42
%End

void setBackgroundImagePath( const QString &path );
%Docstring
Sets the ``path`` for the image to be used for rendering the background of the fragment.

Alternatively, the format may have a :py:func:`~QgsTextCharacterFormat.backgroundBrush` set.

.. seealso:: :py:func:`backgroundImagePath`

.. versionadded:: 3.42
%End

void updateFontForFormat( QFont &font, const QgsRenderContext &context, double scaleFactor = 1.0 ) const;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,13 @@ Applies a ``capitalization`` style to the document's text.
.. versionadded:: 3.16
%End

bool hasBackgrounds() const;
%Docstring
Returns ``True`` if any blocks or fragments in the document have background brushes set.

.. versionadded:: 3.42
%End


};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,24 @@ to the fragment at the specified index within that block.
Returns the fixed height of the fragment at the specified block and fragment index, or -1 if the fragment does not have a fixed height.

.. versionadded:: 3.40
%End

double fragmentAscent( int blockIndex, int fragmentIndex, Qgis::TextLayoutMode mode ) const;
%Docstring
Returns the ascent of the fragment at the specified block and fragment index.

.. seealso:: :py:func:`fragmentDescent`

.. versionadded:: 3.42
%End

double fragmentDescent( int blockIndex, int fragmentIndex, Qgis::TextLayoutMode mode ) const;
%Docstring
Returns the descent of the fragment at the specified block and fragment index.

.. seealso:: :py:func:`fragmentAscent`

.. versionadded:: 3.42
%End

double verticalOrientationXOffset( int blockIndex ) const;
Expand All @@ -187,6 +205,17 @@ Returns the maximum character width for the specified block.
double blockMaximumDescent( int blockIndex ) const;
%Docstring
Returns the maximum descent encountered in the specified block.

.. seealso:: :py:func:`blockMaximumAscent`
%End

double blockMaximumAscent( int blockIndex ) const;
%Docstring
Returns the maximum ascent encountered in the specified block.

.. seealso:: :py:func:`blockMaximumDescent`

.. versionadded:: 3.42
%End

QFont fragmentFont( int blockIndex, int fragmentIndex ) const;
Expand Down
Loading
Loading