122 Commits

Author SHA1 Message Date
Nyall Dawson
183e86f5b3 [api] Add method to test if labeling as non-default blend modes 2025-05-21 07:19:45 +10:00
Nyall Dawson
3f6b490218 Sipify 2025-04-02 11:11:10 +10:00
Nyall Dawson
6d122f0038 Sipify 2025-03-30 20:48:07 +10:00
Julien Cabieces
ed64834106 api(deprecated): add message to deprecated SIP annotation 2024-12-17 09:06:42 +01:00
Nyall Dawson
87efed6b0e Expose mode 2024-12-04 02:57:51 +10:00
Nyall Dawson
6708501ee9 [feature] Support CSS background property in labels/text renderer
This commit adds support for the CSS ``background-color`` and
``background-image`` properties when used with HTML labels.

- Backgrounds are supported for block items (eg ``<div>``) or inline
  items (eg ``<span>``)
- For images, the CSS should be formatted as ``background-image: url(xx)``.
  It supports local file paths, http links, or base64 embedded content
- Backgrounds are not supported for curved text
- HTML backgrounds are always rendered above any background shape for
  the label, and below drop shadows/buffers

Sponsored by City of Freiburg im Breisgau
2024-11-22 05:59:44 +10:00
Nyall Dawson
dd84aab200 Add background brush property for QgsTextBlock, QgsTextFragment 2024-11-22 05:59:44 +10:00
Nyall Dawson
7badf62596 [api] Add tab positions list for QgsTextFormat
Allows setting a list of custom tab stop distances, instead
of just a single distance
2024-11-10 09:52:14 +11:00
Nyall Dawson
0cccf4c42b Support CSS margins for block elements in HTML labels
Adds support for CSS margin properties for block elements in
the text renderer. Specifically:

- This is available for block type elements only, eg DIV, P, H1-H6.
- Margins are NOT available for spans or other non-block content (due to Qt
  limitations)
- Margins can be specified in pt units only
- Margins can be specified either via "margin-left: 5pt; margin-right:
  10pt" etc, or "margin: 5pt 0pt 10pt 0pt"
- Negative margins are supported for the bottom margin ONLY (due to Qt
  limitations)
2024-11-10 09:51:55 +11:00
Nyall Dawson
5a7fbaac1b Convert block margins to QgsTextBlockFormat margins 2024-11-10 09:51:55 +11:00
Nyall Dawson
ca5e4450b6 Support css line-height in HTML labels
Adds support for the line-height CSS property in HTML formatted labels.

Supports line-height in either points or percent, eg "line-height:
40pt" or "line-height: 40%"
2024-10-30 13:16:01 +10:00
Nyall Dawson
f9a7ac7329 Add methods to insert content into QgsTextBlock/QgsTextDocument 2024-10-21 13:41:51 +10:00
Nyall Dawson
d36982fd4d Reduce duplicate code 2024-10-11 11:22:54 +10:00
Nyall Dawson
65c654d2c8 Prep for calculating word wrapping in text document metrics 2024-10-10 11:09:18 +10:00
Nyall Dawson
93012dd5af [feature] Support img tags in HTML label text
Allows use of img tags in HTML label content. The following logic
is applied:

- Image path is set via the src="xxx" attribute. Local, HTTP, and
base64 encoded paths are permitted
- Any image format readable by QGIS can be used
- Image sizes can be specified via the width="##" and height="##"
attributes. If width or height is not specified it will automatically
be calculated from the original image size
- If width or height are specified, they are considered to be
in POINTS
- The css width/height settings are NOT respected (this is a Qt
limitation)
- Images are not supported for curved text labels
- Images are placed inline only, floating images are not supported

Sponsored by City of Freiburg im Breisgau
2024-09-29 08:57:52 +10:00
Nyall Dawson
ffc6dd208d Allow QgsTextFragment to represent an inline image object
Modifies the QgsTextDocument API to extract images from HTML
content, and store in the associated
QgsTextFragment/QgsTextCharacterFormat objects
2024-09-29 08:57:52 +10:00
Nyall Dawson
a492cb22fb [feature] Support horizontal alignment in HTML labels
For multi-line labels, this allows use of either:

- HTML <p align="xxx"> attributes
- CSS "text-align: xxx"
- HTML <center>some text</center> tags

Supported alignments are left, right, center and justify

Horizontal alignment can be used in all contexts where
HTML text is rendered, EXCEPT for curved labels (since they
are restricted to single-line text)

Sponsored by City of Freiburg im Breisgau
2024-09-16 17:26:24 +10:00
Nyall Dawson
b7d18c009a Fix dox 2024-09-14 13:25:59 +10:00
Nyall Dawson
957de0c311 Expose private QgsTextRenderer method for drawing document at point
This allows more efficient rendering when the document and metrics
have already been calculated
2024-09-14 13:25:59 +10:00
Nyall Dawson
5734116a10 Support h1/h2/.../h6 formatting in html labels 2024-09-11 13:43:00 +10:00
Nyall Dawson
90524634f9 [feature] Add support for word-spacing CSS in html labels
...and other places HTML text formatting is accepted.

