Skip to content

Fix: allow Roboto fonts to load and apply correctly from GoogleFonts static site #131

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

AndrewStopchenko-SO
Copy link

Problem

Extension's main window was not able to load the Roboto fonts because they are supplied from the https://fonts.gstatic.com site, which wasn't satisfying the Content Security Policy's default-src; directive.
A bunch of errors similar to the one below were thrown to the VSCode's Developer Tools console:
Refused to load the font 'https://fonts.gstatic.com/s/roboto/v47/KFO7CnqEu92Fr1ME7kSn66aGLdTylUAMa3KUBGEe.woff2' because it violates the following Content Security Policy directive: "default-src ". Note that 'font-src' was not explicitly set, so 'default-src' is used as a fallback.
As a result, extension was falling back to the Arial font:
image

Fix

Add the font-src 'self' https://fonts.gstatic.com CSP directive.

After the change, Roboto font is downloaded and applied correctly, and no font-related errors appear on the VSCode Dev Tools console:
image

Update CSP directives to include font-src which allows access to the `https://fonts.gstatic.com` - this is where the Roboto Google font gets downloaded from.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant