I'm 99.9% certain I have this right, but for some reason it isn't working.
I'm making a chrome extension that injects CSS onto a page, and my CSS has been working fine right up until I wanted to change the fonts.
So my manifest has this...
"css": ["css/my-custom.css"],
"js": [ "js/jquery.js", "js/my-custom.js", "js/jquery.cookie.js"],
"web_accessible_resources": ["css/my-custom.css", "fonts/Roboto-Regular.ttf", "images/*.*"]
...and my CSS has this...
@font-face {
font-family: 'RobotoLtRegular';
src: url('chrome-extension://__MSG_@@extension_id__/fonts/Roboto-Regular.ttf');
font-weight: normal;
font-style: normal;
}
body {
background: #f1f1f1 !important;
font-size: 1.2em !important;
font-family: RobotoLtRegular !important;
}
p {
font-family: RobotoLtRegular !important;
}
...and yet when I reload my extension I don't see the new font. The chrome element inspector also shows that this font should be the one shown on body and p (there are no other fonts overriding RobotoLtRegular.
FYI my fonts are stored in the css directory of the extension, so the path is correct.
I'm at a complete loss.
Any suggestions would be helpful.
UPDATE: If it helps to know, I am loading it as an unpacked extension.
Go to Control Panel > Appearance and Personalization > Display > Adjust ClearType text (on the left). Check the box entitled “Turn on ClearType.” After going through a short wizard, this will fix some of the text rendering issues in Chrome. Enable "Disable accelerated 2D Canvas" in Chrome.
With over one million downloads on the Chrome Web Store, you just can't go wrong with WhatFont. The extension does what it does best, which is to identify fonts quickly and efficiently. Just click on the WhatFont extension icon, and point the cursor at a word.
Head to More tools > Extensions. Use the toggle for each extension to turn it off. Restart Chrome and go back to the extensions list. Re-enable the extensions.
The solution was to add web_accessible_resources into the manifest (works for manifest version 2):
"web_accessible_resources": ["*.ttf" ]
To include any other file types you can comma separate them as such:
"web_accessible_resources": [ "*.png", "*.ttf" ]
Works perfectly.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With