-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
Fix automatic font download on Windows #57844
Conversation
@agiudiceandrea can you test this build please? |
@nyalldawson, unfortunately the issue still occurs using this MinGW64 Windows Build on my Windows 10 system. Same behavior and error messages except for the one in the tab "General" of the Log Messages panel which is the following one using this build: while it is the following one using QGIS 3.38.0 or a previous MinGW64 Windows Build The connection log seems the same as before. {
"Bytes Received": 0,
"Bytes Total": 0,
"Cache (control)": "Load from cache if available, otherwise load from network",
"Cache (save)": "Can store result in cache",
"Headers": {
"User-Agent": "Mozilla/5.0 QGIS/33900/Windows 10 Version 1903"
},
"ID": "src/core/textrenderer/qgsfontmanager.cpp:2104 (run)",
"Initiator": "QgsFontDownloadTask",
"Operation": "GET",
"Replies": 1,
"Reply": {
"Cache (result)": "Read from network",
"Headers": {
"Access-Control-Allow-Origin": "",
"Cache-Control": "no-cache",
"Content-Length": "0",
"Content-Security-Policy": "default-src 'none'; base-uri 'self'; child-src github.com/assets-cdn/worker/ gist.github.com/assets-cdn/worker/; connect-src 'self' uploads.github.com www.githubstatus.com collector.github.com raw.githubusercontent.com api.github.com github-cloud.s3.amazonaws.com github-production-repository-file-5c1aeb.s3.amazonaws.com github-production-upload-manifest-file-7fdce7.s3.amazonaws.com github-production-user-asset-6210df.s3.amazonaws.com api.githubcopilot.com objects-origin.githubusercontent.com copilot-proxy.githubusercontent.com/v1/engines/github-completion/completions *.actions.githubusercontent.com wss://*.actions.githubusercontent.com productionresultssa0.blob.core.windows.net/ productionresultssa1.blob.core.windows.net/ productionresultssa2.blob.core.windows.net/ productionresultssa3.blob.core.windows.net/ productionresultssa4.blob.core.windows.net/ productionresultssa5.blob.core.windows.net/ productionresultssa6.blob.core.windows.net/ productionresultssa7.blob.core.windows.net/ productionresultssa8.blob.core.windows.net/ productionresultssa9.blob.core.windows.net/ productionresultssa10.blob.core.windows.net/ productionresultssa11.blob.core.windows.net/ productionresultssa12.blob.core.windows.net/ productionresultssa13.blob.core.windows.net/ productionresultssa14.blob.core.windows.net/ productionresultssa15.blob.core.windows.net/ productionresultssa16.blob.core.windows.net/ productionresultssa17.blob.core.windows.net/ productionresultssa18.blob.core.windows.net/ productionresultssa19.blob.core.windows.net/ github-production-repository-image-32fea6.s3.amazonaws.com github-production-release-asset-2e65be.s3.amazonaws.com insights.github.com wss://alive.github.com; font-src github.githubassets.com; form-action 'self' github.com gist.github.com copilot-workspace.githubnext.com objects-origin.githubusercontent.com; frame-ancestors 'none'; frame-src viewscreen.githubusercontent.com notebooks.githubusercontent.com; img-src 'self' data: blob: github.githubassets.com media.githubusercontent.com camo.githubusercontent.com identicons.github.com avatars.githubusercontent.com github-cloud.s3.amazonaws.com objects.githubusercontent.com secured-user-images.githubusercontent.com/ user-images.githubusercontent.com/ private-user-images.githubusercontent.com opengraph.githubassets.com github-production-user-asset-6210df.s3.amazonaws.com customer-stories-feed.github.com spotlights-feed.github.com objects-origin.githubusercontent.com *.githubusercontent.com; manifest-src 'self'; media-src github.com user-images.githubusercontent.com/ secured-user-images.githubusercontent.com/ private-user-images.githubusercontent.com github-production-user-asset-6210df.s3.amazonaws.com gist.github.com; script-src github.githubassets.com; style-src 'unsafe-inline' github.githubassets.com; upgrade-insecure-requests; worker-src github.com/assets-cdn/worker/ gist.github.com/assets-cdn/worker/",
"Content-Type": "text/html; charset=utf-8",
"Date": "Mon, 24 Jun 2024 05:18:27 GMT",
"Location": "https://raw.githubusercontent.com/google/fonts/main/ofl/opensans/OpenSans%5Bwdth%2Cwght%5D.ttf",
"Referrer-Policy": "no-referrer-when-downgrade",
"Server": "GitHub.com",
"Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload",
"Vary": "X-PJAX, X-PJAX-Container, Turbo-Visit, Turbo-Frame, Accept-Encoding, Accept, X-Requested-With",
"X-Content-Type-Options": "nosniff",
"X-Frame-Options": "deny",
"X-GitHub-Request-Id": "DC84:C1F32:79583F7:7C42406:667901A3",
"X-XSS-Protection": "0"
},
"Status": "302"
},
"Thread": "0x000001fa1d6b46c0",
"Total time (ms)": 604,
"URL": "https://github.com/google/fonts/raw/main/ofl/opensans/OpenSans[wdth,wght].ttf"
},
{
"Bytes Received": 0,
"Bytes Total": 532636,
"Cache (control)": "Load from cache if available, otherwise load from network",
"Cache (save)": "Can store result in cache",
"Headers": {
"User-Agent": "Mozilla/5.0 QGIS/33900/Windows 10 Version 1903"
},
"Initiator": "unknown",
"Operation": "GET",
"Replies": 2,
"Reply": {
"Cache (result)": "Used entry from cache",
"Headers": {
"Accept-Ranges": "bytes",
"Access-Control-Allow-Origin": "*",
"Content-Length": "532636",
"Content-Security-Policy": "default-src 'none'; style-src 'unsafe-inline'; sandbox",
"Content-Type": "application/octet-stream",
"Cross-Origin-Resource-Policy": "cross-origin",
"Date": "Mon, 24 Jun 2024 05:14:51 GMT",
"ETag": "W/\"43cfa2ae7e736f491a167297b214d2e2bd8ae764313cdb2553062beb70a63dbc\"",
"Expires": "Mon, 24 Jun 2024 05:19:52 GMT",
"Source-Age": "0",
"Strict-Transport-Security": "max-age=31536000",
"Vary": "Authorization,Accept-Encoding,Origin",
"Via": "1.1 varnish",
"X-Cache": "HIT",
"X-Cache-Hits": "0",
"X-Content-Type-Options": "nosniff",
"X-Fastly-Request-ID": "284afb8cd5c5677a6df346c54154eb7365ea604c",
"X-Frame-Options": "deny",
"X-GitHub-Request-Id": "A470:3EDA21:163C47A:1758176:6678B2B3",
"X-Served-By": "cache-lin1730061-LIN",
"X-Timer": "S1719206092.931865,VS0,VE147",
"X-XSS-Protection": "1; mode=block"
},
"Status": "200"
},
"Thread": "0x000001fa1d6b46c0",
"Total time (ms)": 5,
"URL": "https://raw.githubusercontent.com/google/fonts/main/ofl/opensans/OpenSans%5Bwdth%2Cwght%5D.ttf"
},
{
"Bytes Received": 0,
"Bytes Total": 0,
"Cache (control)": "Load from cache if available, otherwise load from network",
"Cache (save)": "Can store result in cache",
"Headers": {
"User-Agent": "Mozilla/5.0 QGIS/33900/Windows 10 Version 1903"
},
"ID": "src/core/textrenderer/qgsfontmanager.cpp:2104 (run)",
"Initiator": "QgsFontDownloadTask",
"Operation": "GET",
"Replies": 1,
"Reply": {
"Cache (result)": "Read from network",
"Headers": {
"Access-Control-Allow-Origin": "",
"Cache-Control": "no-cache",
"Content-Length": "0",
"Content-Security-Policy": "default-src 'none'; base-uri 'self'; child-src github.com/assets-cdn/worker/ gist.github.com/assets-cdn/worker/; connect-src 'self' uploads.github.com www.githubstatus.com collector.github.com raw.githubusercontent.com api.github.com github-cloud.s3.amazonaws.com github-production-repository-file-5c1aeb.s3.amazonaws.com github-production-upload-manifest-file-7fdce7.s3.amazonaws.com github-production-user-asset-6210df.s3.amazonaws.com api.githubcopilot.com objects-origin.githubusercontent.com copilot-proxy.githubusercontent.com/v1/engines/github-completion/completions *.actions.githubusercontent.com wss://*.actions.githubusercontent.com productionresultssa0.blob.core.windows.net/ productionresultssa1.blob.core.windows.net/ productionresultssa2.blob.core.windows.net/ productionresultssa3.blob.core.windows.net/ productionresultssa4.blob.core.windows.net/ productionresultssa5.blob.core.windows.net/ productionresultssa6.blob.core.windows.net/ productionresultssa7.blob.core.windows.net/ productionresultssa8.blob.core.windows.net/ productionresultssa9.blob.core.windows.net/ productionresultssa10.blob.core.windows.net/ productionresultssa11.blob.core.windows.net/ productionresultssa12.blob.core.windows.net/ productionresultssa13.blob.core.windows.net/ productionresultssa14.blob.core.windows.net/ productionresultssa15.blob.core.windows.net/ productionresultssa16.blob.core.windows.net/ productionresultssa17.blob.core.windows.net/ productionresultssa18.blob.core.windows.net/ productionresultssa19.blob.core.windows.net/ github-production-repository-image-32fea6.s3.amazonaws.com github-production-release-asset-2e65be.s3.amazonaws.com insights.github.com wss://alive.github.com; font-src github.githubassets.com; form-action 'self' github.com gist.github.com copilot-workspace.githubnext.com objects-origin.githubusercontent.com; frame-ancestors 'none'; frame-src viewscreen.githubusercontent.com notebooks.githubusercontent.com; img-src 'self' data: blob: github.githubassets.com media.githubusercontent.com camo.githubusercontent.com identicons.github.com avatars.githubusercontent.com github-cloud.s3.amazonaws.com objects.githubusercontent.com secured-user-images.githubusercontent.com/ user-images.githubusercontent.com/ private-user-images.githubusercontent.com opengraph.githubassets.com github-production-user-asset-6210df.s3.amazonaws.com customer-stories-feed.github.com spotlights-feed.github.com objects-origin.githubusercontent.com *.githubusercontent.com; manifest-src 'self'; media-src github.com user-images.githubusercontent.com/ secured-user-images.githubusercontent.com/ private-user-images.githubusercontent.com github-production-user-asset-6210df.s3.amazonaws.com gist.github.com; script-src github.githubassets.com; style-src 'unsafe-inline' github.githubassets.com; upgrade-insecure-requests; worker-src github.com/assets-cdn/worker/ gist.github.com/assets-cdn/worker/",
"Content-Type": "text/html; charset=utf-8",
"Date": "Mon, 24 Jun 2024 05:18:28 GMT",
"Location": "https://raw.githubusercontent.com/google/fonts/main/ofl/opensans/OpenSans-Italic%5Bwdth%2Cwght%5D.ttf",
"Referrer-Policy": "no-referrer-when-downgrade",
"Server": "GitHub.com",
"Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload",
"Vary": "X-PJAX, X-PJAX-Container, Turbo-Visit, Turbo-Frame, Accept-Encoding, Accept, X-Requested-With",
"X-Content-Type-Options": "nosniff",
"X-Frame-Options": "deny",
"X-GitHub-Request-Id": "DC84:C1F32:7958566:7C4259E:667901A3",
"X-XSS-Protection": "0"
},
"Status": "302"
},
"Thread": "0x000001fa1d6b46c0",
"Total time (ms)": 490,
"URL": "https://github.com/google/fonts/raw/main/ofl/opensans/OpenSans-Italic[wdth,wght].ttf"
},
{
"Bytes Received": 0,
"Bytes Total": 583992,
"Cache (control)": "Load from cache if available, otherwise load from network",
"Cache (save)": "Can store result in cache",
"Headers": {
"User-Agent": "Mozilla/5.0 QGIS/33900/Windows 10 Version 1903"
},
"Initiator": "unknown",
"Operation": "GET",
"Replies": 2,
"Reply": {
"Cache (result)": "Used entry from cache",
"Headers": {
"Accept-Ranges": "bytes",
"Access-Control-Allow-Origin": "*",
"Content-Length": "583992",
"Content-Security-Policy": "default-src 'none'; style-src 'unsafe-inline'; sandbox",
"Content-Type": "application/octet-stream",
"Cross-Origin-Resource-Policy": "cross-origin",
"Date": "Mon, 24 Jun 2024 05:14:52 GMT",
"ETag": "W/\"979e5b9b35593a390672afe0163c0c5a9f91f04285006fcb10e391cace5195c6\"",
"Expires": "Mon, 24 Jun 2024 05:19:52 GMT",
"Source-Age": "0",
"Strict-Transport-Security": "max-age=31536000",
"Vary": "Authorization,Accept-Encoding,Origin",
"Via": "1.1 varnish",
"X-Cache": "HIT",
"X-Cache-Hits": "0",
"X-Content-Type-Options": "nosniff",
"X-Fastly-Request-ID": "c8b53be74f7c740479ff9757afb9aff36224aa43",
"X-Frame-Options": "deny",
"X-GitHub-Request-Id": "FD4F:1C9D7F:F384A0:FF09B1:6678B2B4",
"X-Served-By": "cache-lin1730061-LIN",
"X-Timer": "S1719206093.656403,VS0,VE150",
"X-XSS-Protection": "1; mode=block"
},
"Status": "200"
},
"Thread": "0x000001fa1d6b46c0",
"Total time (ms)": 7,
"URL": "https://raw.githubusercontent.com/google/fonts/main/ofl/opensans/OpenSans-Italic%5Bwdth%2Cwght%5D.ttf"
},
{
"Bytes Received": 0,
"Bytes Total": 0,
"Cache (control)": "Load from cache if available, otherwise load from network",
"Cache (save)": "Can store result in cache",
"Headers": {
"User-Agent": "Mozilla/5.0 QGIS/33900/Windows 10 Version 1903"
},
"ID": "src/core/textrenderer/qgsfontmanager.cpp:2129 (run)",
"Initiator": "QgsFontDownloadTask",
"Operation": "GET",
"Replies": 1,
"Reply": {
"Cache (result)": "Read from network",
"Headers": {
"Access-Control-Allow-Origin": "",
"Cache-Control": "no-cache",
"Content-Length": "0",
"Content-Security-Policy": "default-src 'none'; base-uri 'self'; child-src github.com/assets-cdn/worker/ gist.github.com/assets-cdn/worker/; connect-src 'self' uploads.github.com www.githubstatus.com collector.github.com raw.githubusercontent.com api.github.com github-cloud.s3.amazonaws.com github-production-repository-file-5c1aeb.s3.amazonaws.com github-production-upload-manifest-file-7fdce7.s3.amazonaws.com github-production-user-asset-6210df.s3.amazonaws.com api.githubcopilot.com objects-origin.githubusercontent.com copilot-proxy.githubusercontent.com/v1/engines/github-completion/completions *.actions.githubusercontent.com wss://*.actions.githubusercontent.com productionresultssa0.blob.core.windows.net/ productionresultssa1.blob.core.windows.net/ productionresultssa2.blob.core.windows.net/ productionresultssa3.blob.core.windows.net/ productionresultssa4.blob.core.windows.net/ productionresultssa5.blob.core.windows.net/ productionresultssa6.blob.core.windows.net/ productionresultssa7.blob.core.windows.net/ productionresultssa8.blob.core.windows.net/ productionresultssa9.blob.core.windows.net/ productionresultssa10.blob.core.windows.net/ productionresultssa11.blob.core.windows.net/ productionresultssa12.blob.core.windows.net/ productionresultssa13.blob.core.windows.net/ productionresultssa14.blob.core.windows.net/ productionresultssa15.blob.core.windows.net/ productionresultssa16.blob.core.windows.net/ productionresultssa17.blob.core.windows.net/ productionresultssa18.blob.core.windows.net/ productionresultssa19.blob.core.windows.net/ github-production-repository-image-32fea6.s3.amazonaws.com github-production-release-asset-2e65be.s3.amazonaws.com insights.github.com wss://alive.github.com; font-src github.githubassets.com; form-action 'self' github.com gist.github.com copilot-workspace.githubnext.com objects-origin.githubusercontent.com; frame-ancestors 'none'; frame-src viewscreen.githubusercontent.com notebooks.githubusercontent.com; img-src 'self' data: blob: github.githubassets.com media.githubusercontent.com camo.githubusercontent.com identicons.github.com avatars.githubusercontent.com github-cloud.s3.amazonaws.com objects.githubusercontent.com secured-user-images.githubusercontent.com/ user-images.githubusercontent.com/ private-user-images.githubusercontent.com opengraph.githubassets.com github-production-user-asset-6210df.s3.amazonaws.com customer-stories-feed.github.com spotlights-feed.github.com objects-origin.githubusercontent.com *.githubusercontent.com; manifest-src 'self'; media-src github.com user-images.githubusercontent.com/ secured-user-images.githubusercontent.com/ private-user-images.githubusercontent.com github-production-user-asset-6210df.s3.amazonaws.com gist.github.com; script-src github.githubassets.com; style-src 'unsafe-inline' github.githubassets.com; upgrade-insecure-requests; worker-src github.com/assets-cdn/worker/ gist.github.com/assets-cdn/worker/",
"Content-Type": "text/html; charset=utf-8",
"Date": "Mon, 24 Jun 2024 05:18:28 GMT",
"Location": "https://raw.githubusercontent.com/google/fonts/main/ofl/opensans/OFL.txt",
"Referrer-Policy": "no-referrer-when-downgrade",
"Server": "GitHub.com",
"Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload",
"Vary": "X-PJAX, X-PJAX-Container, Turbo-Visit, Turbo-Frame, Accept-Encoding, Accept, X-Requested-With",
"X-Content-Type-Options": "nosniff",
"X-Frame-Options": "deny",
"X-GitHub-Request-Id": "DC84:C1F32:79586D1:7C426FF:667901A4",
"X-XSS-Protection": "0"
},
"Status": "302"
},
"Thread": "0x000001fa1d6b46c0",
"Total time (ms)": 487,
"URL": "https://github.com/google/fonts/raw/main/ofl/opensans/OFL.txt"
},
{
"Bytes Received": 0,
"Bytes Total": 0,
"Cache (control)": "Load from cache if available, otherwise load from network",
"Cache (save)": "Can store result in cache",
"Headers": {
"User-Agent": "Mozilla/5.0 QGIS/33900/Windows 10 Version 1903"
},
"Initiator": "unknown",
"Operation": "GET",
"Replies": 2,
"Reply": {
"Cache (result)": "Used entry from cache",
"Headers": {
"Accept-Ranges": "bytes",
"Access-Control-Allow-Origin": "*",
"Content-Encoding": "gzip",
"Content-Security-Policy": "default-src 'none'; style-src 'unsafe-inline'; sandbox",
"Content-Type": "text/plain; charset=utf-8",
"Cross-Origin-Resource-Policy": "cross-origin",
"Date": "Mon, 24 Jun 2024 05:14:53 GMT",
"ETag": "W/\"9eb464e7bdc26b365f9cc1f4ad0f51128a9706a6cb834b452297943726bedec8\"",
"Expires": "Mon, 24 Jun 2024 05:19:53 GMT",
"Source-Age": "0",
"Strict-Transport-Security": "max-age=31536000",
"Vary": "Authorization,Accept-Encoding,Origin",
"Via": "1.1 varnish",
"X-Cache": "HIT",
"X-Cache-Hits": "0",
"X-Content-Type-Options": "nosniff",
"X-Fastly-Request-ID": "986d225ac857cac3213ce2dbbab349718c6ef9bf",
"X-Frame-Options": "deny",
"X-GitHub-Request-Id": "4EF4:F6521:148612A:1590DD6:6678B2B4",
"X-Served-By": "cache-lin1730061-LIN",
"X-Timer": "S1719206094.518435,VS0,VE134",
"X-XSS-Protection": "1; mode=block"
},
"Status": "200"
},
"Thread": "0x000001fa1d6b46c0",
"Total time (ms)": 4,
"URL": "https://raw.githubusercontent.com/google/fonts/main/ofl/opensans/OFL.txt"
} |
1dec24e
to
f420487
Compare
Thanks @agiudiceandrea -- can you test with the updated version? |
Using the new build the issue still occurs. The only difference compared to the previous build is that the message in the tab "General" of the Log Messages panel is now: |
@agiudiceandrea ok. I suggest we merge this and then test on the nightlies. Maybe it's a mingw issue. |
A random_name.ttf file of 532636 bytes (provided here in a zip archive GUqNdY.zip because .ttf files cannot be attached to a comment) is actually created in the |
That's expected. We then try to open it as a font, and if that fails, we open as a zip. From my tests qt on windows required ttf as the extension for this to work, which is what this pr addresses. |
When the .ttf file is added in the QGIS/src/core/textrenderer/qgsfontmanager.cpp Line 1930 in 2fb1de2
the returned id is -1
Anyway, in the Python console, the same instruction correctly returns the value sourcePath = "C:/Users/Andrea/AppData/Local/Temp/GUqNdY.ttf"
id = QFontDatabase.addApplicationFont( sourcepath )
print(id)
2 |
@agiudiceandrea ok, let's see if this |
@nyalldawson, using the latest MinGW64 Windows Build the the warning message The Anyway, previously the fonts folder contained about 38 font files with the .ttf extension and more meaningful names |
@agiudiceandrea there's only two files available from Google Fonts -- see https://github.com/google/fonts/tree/main/ofl/opensans . I'm not sure where the others came from. |
@nyalldawson, they were previously downloaded by QGIS from https://fonts.google.com/download?family=Open+Sans |
@agiudiceandrea that's what I mean -- the GitHub repo is supposed to be the source of those files, so I'm not sure where they come from. |
It looks like the two files Such Perhaps the repo https://github.com/googlefonts/opensans/ may be used instead of https://github.com/google/fonts/tree/main/ofl/opensans. |
@agiudiceandrea ok, I propose that we merge this pr as it fixes the issue for the majority of fonts. Then extra logic could potentially be added later if we want to use different sources for individual fonts. |
ok |
The backport to
stderr
stdout
To backport manually, run these commands in your terminal: # Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add .worktrees/backport-queued_ltr_backports queued_ltr_backports
# Navigate to the new working tree
cd .worktrees/backport-queued_ltr_backports
# Create a new branch
git switch --create backport-57844-to-queued_ltr_backports
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick f4204877541538b817e5182a9e4799b871dc2f26,2fd8813c44ef0f03deace4f7c6581d9f4ef0da80
# Push it to GitHub
git push --set-upstream origin backport-57844-to-queued_ltr_backports
# Go back to the original working tree
cd ../..
# Delete the working tree
git worktree remove .worktrees/backport-queued_ltr_backports Then, create a pull request where the |
For a future enhancement: all the 38 font files of the "Open Sans" family previously directly downloaded by QGIS in a zip file from https://fonts.google.com/download?family=Open+Sans can be directly downloaded using the json file directly downloadable from https://fonts.google.com/download/list?family=Open+Sans which lists each font file and the corresponding URL from which it can be downloaded. Can't we directly host the zip file containing all the 38 "Open Sans" font files of the "Open Sans" family and make QGIS download it from there? |
No description provided.