Weird fonts in websites after changing android system font with root

After I had changed the system wide font with a magisk module, random fonts appear in all the websites that do not have custom website fonts.

The fonts work properly on chromium based browsers but this seems to be an issue with firefox. I had previously changed a setting in about:config to fix it but now I cannot find it.

Pls help.

Messed up fonts in Firefox:

How it is supposed to look (Chrome):