-
Notifications
You must be signed in to change notification settings - Fork 12.2k
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
Strange/Weird characters on refresh (Self-hosted CSS compiled from SCSS) #17644
Comments
Hi! Thanks for being part of the Font Awesome Community. Are you using self-hosted icons? |
@tagliala yes we are! Thanks for the quick response :) |
Could you please try with the Pro CDN (not the kit, just the link to the plain css) and attempt to reproduce? |
Hi @templeman15
I just read and realised that it was a screenshot of the According to the Sass library used by your application, you may have wrong CSS results: |
Hello @tagliala! Here is the output served from the app (this is when the page loads correctly): Here is the output css from the browser (this is when the strange character occurs): |
Ok, thanks. Please switch to a different Sass implementation, make sure that your CSS output contains properly encoded characters Meanwhile, closing here |
@tagliala I am also seeing this behavior intermittently. Can you clarify: is there an issue using fontawesome with dart-sass? |
After some more investigation, this might be due to us setting |
Not with Font Awesome. There are some issues with escaping with some versions of Dart Sass, please take another look at #17644 (comment) There is no Font Awesome involved in this simple snippet: .search-icon {
&::before {
content: "\f002";
}
} If the content is compiled into Font-Awesome/css/fontawesome.css Lines 3396 to 3397 in fcec2d1
You should not use that value for Font Icons: GoogleChrome/lighthouse#10127 |
Hi @dkniffin I've investigated and
Yes, there might be, in the case that a Font Awesome SCSS compiled to CSS with Dart Sass or Ruby Sass is not correctly interpreted as UTF-8 by the browser. Although this may be considered a browser issue, I think that we should do our best to prevent it and provide ASCII output. This will be hopefully fixed (again) in FA v6. I'm going to reopen this issue for tracking purposes Since this will be a breaking change in v5, so I don't know what the team will decide. The workaround is to override all the Ref:
Reference fix: /* _mixins.scss */
@function fa-content($fa-var){
@return unquote("\"") + unquote(str-insert($fa-var, "\\", 1)) + unquote("\"");
}
/* _variables.scss */
$fa-var-500px: f26e; |
The breaking change happened between dart-sass 1.10.4 and 1.11.0, but I can't bisect to the specific change because I do not have a proper dart build system. Ruby Sass 3.7.4 is also affected and the breaking change happened between 3.6.0 and 3.7.0 SassC 2.4.0 is not affected I guess this is the change: https://github.com/sass/sass/blob/master/accepted/identifier-escapes.md |
Solutionif you have PUA codes (e.g.,
|
FWIW, I still see the odd characters with FA With disclaimer about my limited browser internals knowledge, could it be a timing issue, where the font svg/wolff/ttf file isn't loading in time before the HTML renders the page? |
I don't know and I don't think so. Will try to simulate this |
I had this problem for so long and apparently I got rid of it by adding Disclaimer: I don't use FontAwesome. I'm using the Inter font with their CSS import rules and CDN. I was searching about the issue and ended up here. Placed it right at the beginning of my CSS, just before the import font url. Tested it plenty of times with different scenarios and I don't get the weird characters anymore. Everything works great. |
Thanks for this heads-up |
Any luck with the 1.54.0 update in sass? The change appears to be the same of the 1.39.0 that was supposed to fix this, but maybe it works this time? https://github.com/sass/dart-sass/blob/main/CHANGELOG.md#1540 |
There is a partial fix in 1.38.0, as per #17644 (comment) I can confirm that in 1.55.0 this issue has been partially fixed, in the meaning that codes in the private area are correctly escaped, letters and numbers aren't (would this be a problem? 🤷🏻♂️), and I can't see unescaped unicode characters in the output CSS, so the
Partial output: .fa-at::before {
content: "\@";
}
/* ... */
.fa-0::before {
content: "\30 ";
}
/* ... */
.fa-p::before {
content: "P";
}
/* ... */
.fa-snowflake::before {
content: "\f2dc";
} Anyway, adding the |
@viniciusdeliz I updated sass to version 1.54.0 on July 30th (currently my version is 1.55.0), and since then I've already encountered the weird characters on refresh, several times, randomly. So, on my side, the issue is still not fixed, but it seems that the problem occurs less often than before (maybe it's just an impression).
@tagliala I agree with you: a Font Awesome's fix is still needed for this issue. 👍 |
I've hit this one using parcel: parcel-bundler/parcel#8713 |
I noticed that the css file doesn't get interpreted as css, so I investigated deeper into it. Opening up the debugger tools reproduced it consistently, so that was the first clue. I had a theory that Following
Now https://cachix.org will finally not get garbled fonts 🚀 |
Found that post that was exactly my problem : encoding mixin error with libsass |
For others, facing the same issue: The problem with displaying the icons incorrectly when contained in unicode characters is Chrome related and happens only in Chrome and other Chromium based browsers (e.g. Edge or Vivaldi). I could not reproduce it on Firefox or Safari. It is not related to FontAwesome, it is related to all Iconfonts using unicode. (Im my case my own font) It can even be reproduced regularly the following way:
It works only once, if you want to repeat, you need to close the developer tools, reload the page, then reopen the developer tools again and reload again. It seems, that chrome does not check or detect the format of the CSS correctly when the page is reloaded with developer tools open at the first time. For me, the best solution was - as mentioned by others before - to add
at the beginning(!) of the .css file to workaround the Chromium engine bug. |
Just to mention (again) that adding I suggest to consider also changing response header via nginx or whatever proxy server: #17644 (comment) |
If using escaped utf8 characters beginning with |
I'm 100% for this solution, and I think that FA should output escaped chars, but unfortunately it's a breaking change :( Upgrading to dart sass > 1.55 should also help (or maybe even fix) |
hello @tagliala ! so sorry to bring up such an old comment I did read the update, but with this "fix" does that mean the minified code results in the unicode string (ie. "\f26e")? at the moment, the minified css I have are all PUA (Private Use Area) codes even with the "fix" |
No, if you want a fix like that, it is a little bit more complicated at the moment and it will require a new fix after each update, please check the comments here: diowa/ruby3-rails6-bootstrap-heroku#540 |
Actually, this case is not from sass-loader but dart-sass. I have looked up many, many issues about this case, which are all over the major open-source warehouses such as sass, sass-loader, and so on. The source of the problem is not the sass-loader, the sass-loader just calls the sass command, so the source of the problem is the default encoding of dart-sass (you can get this result just with sass-loader and file-loader), which stubbornly encodes characters that do not need to be encoded. So "\xxx" in our code is translated into a garbled character after dart-sass compilation. Unfortunately, dart-sass could have had an elegant solution to this problem, however, their developers were so stubborn that they believed their default coding could not be changed. They think this effect is so great that they act like bandits and demand that person who asked the question provide stable replication steps for an occasional bug. Guess the ultimate source of this problem can actually be attributed to the browser, the browser for the CSS encoding guess error, resulting in even if you have added html encoding and CSS charset, the font icon parsing still occurs problems. The final solution, as this man says, is to Change your sass file to a CSS file. Extract all CSS styles that contain Unicode characters into a CSS file, not a Sass file. The CSS file does not need to go through the sass-loader, so the stubborn dart-sass cannot corrupt it |
Update on my end: I ended up using a postcss plugin - https://github.com/lcoronelp/postcss-sass-unicode I will say that its not great, though because this is what looks like is happening:
So now when the browser loads in the css, it doesnt have to do its decoding for whatever the square [] is - its just reading the value. Until theres a popular solution, ive just been using the above plugin for now |
Maybe you can try my idea if your font icon related styles are all in a sass file. Just change this sass file to a CSS file to make it escape dart-sass |
thank you @nsunga, this approach seemed to help in our case and helped to resolve an issue |
Issue is often(50% of the time) occurring with Mac Chrome. I have tried adding charset, but it still fails. The icons gets added by CMS and we don't have a way to determine which of them to preload. We are using sass and not with dart as it is not supported by CMS. Is there any other solution suitable here? |
This is supposed to happen with self-hosted css files compiled from Sass, so it should mean that user have the ability to make changes to the toolchain used to compile the css output. You can:
|
For fellows using webpack and facing this issue, I've realized that while on localhost my stylesheet always had the icons in place. So I found that in the stylesheet of my built application I had the following output: So testing a bit of options, I figured that the culprit of my setup was the sass-loader set for .scss files. So on my webpack.config.js for my
Now the stylesheet output for my build is the following: Hopefully this can help someone! |
Related to datavisyn/reprovisyn#1665 Solution proposed by FortAwesome/Font-Awesome#17644 (comment)
Coming from datavisyn/reprovisyn#1665 ### Developer Checklist (Definition of Done) **Issue** - [x] All acceptance criteria from the issue are met - [ ] Tested in latest Chrome/Firefox **UI/UX/Vis** - [ ] Requires UI/UX/Vis review - [ ] Reviewer(s) are notified (_tag assignees_) - [ ] Review has occurred (_link to notes_) - [ ] Feedback is included in this PR - [ ] Reviewer(s) approve of concept and design **Code** - [x] Branch is up-to-date with the branch to be merged with, i.e., develop - [x] Code is cleaned up and formatted - [ ] Unit tests are written (frontend/backend if applicable) - [ ] Integration tests are written (if applicable) **PR** - [x] Descriptive title for this pull request is provided (will be used for release notes later) - [x] Reviewer and assignees are defined - [x] Add type label (e.g., *bug*, *feature*) to this pull request - [x] Add release label (e.g., `release: minor`) to this PR following [semver](https://semver.org/) - [x] The PR is connected to the corresponding issue (via `Closes #...`) - [x] [Summary of changes](#summary-of-changes) is written ### Summary of changes - Add solution proposed by FortAwesome/Font-Awesome#17644 (comment) ### Screenshots ### Additional notes for the reviewer(s) - Thanks for creating this pull request 🤗
Describe the bug
On random page loads or refreshing of page strange characters are displayed instead of the font awesome icons. Seems to very closely related to #15010 & #17611. However, it happens when using both
fa
classes and setting the content manually in css.There is no trace of FA4 in the project.
To Reproduce
SCSS:
Expected:
Actual:
Expected behavior
Expected behavior is that the font awesome icons would display correctly.
Version and implementation
Version: Font Awesome Pro 5.14.0
Browser and version: Google Chrome 88.0.4324.150
OS: Mac OS 10.15.7
Bug report checklist
The text was updated successfully, but these errors were encountered: