Adding Fallback Fonts When Using Custom Fonts in Power BI Themes
Martyn Booth
Senior Power BI Engineer @ FSP | Designing World Class Power BI Reports for Clients | Blogger at Not Just a Pretty Dashboard
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?
Limitations of Custom Fonts in Power BI
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 unmanageable 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 to the original font you wanted to use.
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. I've changed the title font to one of the native Power BI fonts, Comic Sans MS. I've gone with this choice, partly for comedic effect and partly to make it easy to identify if it's being used as a fallback font later on.
{
"name": "Fallback Font Demo",
"textClasses": {
"title": {
"fontFace": "'Comic Sans MS'"
}
}
}
To test this out, I want add 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.
I've installed the font locally on my machine, now all I need to do is add this font name to the fontFace property in the theme. It needs to go between the double quotations, but separated by a comma:
{
"name": "Fallback Font Demo",
"textClasses": {
"title": {
"fontFace": "FLIPclockBlack,'Comic Sans MS'"
}
}
}
A Few Things to Remember
领英推荐
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 defaults 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.
This article is originally from my blog at NotJustAPrettyDashboard.com
Expert in Data, Analytics & Project Controls | BaseOne.uk | Helping businesses make better decisions!
2 个月Fonts in power bi are pretty poor. I’ve used Google fonts via html in the past. But it makes reports quite complex. This is a cool post! ??
Stamp 1G | Business Intelligence Analyst | Microsoft Certified Power BI Analyst | Power BI | Tableau | SQL | SSRS | SSIS | Power Automate | Power Query | DAX
2 个月Very informative and got to learn one more limitation of Power BI custom fonts and how we can overcome it. Thanks I will use this in my next projects.
Fonts are a tricky topic for personal branding at companies. You can't use someone else's copyrighted material but you can't use something ugly when it doesn't work. Having fallback fonts work. It would be great if all machines had access to the same fonts.