When you select a particular font in a Visio document, what you are really doing is adding a reference to a font that’s resident on your system. What you don’t always know is that anyone else who opens your document will have the same font on their system and therefore that they will see the document as you intended…
I’m currently in the process of putting together some Visio shapes for a Windows Phone wireframing post and have been thinking about the best approach for enabling dynamic fonts (ie a single shape that changes its font based on Shape Data. I have to admit that the way in which Visio handles fonts wasn’t something I completely understood so I thought I’d hit up the Visio team with a question and jot down what I learnt.
Font by ID
One factor in handling fonts in Visio is that they are referenced by an ID number and this may differ from system to system. You can see the ID by opening the ShapeSheet (have a look at the just for starters post if you’ve not come across this before) of a shape and scrolling down to the Character section. In the image below, for example, you can see that the shape I’ve selected has a font called ‘Buxton Sketch’ and, on my system, its ID is 58:
If I now remove the ‘Buxton Sketch’ font from my system then ID 58 no longer refers to ‘Buxton Sketch’, but another font – in this case ‘Californian FB’:
So if you can’t trust that the same ID will refer to the same font on two different systems then how does Visio deal with this? Well the answer is a hierarchical solution.
The first time you add a new font to your shape Visio stores a reference to it at document level. You can see this by saving the document in xml format (.vdx) and looking for the FaceNames tag:
If you then send your document to a colleague who opens it on their system, Visio will see that one or more shapes reference a font with ID 58 and try to resolve this against a font. It first hunts through the FaceNames to work out which actual font the ID is referring to and then whether it can find it on the system. Continuing with the above example, if Visio is able to locate ‘Buxton Sketch’ on the target system then of course it uses it, but if it can’t then it then steps down to the next level, which is to try an find a reasonable equivalent…enter the Panose System.
The Panose font matching and classification system enables fonts to be placed into various categories such as Family, Serif Style, Weight etc. and this means that you can identify a visually similar font based on its Panose digits (see the Panos attribute in the xml above). If you’re interested in this system then have a look at the wiki link above and also the image below (click for the original pdf), which is a nice visualisation of the Panose categories:
This is all fine if you’ve used your fonts in advance, but what happens if you either don’t want to use each font, or are not dealing with document level objects (perhaps you have an add-in that pushes font ID’s into the respective cell)? Well here you have the FontToID ShapeSheet function, which appeared in Visio 2007. This function takes a string as a parameter and returns, as you might expect, an ID. For example:
The documentation for the FontToID function isn’t very extensive, so bear in mind that a) the string is case sensitive and b) if the font name is not found the function returns a #VALUE error. (Thanks to MVP Scott Helmers for those two.)
So I hope that helps those, who like me, hadn’t quite grasped the intricacies of font handling in Visio.
[UPDATE 08.08.11 - If your interested in other Visio font related information, you might want to check out a new post by Saveen Reddy on a workaround for using OpenType fonts with Visio]