108 Commits

Author SHA1 Message Date
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
Nyall Dawson
a10b971156 Add additional text renderer rect modes
Adds some text layout modes where the line heights are based
on cap heights or font ascent alone

These are required in order to port additional parts of QGIS
text rendering to the QgsTextRenderer class
2022-11-24 12:41:24 +10:00
Nyall Dawson
a7c39ffdc7 Add support for super and subscript HTML formatting in text renderer
This allows for either:

- <sup>superscript</sup> / <sub>subscript</sub> components in text,
where the text will be vertically super or subscript aligned
and automatically sized to 2/3rd of the parent font size. Users
can also set a fixed font size for the super/sub script by
including css rules, e.g. <sup style="font-size:33pt">super</sup>

- "vertical-align: super" or "vertical-align: sub" CSS formatting
rules in any other HTML element

Sponsored by OSGEO UK
2022-11-14 20:46:15 +10:00
Nyall Dawson
79b809a585 Prepare framework for text renderer vertical alignment 2022-11-14 20:46:15 +10:00
Nyall Dawson
ed84780de6 Avoid unnecessary font scaling by precalculating if format has a null
font size
2022-11-10 18:30:06 +10:00
Nyall Dawson
e478a52d72 Use precalculated horizontal advance and fragment fonts from text metrics instead of
recalculating
2022-11-10 18:30:06 +10:00
Nyall Dawson
8dbb654a55 Address review 2022-09-07 22:09:52 +10:00
Nyall Dawson
254c43df5f Correctly render vertical oriented text using HTML formatting 2022-09-07 22:09:52 +10:00
Nyall Dawson
05bd566089 Modify text renderer to account for rendering text with HTML
content which varies in font metrics
2022-09-07 22:09:52 +10:00
Nyall Dawson
5f2aca49af Correctly account for scaling factor and render context scale
when creating fonts for document fragments
2022-09-07 22:09:52 +10:00
Nyall Dawson
ad5d9d89f5 Add font size, family, italic and bold to QgsTextCharacterFormat 2022-09-07 22:09:52 +10:00
Nyall Dawson
b4c9378625 Move text renderer enums to Qgis, promote to enum class, tighten includes 2022-09-06 15:30:00 +10:00
Nyall Dawson
ed9dfa9f5a Move TextOrientation enum from QgsTextFormat and promote to enum class 2022-09-05 17:17:18 +10:00
Nyall Dawson
775e333ec3 [feature][labeling] Add option to use absolute units for line height
Previously the line height was always set in multiples of the
text line spacing. This works fine for rendering text blocks
containing text of all the same sizes, but when we mix
text sizes in the one document then the relative line height
option doesn't cover all use cases. (e.g. when a constant
spacing between lines is desired even when the text on those
lines varies in height)
2022-09-05 13:17:33 +10:00
Nyall Dawson
864fee0172 Try to take stored font filename from response headers 2022-06-20 13:01:55 +10:00