Forum Discussion
Importing Google fonts /using Google Fonts in cust Viz dev
- 3 years ago
Hi smpa01,
Assumning that you've added https://fonts.gstatic.com to your visual's privileges for web access and it's still being refused, the Google domains may be imposing further cross domain issues against the custom visual sandboxing from their end.
However, if you're OK with bundling the font as part of your visual, then this will be possible.
With Deneb I've loaded the DIN font (as this doesn't seem to be available to custom visuals) as a base64 URL into my visual.less and this gets packaged and works inside the visual. You can see an example of how I set this up here.
If you're using a custom webpack configuration and have an appropriate loader, you may just be able to load the font using a relative URL in your source (I don't use powerbi-visuals-webpack-plugin as it never seems to be reliable enough for me and it defintiely doesn't work using powerbi-visuals-tools as-is).
Anyway, this may give you a way to achieve what you want, even if not as you were intending originally.
Regards,
Daniel
Hi smpa01,
Assumning that you've added https://fonts.gstatic.com to your visual's privileges for web access and it's still being refused, the Google domains may be imposing further cross domain issues against the custom visual sandboxing from their end.
However, if you're OK with bundling the font as part of your visual, then this will be possible.
With Deneb I've loaded the DIN font (as this doesn't seem to be available to custom visuals) as a base64 URL into my visual.less and this gets packaged and works inside the visual. You can see an example of how I set this up here.
If you're using a custom webpack configuration and have an appropriate loader, you may just be able to load the font using a relative URL in your source (I don't use powerbi-visuals-webpack-plugin as it never seems to be reliable enough for me and it defintiely doesn't work using powerbi-visuals-tools as-is).
Anyway, this may give you a way to achieve what you want, even if not as you were intending originally.
Regards,
Daniel
dm-p thanks for the response.
Assumning that you've added https://fonts.gstatic.com to your visual's privileges for web access _ No, I did not do that cause I don't know how to do that explicitly. If you can please let me know how to do that, would be great.
However, if you're OK with bundling the font as part of your visual, then this will be possible - I also did not know that gFonts can be bundled as part of the viz and I tried this. You made my day !!!!
getComputedStyle(document.querySelector('#sandbox-host > p')).font
//returns as desired
Can't thank you enough for this TBH.
Web is so mysterious.