59 Commits

Author SHA1 Message Date
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
Nyall Dawson
832d5e95ee Cleanup and refactor calculationg of label text metrics for curved
labels, and move methods for calculating curved text placement
out of PAL so that they can be reused elsewhere
2021-04-08 14:26:05 +10:00
Denis Rouzaud
ba8a445850 run sipify 2021-03-22 21:13:52 +01:00
Nyall Dawson
50b9beaad6 [sipify] Catch more class references and insert :py:class: annotations 2021-01-31 05:41:22 +10:00
Nyall Dawson
620948f809 Add method to change capitalization of QgsTextDocument 2020-09-21 12:05:54 +10:00
Nyall Dawson
484ba6f979 [labeling] Add a new capitalization option for "Title Case", and
rename the confusing "Capitalize First Letter" option to
"Force First Letter to Capital"

This change is intended to clarify the role of the "capitalize
first letter" option, and to provide an option which actually
does what users expect the "capitalize first letter" option
to do.

Fixes #16539
2020-09-17 09:33:51 +10:00
Nyall Dawson
51d8ad75c5 Don't modify text format paint effects in place
Avoids race conditions when multiple threads are rendering the same
text format which contains paint effects

Fixes #37938
2020-07-27 07:36:50 +10:00
Nyall Dawson
ac5a7226ee Add equality operator for QgsTextFormat 2020-07-14 11:23:33 +10:00
Nyall Dawson
9bad5578cf Equality operator for QgsTextShadowSettings 2020-07-14 11:23:33 +10:00
Nyall Dawson
52d7d1886a Add an equality operator for QgsTextMaskSettings 2020-07-14 11:23:33 +10:00
Nyall Dawson
305fa330bd Add equality operator for QgsTextBufferSettings 2020-07-14 11:23:33 +10:00
Nyall Dawson
7547dbd464 Equality operator for QgsTextBackgroundSettings 2020-07-14 11:23:33 +10:00
Nyall Dawson
c575b827bf Add an invalid state to QgsTextFormat
Allows determining whether the QgsTextFormat is a default constructed
object, which should represent a not set/default settings value.
2020-07-14 11:23:33 +10:00
Nyall Dawson
b584f93afb Expose text format override options to table editor widget 2020-07-13 06:00:05 +10:00
Nyall Dawson
52f774158e Add method to convert a QgsTextBlock to plain text 2020-07-09 13:23:20 +10:00
Nyall Dawson
49a3c1047e code cleanup 2020-07-09 13:23:20 +10:00
Nyall Dawson
77dfaae688 Add QgsTextRenderer methods to convert Qt alignment flags 2020-07-09 13:23:20 +10:00
Nyall Dawson
573e46b671 Add a character based text height calculation method to QgsTextRenderer 2020-07-08 17:00:39 +10:00
Nyall Dawson
a49cb7c9f3 [api] Add vertical alignment control to QgsTextRenderer 2020-07-08 08:49:57 +10:00
Nyall Dawson
0dd1490fdc [api] Apply a font scale workaround factor to QgsTextRenderer
This is a hack which has been in place in layouts/composer for a long
time in order to provide more consistent and reliable text rendering
at small font sizes or when "zoomed out". Without this hack the font
rendering and metric based calculations for these small font sizes
can be unstable, leading to font sizes "jumping" around as a layout
is zoomed into or out of.
2020-07-08 08:49:57 +10:00
Nyall Dawson
81a9db9f57 [sipify] Fix creation of cross references 2020-06-15 13:43:58 +10:00
Nyall Dawson
cedd73ee4d More list formatting fixes 2020-06-13 16:49:14 +10:00
Nyall Dawson
8fb8e45d51 Ensure that fields required by marker symbol backgrounds for labels
are fetched when rendering

Fixes #36944
2020-06-05 08:53:06 +10:00
Nyall Dawson
f2b03a8334 Doxygen test fixes 2020-05-12 19:21:39 +10:00