by Michael S. Kaplan, published on 2006/06/25 13:32 -04:00, original URI: http://blogs.msdn.com/b/michkap/archive/2006/06/25/646701.aspx
When I first mentioned yesterday that I was going to be blathering about the Fonts folder for a bit, regular reader Rosyna commented:
It'll be interesting. I know virtually nothing about the Windows fonts folder. Many people hate the Mac OS X's multiple fonts folders (System, "Local", Network, User, and Classic). It becomes hard to deal with everything has having multiple duplicate fonts is very possible and almost the case on every single Mac OS X box.
The good thing though is that any font dragged into a Mac OS X font folder is available to all applications immediately.
I suddenly realized I wanted to start things a bit differently than what I was originally going to do.
(For those of you who hate the "Add Font..." dialog, wait for the next post -- I'll be getting to that shortly!)
So, we'll start with simple question: What the hell is the Fonts folder?
The simple answer? It is a Shell namespace extension that causes any display of %WINDIR%\Fonts in the Windows Explorer to have a special view where typical filesystems actions in Explorer such as copy, move, and delete have special handlers.
It is by no means the only way to get fonts ontop Windows, though.
If you look at the Platfrom SDK documentation for the AddFontResource function:
The AddFontResource function adds the font resource from the specified file to the system font table. The font can subsequently be used for text output by any application.
So all you have to do to get a font available to everyone is call this function!
Of course there are things to keep in mind in the remarks section:
Any application that adds or removes fonts from the system font table should notify other windows of the change by sending a WM_FONTCHANGE message to all top-level windows in the operating system. The application should send this message by calling the SendMessage function and setting the hwnd parameter to HWND_BROADCAST.
When an application no longer needs a font resource that it loaded by calling the AddFontResource function, it must remove that resource by calling the RemoveFontResource function.
This function installs the font only for the current session. When the system restarts, the font will not be present. To have the font installed even after restarting the system, the font must be listed in the registry.
Wow, those three paragraphs are like three strong drinks, aren't they? They tell you:
That work in the third bullet point is to add the font's name and filename to the registry in the following subkey:
HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts
And although most of the files listed there will have no path (in which case %WINDIR%\Fonts is assumed), this is not a requirement.
All that our Shell Extension Fonts folder does (well, it does more than this, but bear with me for a bit) is wrap all this up. In fact, it is GDI that makes an AddFontResource call on every font in that registry key when it does its own initialization, and it is the folder's handling code that adds and removes fonts from the list in the registry.
But all of the hints are here -- anyone who hates the Shell Fonts folder interface to these things can build their own code. They can even make it a Shell Extension wherever they like, and put in all the same kind of handling code, or better.
Now the Shell code does a bit more here -- for example you can install a font programatically by opening the Fonts folder in Explorer and simply copying the font file to the folder (more on why this is not the best way to do it later!). It also gives some unique views of fonts that are in the folder (more on these later, too), and it completely hides hidden files even if you have the "Hide protected operating system files" setting unchecked (which you would do as well if you saw what was in there!). And lots of other little things like that.
But clearly the widespread belief that fonts need to be in the Fonts folder (which requires admin privileges to write to) is a myth. The only action that truly requires admin-style privileges is writing to that registry key (since it is under HKLM), but just about everything else is a bit more open to people.
The myth is a tribute to What it means to be in the default install, and how hard it is to get noticed as a feature if the feature is not available in some default, built-in fashion.
Imagine for example if the Fonts folder was actually further virtualized into supporting both the current folder in %WINDIR%\Fonts and some kind of per-user folder like under %USERPROFILE%\Fonts or something -- so that anyone could install fonts and you would either have the "just me" or "all users" choice, or if you lacked permissions it would be a "just me" install automatically.
For now one will have to keep imagining (there is no such feature in Vista, for example).
But I will be talking more about the Fonts folder in future posts, specifically to cover:
So stay tuned, there will be much more for font users, typographers, people who find my posts witty, Microsoft bashers, basically just about everyone....
This post brought to you by F (U+0046, a.k.a. LATIN CAPITAL LETTER F)
# Ben Cooke on 25 Jun 2006 2:54 PM:
# Michael S. Kaplan on 25 Jun 2006 4:16 PM:
# Rosyna on 25 Jun 2006 4:22 PM:
# Anonymous on 25 Jun 2006 6:19 PM:
# Michael S. Kaplan on 25 Jun 2006 7:49 PM:
Centaur on 26 Jun 2006 10:24 AM:
# Michael S. Kaplan on 26 Jun 2006 2:24 PM:
# Mike on 26 Jun 2006 2:42 PM:
# Adam on 27 Jun 2006 11:55 AM:
# Michael S. Kaplan on 27 Jun 2006 12:46 PM:
# Adam on 28 Jun 2006 4:26 AM:
# Michael S. Kaplan on 28 Jun 2006 7:25 AM:
# Adam on 28 Jun 2006 6:23 PM:
# John Elliott on 3 Jul 2006 8:57 AM:
Centaur on 3 Jul 2006 10:43 AM:
# Ricardo Cancho (Spain) on 21 Jan 2008 1:24 PM:
Hi.
My experience: RemoveFontResource() works only for font files instaled by the same program that performed AddFontResource(), and in the same session. If you'll try to use RemoveFontResource to go away an arbitrary font manually installed in C:\Windows\Fonts or installed with your own program, but after a rebooot, RemoveFontResource fails (the .ttf file is locked). So you can't write a full "Font Manager", as I tried myself.
The only way I found was: a) open C:\Windows\Font through with the explorer, b) use SendKeys to locate the font face plus style in the list c) use SendKeys {DEL} to delete (& unregister) the file, and d) use SendKeys %{F4} to close the explorer's window.
Believe me, the result isn't a commercial piece of software at all.
Yours.
Ricardo Cancho.
kiers on 24 Nov 2008 11:51 PM:
hmm...interesting. I understand what u said about "shell namespace extension" and how for THIS particular folder there are special handlers for copy cut paste etc.
My problem: can I "move" via a junction poiint (parse point under NTFS) the c:\windows\fonts folder to D:\fonts for space saving reasons?
I copied all fonts under teh c: folder and pasted them to D: folder. however I noted the C; folder had 231 fonts inside, however right clicking on the c: fonts folder itself showed "363 files" !! at 436MB.
whereas the pasted fonts folder in D: drive ONLY shows 231 "files" at 312MB!!!
question: what's missing in the d: folder that the c: fonts folder has??? i don't want to empty the c: folder and apply the parsepoint till I am reconciled between c: and d: !!!
any suggestions? am I kosher?
Michael S. Kaplan on 25 Nov 2008 9:56 PM:
Many of the font files are marked system and hidden, it looks like you did not move those?
ldandmbbrown on 23 Feb 2010 9:15 PM:
Michael, I read your blog About the Fonts folder in Windows, Part 1 (aka what are we talking about?), Your blog About the Fonts folder in Windows, Part 2 (aka Adding Fonts), the commentaries left about the posts. Followed the embedded links within your post and still have come away with the feeling that getting fonts into the Windows\Font folder is easy...Its getting them out that is somewhat hopeless by any other means than through the provided UI.
I manage around 1000 devices both MAC and PC's running Mac OS 10.x through Windows XP, Vista and now Windows 7. The problem that we fight on a daily basis is maintaining the bare minimum amount of fonts on each platform (~66 to be exact) hoping not to interfere with the fonts supplied to us by our customers (Which by the way I suspect are creeping into the Windows\Font folder somehow).
Three (3) to four (4) weeks ago, I set out on a mission to make maintaining our fonts a more efficient and less resource intensive endeavor. Here I am 3 - 4 weeks later posting a comment to an article you posted 4 years ago and still each avenue I have went down has brought me back to the same place (want to delete, use the UI...such a wonderful customer experience)....Only way to bust the fonts out of captivity once placed in the Windows\font folder is to manually rip them out. This seems very counter productive to me in an age when technology has exploded into the hands of almost everyone.
The ramifications of fonts just showing up and being able to be installed with the introduction of @Font-face command. This command used poorly by anyone wanting to use cute fonts in a webpage or document, coupled with an OS willingly accepting them with open arms is alarming (or should be). The ramification of the installation of fonts without anyone’s knowledge exposes companies to all sorts of ethical if not financial risk.
If the owners of the Windows\Font folder as you so brilliantly implied are not concerned with the introduction of unsolicited, unwanted files, why would they be so protective of not allowing authorized users of being able to just as easily remove them? I would be happy to expound upon this further if you have any interest, even if you want to take them into another discussion venue. Look forwards to hearing from you soon.
referenced by
2008/10/09 About the Fonts folder in Windows, Part 5 (Nothing personal!)
2008/03/21 Did UnC "My name is URL" on TV the other day? Fontastic!
2007/11/06 Like a mattress tag, the rule is DO NOT REMOVE
2007/05/26 On installing fonts
2007/04/01 There is no spoon^H^H^H^H^HGDI Font Cache
2006/08/27 About the Fonts folder in Windows, Part 3 (aka What changes in Vista?)
2006/07/02 About the Fonts folder in Windows, Part 2 (aka Adding Fonts)