Create a gist now

Instantly share code, notes, and snippets.

LoadFonts SendTo Command - Load missing fonts required by an Illustrator file from the folder where you keep your font library.
@echo off
setLocal EnableDelayedExpansion
cd /d %~dp1
set init=init-%RANDOM%.tmp
set clean=clean-%RANDOM%.tmp
set fp=%~n1.fonts.txt
:: EDIT THIS LINE with the location of your own font collection folder
set fontdir="F:\Fonts"
if exist "%fp%" goto Unload
:: First type of scanning and parsing
findstr "<stFnt:fontFamily>" %1>%init%
:: Second type of scanning and parsing
for /f "tokens=* delims= " %%f in ('findstr "FontFamily" %1') do (
set line=%%f
call :Sp
type NUL > %clean%
:: DelDupeText.bat plus markup cleaning for 1st type of parsing
for /f "tokens=*" %%a in (%init%) do (
set str=%%a
set str=!str:^<stFnt^:fontFamily^>=!
set str=!str:^</stFnt^:fontFamily^>=!
find /i ^"!str!^" %init% >nul
find /i ^"!str!^" %clean% >nul
if errorlevel 1 echo !str!>>%clean%
if exist %clean% del %init%
echo Searching for fonts to load from %fontdir%
for /f "tokens=*" %%x in (%clean%) do (
set "x=%%x"
call :Sub x
del %clean% 2>nul
if exist "%fp%" (>nul findstr "^" "%fp%" || del "%fp%")
if exist "%fp%" (
echo --------------
:: EDIT THIS LINE with the location of ShellTools FontLoader.exe
start %SystemRoot%\FontLoader.exe "%fp%" -load
echo Fonts loaded.
exit /b
:: EDIT THIS LINE with the location of ShellTools FontLoader.exe
start %SystemRoot%\FontLoader.exe "%fp%" -unload -tmp
echo Fonts unloaded.
goto End
dir /b %SystemRoot%\Fonts | find /i "!x!" >nul
if errorlevel 1 (
dir /s /b %fontdir%\*.ttf,%fontdir%\*.otf | find /i "!x!">>"%fp%"
if errorlevel 1 (
echo !x! was not found.
set /p x="Press Enter to skip or try a name variation: "
if NOT errorlevel 1 (
call :Sub
goto :End
) else ( set "x=" )
if NOT "!x!"=="" (echo Trying !x!) else (echo Skipped...)
) else (
rem This one was found in Windows Fonts folder
goto :EOF
for /f "tokens=1* delims=/)" %%a in ("%line%") do (
echo "%%a" | find "FontFamily" >nul
if NOT errorlevel 1 (
set "found=%%a"
set found=!found:FontFamily(=!
echo !found!>>%init%
set line=%%b
if not "%line%" == "" goto :Sp
goto :EOF

Depends on the Moon Software ShellTools executable FontLoader.exe !

What it does

It allows you to keep Windows installed fonts to a minimum by detecting fonts required by an Illustrator document and letting you load them temporarily. There are probably several apps that handle this, but this one is free, simple and lightweight.

The end goal for this batch file is to open old project files and have their missing fonts automagically loaded and unloaded.

Use case

I formatted my machine and thus lost all installed fonts. I didn't want to put them all back on from the backup because of the performance penalty and because I didn't need every font all the time. But I did want my old Illustrator projects to open correctly. So at the moment I keep my font collection on a separate drive, and run this batch script on the documents I want to open.


  • Save this batch file (.cmd or .bat) to the Windows SendTo folder (search for shell:SendTo). You may also save it wherever and create a shortcut to it in the SendTo folder, which you can rename and put an icon on.
  • Get ShellTools and locate FontLoader.exe.
  • Copy it to somewhere like C:\WINDOWS\ and edit the corresponding lines in the script with its location
  • Edit the corresponding line with the location of your fonts collection (eg. F:\Backup\MyFonts)
  • Save the batch file and you're good to go!
  • Now navigate to an Illustrator project file (.ai, .pdf, .eps), right click > Send to > LoadFonts.cmd
  • A command line window will pop up telling you what it's doing.
  • After the file is scanned, the fonts identified and located in your collection, a text file will be created in your project folder. This file contains the paths of the fonts you have just loaded. (eg. will have MyProject.fonts.txt)

Run it again to unload the document fonts when you're done with it.

Known bugs

(Windows 7, Adobe Illustrator CS6)

  • Font families blanket approach has this issue: if one font from a family is installed, the search says "Hang on, don't load these, this family is already installed"
  • Fonts used by objects that are hidden are sometimes not detected. This is because of compression.
  • Fonts used by plug-ins are undetected. (eg. Astute Graphics Phantasm)
  • Using FontLoader after Illustrator is convinced fonts are not available sometimes crashes Illustrator.

To do

  • Awful spaghetti code - this is a mashup of googled snippets. I'm not a programmer.
  • Parsing the document is pretty primitive. Look for a way to extract the font family name from within the strings stFnt:fontFamilyFutura</stFnt:fontFamily> and /FontFamily(Futura)/ in a more elegant manner (capturing group, submatches? hybrid batch/VBScript?)
  • Eliminate the dependency on FontLoader.exe or package it neatly
  • Moar user friendliness

Maybe dispense with SendTo altogether and instead create a batch file to associate Illustrator project files with... that first checks for fonts, loads the missing ones and then passes the file on to Illustrator.exe

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment