tosk Posted January 30, 2006 Share Posted January 30, 2006 (edited) EDIT: Modified code to allow user to specify directory containing fonts.I wrote a small utility that can aid in installing fonts during a unattended installation. The utility is silent, in that, it has no display or interface. It will run silently in the background and do it's work then exit. It has only one argument. If the user wishes (it's preferred) the directory containing the fonts to be installed can be specified as the one argument. If no argument is given, it uses the working directory.How it worksFirst, it gets a list of all the files in the working/specified directory, then it processes all the ones that have the .ttf (.TTF) extension. After it gets it's list, it copies each of the files to %SYSTEMROOT%\Fonts and creates registry entries for each of the fonts. Unfortunately, I don't know of any available API for Java that can parse a TTF and retrieve the font name, so the entries in the registry are labeled "System Installed Font (# ?)" where ? is the number that font was processed.After a reboot the fonts are all available with their proper names. So you won't have to worry about opening Word and seeing "System Installed Font (# 12)" in the font selector.The utility depends on the presence of the REG.EXE tool. If this tool doesn't exist or isn't in your path, the program will fail but will not display any errors.How to make it workThe whole purpose behind using this tool is so that when the system boots for the first time, the fonts are available without user interaction. So the tool will need to be run during GUI-mode or during RunOnceEx if your setup automatically reboots at the end. Remember: the system must be rebooted before the fonts will appear. That's why it's best to do it during GUI-mode. The best way (according to me) is to run it during [setupParams] in WINNT.SIF.Here's an example using [setupParams] in WINNT.SIF...[SetupParams]UserExecute="%SYSTEMDRIVE%\Fonts\typer.exe %SYSTEMDRIVE%\Fonts"...Here's an example using cmdlines.txt:D:\ (ROOT OF CD) -$OEM$ -$$ -$1 -Fonts -FONT1.TTF -FONT2.TTF -another.ttf -... -typer.exe -cmdlines.txt -fonts.cmdcmdlines.txt[COMMANDS]..."fonts.cmd"...fonts.cmd%SYSTEMROOT%\SYSTEM\CMDOW @ /HID@echo off%SYSTEMDRIVE%cd Fontsstart /wait typer.exeexitThat's one way to do it. I'm experimenting with different ways to clean it up so it's completely silent and the end-user is oblivious to what's going on.The utility was written in Java, but was compiled to native code using GCJ and packed using UPX.Below is a link to a zipped copy of the native binary. Source is included and will successfully compile and run with Sun Java 1.5 (bytecode) and GNU GCJ 3.4.0 (native and bytecode).License: You may use this utility as you see fit and may use it's source as you see fit. This utility has NO warranty. I have tested it and it works fine for me, but don't blame me if you use it and it destroys the world.Note: I've tested it on already-installed systems and on my unattended CD. Both times, the utility performed appropriately.Download: typer.zip Size: 1.26 MB (1,292 KB) Edited October 17, 2006 by tosk Link to comment Share on other sites More sharing options...
Shark007 Posted January 30, 2006 Share Posted January 30, 2006 Seems like a nice little utility.Are you aware that simply placing the font files into $OEM$\$$\FONTSor using a selfextracting exe to uncompress into the windows\font folderwill install them just fine and to register them for use all you have to dois open the %windir%\fonts folder once and close it.shark Link to comment Share on other sites More sharing options...
tosk Posted January 30, 2006 Author Share Posted January 30, 2006 (edited) Yah. I knew you could do that. But doing that you actually have to open Fonts to register them. To me, that kind of defeats the purpose of an unattended install since the fonts aren't actually installed until after setup finishes, the system boots for the first time and the end-user has control.Besides, I was incredibly bored this weekend and needed a way to kill some time. This is also a small proof-of-concept for a project I'm working on that requires a registry access API in Java.I'm going to test running it from [setupParams] in WINNT.SIF after I add the ability to specify the font directory as an argument. Edited January 30, 2006 by tosk Link to comment Share on other sites More sharing options...
Bezalel Posted January 30, 2006 Share Posted January 30, 2006 Why don't you use the AddFontResource API call in gdi32.dll? In this case You don't need the font name, the API gets and applys the name. Link to comment Share on other sites More sharing options...
tosk Posted January 31, 2006 Author Share Posted January 31, 2006 Why don't you use the AddFontResource API call in gdi32.dll? In this case You don't need the font name, the API gets and applys the name.Is this documented anywhere and is it freely available? Or do you know what's required to actually do something like this? Also, is it possible to make the call using rundll32? Link to comment Share on other sites More sharing options...
Lost Soul Posted January 31, 2006 Share Posted January 31, 2006 (edited) nice work but i really prefer just using the "fontinst.exe /F fontinst.inf" self extracting file my self it installs and registers every font you like Edited January 31, 2006 by Lost Soul Link to comment Share on other sites More sharing options...
tosk Posted January 31, 2006 Author Share Posted January 31, 2006 Why don't you use the AddFontResource API call in gdi32.dll? In this case You don't need the font name, the API gets and applys the name.Is this documented anywhere and is it freely available? Or do you know what's required to actually do something like this? Also, is it possible to make the call using rundll32?Through some trial and error, I've found that using AddFontResource doesn't work. It has to be called as AddFontResourceA and even then, it doesn't add the appropriate entries to the registry. I'm sure I've just not done something right and that's why it's not working. Any help would be greatly appreciated. Link to comment Share on other sites More sharing options...
Bezalel Posted January 31, 2006 Share Posted January 31, 2006 Why don't you use the AddFontResource API call in gdi32.dll? In this case You don't need the font name, the API gets and applys the name.Is this documented anywhere and is it freely available? Or do you know what's required to actually do something like this? Also, is it possible to make the call using rundll32?Most of the font related APIs are documented at http://msdn.microsoft.com/library/default....ontext_9r77.asp Link to comment Share on other sites More sharing options...
clavicle Posted October 5, 2006 Share Posted October 5, 2006 @toskIt's been a long time since this utility was released. But I am unable to download it. Can you please upload it again. Link to comment Share on other sites More sharing options...
druiddk Posted October 11, 2006 Share Posted October 11, 2006 Yes, Please upload it again Link to comment Share on other sites More sharing options...
tosk Posted October 17, 2006 Author Share Posted October 17, 2006 *bump*Fixed the download link. It's available again as requested. Link to comment Share on other sites More sharing options...
clavicle Posted October 17, 2006 Share Posted October 17, 2006 Thanks! ;-) Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now