82 Commits

Author SHA1 Message Date
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
Nyall Dawson
dae637a67c Defer font download handling until QgsApplication is fully initialized
and make opt-in for non-app clients

There's a tricky initialization balancing act happening here -- but
if we try to load the default style on a system missing the fonts
referenced in that style, then we risk trying to download those
fonts before the QgsNetworkAccessManager is ready.

So play it safe and defer all font download handling until the
QGIS app is fully launched.
2022-06-20 13:01:55 +10:00
Nyall Dawson
b9ff03473b Download missing fonts when parsing vector tile styles wherever possible
This is an alternative approach to solving #46588, where we avoid the
issues which arise from trying to render vector tile PBF fonts.

Refs #46588
2022-06-20 13:01:55 +10:00
Nyall Dawson
3214235580 Add method to remove a user font 2022-06-20 13:01:55 +10:00
Nyall Dawson
e1dba0dbe0 Allow for multiple user font directories, and add method to return
all installed user fonts
2022-06-20 13:01:55 +10:00
Nyall Dawson
852480c7bc Wrap up font download in a nice method which just requires a family name
And populate hardcoded list with a bunch of known fonts available
from Google Fonts
2022-06-20 13:01:55 +10:00
Nyall Dawson
4772f6c27e Add method to download and install a font 2022-06-20 13:01:55 +10:00
Nyall Dawson
4f2705e435 Make any TTF/OTF fonts stored in the QGIS user profile/fonts directory
available for use in QGIS

Allows for use of fonts which aren't installed system-wide in QGIS, e.g.
when the user does not have permission to install fonts on a system.
2022-06-20 13:01:55 +10:00
Nyall Dawson
d4ef3e3c3d Make sure QgsFontManager methods are thread safe 2022-06-20 13:01:55 +10:00
Nyall Dawson
607b140c30 Add method to process a font family name and apply any matching
replacements
2022-06-20 13:01:55 +10:00
Nyall Dawson
3d7310b65c Persist font replacements across sessions 2022-06-20 13:01:55 +10:00
Nyall Dawson
0091696272 Start on QgsFontManager class 2022-06-20 13:01:55 +10:00
Nyall Dawson
9de1920302 Add option for "forced bold" and "force italic" to QgsTextFormat
Unlike setting a font's style via setNamedStyle(), these settings
will ensure that a font is always rendered in bold or italic regardless
of whether the font family actually has a bold or italic variant. A
"faux bold" or slanted text effect will be emulated by Qt, which may
result in poor quality font rendering.

(For this reason it is greatly preferred to call setNamedStyle() instead.)

This API is being added so that QgsTextFormat/QgsTextRenderer can
replicate the same font behaviour as the base QFont/QPainter classes
do, where faux bold/italic effects are possible.

(It's not exposed anywhere for user control!)
2022-04-26 10:56:28 +10:00
Nyall Dawson
fadfb477d9 [api] Move text wrapping handling logic from layout table code to QgsTextRenderer
Allows other users of QgsTextRenderer to take advantage of the
automatic line wrapping behaviour
2021-11-29 13:03:13 +10:00
Nyall Dawson
730cd7e23a [feature] Add "stretch" setting for labels and text formats
Allows text to be horizontally stretched or condensed by a %
factor. Handy for tweaking the widths of fonts to fit a bit
of extra text into labels (when used sparingly, that is...
you can certainly abuse font stretching with some horrendous
results!)

Requires Qt 6.3+ or KDE's 5.15 fork

Thanks for KDAB for fixing the upstream issues blocking this!
2021-11-09 14:58:14 +11:00
Nyall Dawson
dae69acc76 [feature] Support Small Caps style in labels/text renderer
Adds two new capitalization styles for labels and text symbols:

- Small Caps: Renders lowercase characters as small caps
- All Small Caps: Renders all characters as small caps (regardless
of their original case)

Requires Qt 6.3+, or Qt 5.15 using KDE's fork and the cmake
HAS_KDE_QT5_SMALL_CAPS_FIX switch defined during build.
2021-11-08 14:36:44 +11:00
Nyall Dawson
7c75c4cd7f Never try to create/render 0 pixel sized fonts
This throws Qt warnings, and results in large fonts being created
when they actually should be invisible
2021-08-19 05:58:08 +10:00
Nyall Dawson
711a615be3 Fix raises sphinx format 2021-06-25 10:50:04 +10:00
Nyall Dawson
bb0dfb6ba3 Doxygen says no 2021-06-10 11:03:43 +10:00
Nyall Dawson
49e48f9383 Better approach to avoid duplicate docs 2021-06-10 11:03:43 +10:00
Nyall Dawson
4ff3f447dc Don't try to insert links in raises blocks in PyQGIS docs
These aren't formatted correctly if we do
2021-06-10 11:03:43 +10:00
Nyall Dawson
8359281012 Fix formatting of exception blocks in PyQGIS docs 2021-06-10 11:03:43 +10:00
Nyall Dawson
22c2d7213b Remove unnecessary includes of qgssymbollayerreference.h 2021-05-24 12:16:21 +10:00
Mathieu Pellerin
65ba35921a Address review 2021-05-04 13:12:45 +07:00
Mathieu Pellerin
672d53e5fe Handle data defined properties upgrade when reading pre-3.20 project files 2021-05-04 11:57:28 +07:00
Mathieu Pellerin
4fad4bac0f [feature][labeling] Use fill symbols to render rectangle,square,circle,ellipse background shields 2021-05-04 11:57:28 +07:00
Nyall Dawson
e5c709ccd6 [api] Provide a mechanism to specify a list of fallback font families for
QgsTextFormat

Just like in CSS, these families will be used as an ordered list
of fonts to fallback on if the actual text format font isn't available
on a particular QGIS install.

This is API only, and isn't designed to be shown anywhere in QGIS.
Instead the intended use is for creators of QGIS styles to either use
the raw api to specify the list of fallback fonts OR hand edit the
style xml to add the fallback fonts, e.g by adding a block like:

    <families>
      <family name="Arial"/>
      <family name="Helvetica"/>
      <family name="Sans"/>
    </families>

To the "text-style" parent element.
2021-04-22 16:39:24 +10:00