This allows use of CSS "word-spacing: 12" to increase the word
spacing in a section of HTML text. The word spacing is always
treated as being in point units.
2024-09-11 08:24:39 +10:00
Nyall Dawson
b39f760cbc
Correctly handle multiline SIP_OUT param documentation 2024-09-10 11:11:25 +10:00
Nyall Dawson
534ca73c59 Fix missing see also trailing notes in PyQGIS documentation 2024-09-04 06:32:03 +10:00
Nyall Dawson
ef0289f3ec Fix formatting of Python ..deprecated annotations in docstrings
Fixes https://github.com/qgis/pyqgis-api-docs-builder/issues/174
2024-09-02 11:42:12 +10:00
Nyall Dawson
519959154a Fix some overly verbose class "brief" descriptions 2024-08-28 11:58:21 +10:00
Nyall Dawson
8b04562ba7 Avoid fragile reg for argument removal 2024-08-14 13:05:46 +10:00
Nyall Dawson
3a578d6712 Header update 2024-08-13 20:28:55 +10:00
Nyall Dawson
be8dce7d0d Valid improvements from new sipify 2024-08-13 20:28:55 +10:00
Nyall Dawson
6f652d251b Drop no-value copy constructor dox 2024-07-25 04:02:55 +10:00
Nyall Dawson
ad29a505e1 Fix text wrapping stability for small text
Adjust the QgsTextRenderer::calculateScaleFactorForFormat logic
so that small text is scaled up to at least 50 pixels when
calculating text metrics

This avoids tiny differences in calculated text metrics for small
text from affecting how text wrapping is calculated, which can
otherwise result in words at the end of lines "bouncing" from line
to line as layouts and maps are zoomed out
2024-07-25 04:02:33 +10:00
Nyall Dawson
28943f9c1b Remove a bunch of useless default constructor doxygen 2024-07-23 02:08:28 +10:00
Nyall Dawson
190108e7f1 Fix automatic font download on Windows 2024-06-27 06:17:13 +10:00
Nyall Dawson
fce4ed06b8 Split fragments on tab characters 2024-05-25 06:10:28 +10:00
Nyall Dawson
25f00e2560 Don't try to render empty text strings 2024-05-25 06:10:28 +10:00
Nyall Dawson
f5853a7212 Add tab stop distance to QgsTextFormat 2024-05-25 06:10:28 +10:00
Nyall Dawson
b70fba6762 Download Google fonts from github, not broken Google fonts download url
Note that not all fonts available from Google fonts are present on
the github repo for some reason, eg Open Sans Condensed is not.

Fixes #57070
2024-04-18 11:31:55 +10:00
Alessandro Pasotti
db37ff8fc9
Merge pull request #56334 from elpaso/bugfix-gh55532-line-break-in-html-labels
[labeling] fix BR in HTML labels
2024-02-23 09:28:08 +01:00
Even Rouault
15ea5c46bc
Header files: remove all mentions of '\since QGIS 3.0' 2024-02-18 20:57:23 +01:00
Alessandro Pasotti
3705ad0c2b [labeling] fix BR in HTML labels
Fix <br> ignored in HTML formatted labels.

Fix #55532
2024-02-13 12:10:25 +01:00
Mathieu Pellerin
0e6b4fb118 [layouts] Fix line height setting not respected for HTML-enabled label items 2023-10-17 15:55:13 +13:00
Nyall Dawson
ff7a5c934c Fix pixelated icons in style lists on hi dpi displays
Use QgsScreenProperties in style model to ensure we
correctly generate preview icons matching the device
pixel ratio and DPI of all attached displays
2023-06-22 18:49:22 +10:00
Alessandro Pasotti
8b8d5d9031
Merge pull request #53438 from elpaso/bugfix-gh48020-server-opacities-parameter-does-not-apply-to-labels
Server: fix label opacity when OPACITIES is set
2023-06-21 16:32:16 +02:00
Nyall Dawson
730081dceb Handle view device pixel ratio when generating preview icons
for text format and label settings
2023-06-21 13:46:50 +10:00
Alessandro Pasotti
b1b8fb8e15 Address PR comments 2023-06-14 09:55:48 +02:00
Alessandro Pasotti
a7c803e6c0 Implement multiplyOpacity for QgsTextFormat
This is used to change the labeling opacity in the server.
2023-06-13 12:55:40 +02:00
Nyall Dawson
50c76929e1
Followup 30700f1, ensure links to Qgis members are set in docstrings 2023-03-31 10:46:24 +10:00
Nyall Dawson
107e206ccb Expand documentation 2023-03-27 20:58:08 +10:00
Nyall Dawson
95786c347d Add QgsTextRenderer method to render text along a line/curved path 2023-03-27 20:58:08 +10:00
Nyall Dawson
f9c3da1e06 Move unit enums to Qgis, promote to enum class 2023-02-19 13:29:06 +10:00
Nyall Dawson
cfbf5ef51d Add more efficient method to draw document when a QgsTextDocument is already available 2022-11-24 12:41:24 +10:00