Adding Fallback Fonts When Using Custom Fonts in Power BI Themes
Have you tried using custom fonts in Power BI Themes, only for it to break and look rubbish when you share the report out to users? If so, you need a fallback font, learn how to implement them here.
Scenario
Your company has a custom font that it wants to have included on its Power BI reports.
You add the custom font to the Theme by replacing the default theme with your custom font.
The font it installed locally on your machine and it works fine so you publish it to the service and share it with other users.
But, the other users without the font installed on their machine, start to see a horrible looking font that looks really out of place.
So, what's going on and how do we control this?
What's Going On?
One of the main limitations when using custom fonts in a Power BI theme, is that every end user must have the custom font installed on their device.
With a small number of known users, this can be overcome by getting them (or the IT department) to install the fonts on their machines.
But, when there is a larger audience, it becomes unmanagable so we need to be able to control which font is used when the custom font is not available.
This is where Fallback Fonts come into play. Think of it as damage limitation, at least you know what your report will look like when fallback fonts are used, and you can try and use the closest match possible.
How do I use Fallback Fonts in a Power BI Theme
Here is an example theme where all I've changed is the Title font family. I've changed the Title font to a native Power BI font, Comic Sans MS, so we can clearly identity that it's working as a fallback later on.
{
"name": "Fallback Font Demo",
"textClasses": {
"title": {
"fontFace": "'Comic Sans MS'"
}
}
}
As a quick side rant, WTF is Comic Sans even doing in Power BI!? You only give us 26 options and two of them are Comic Sans & Wingdings? Come on Microsoft, pull your finger out 🙄
Anyway, I want add in a custom font that's definitely not going to be installed on anybody else's machine by default. I've gone for one called FLIPclockBlack which gives an old school scoreboard flip-chart style font.
All I need to do is add this font name to the fontFace property in the theme, between the double quotations, but separated by a comma as follows:
{
"name": "Fallback Font Demo",
"textClasses": {
"title": {
"fontFace": "FLIPclockBlack,'Comic Sans MS'"
}
}
}
A Few Things to Remember
- You can add multiple fallback fonts, the first available font will be rendered.
- Make sure you get the exact spelling of the font name. I suggest looking in the fonts directory in Windows, just search fonts from your Start menu.
- If the font name contains a space, wrap the font name in single quotation marks, for example 'Times New Roman'
Testing the Fallback Font is Working
First, I'm going to check my report on my machine where I know I have the custom font installed. It looks like this:
Second, I am going to access the same report from a different machine where I know the custom font is NOT installed.
What we want to see is the report defaulting back to Comic Sans MS, not some random font that we haven't specified.
Here's how it looks:
Result! The report is reverting to the fallback font we specified as planned.
Now, in real life, you obviously wouldn't use such ridiculous fonts as I've used.
You should always specify one of the Power BI Native fonts as the final fallback option, but you should be pretty safe using something like these web-safe fonts.
What Happens If I Don't Specify a Fallback Font
For this test, I've removed the Comic Sans MS fallback font, leaving us only with the custom FLIPclockBlack font.
When this font isn't available, here's what it default back to:
As you can see, the report has defaulted to Times New Roman, which rarely looks good in my opinion.
It makes it look even worse if you are trying to load a modern, sans-serif style font that your brand uses, and you end up with this!
Not a good look, so make sure you specify some fallback fonts!
Thanks for reading, I hope this helps give you confidence to start using some custom themes in your business.