# xelatex hangs when using fontspec

I'm using TexStudio 2.5.1 on Windows 7 with MiKTeX. The following brief .tex file will cause xelatex to hang:

\documentclass[12pt]{article}
\usepackage{fontspec}
\begin{document}
Test
\end{document}


Using this command to compile:

xelatex.exe -synctex=1 -interaction=nonstopmode "test".tex


By 'hang', I mean that the xelatex process will take up an entire core and 200+ MB of memory, and not finish after several minutes. I get no error messages because the process never finishes.

If I comment out the fontspec line, it doesn't hang. But I'd like to use the fontspec package in my document. Why does it hang and how can I fix it?

As a side note, using lualatex instead of xelatex will succeed, but then using \setmainfont{Georgia} will make that hang as well.

-
Welcome to TeX.SE! You mention the operating system (Windows 7) and front end (TeX Studio) you use; which TeX distribution do you use? This may be important -- e.g., I use MacTeX2012 running under MacOSX 10.8.2, and your MWE (with or without the \usepackage{fontspec} directive) compiles just fine under XeLaTeX on this system. Incidentally, since you use TeXStudio, why are you issuing compile directives from a command line? And, have you tried executing "xelatex test" from the command line? –  Mico Dec 13 '12 at 2:26
@JeffE Have you configured your default compiler to be XeLaTeX? –  hpesoj626 Dec 13 '12 at 2:35
@hpesoj626 - I apologize for not making one of my questions clear enough: I wasn't asking how to configure TeXstudio, but why the OP doesn't seem to be using TeXstudio's front-end capabilities to compile the .tex file. –  Mico Dec 13 '12 at 3:10
@Mico: Sorry, I forgot to mention -- I'm using MiKTeX (latest version). I did actually use the built-in compile tool, I only pasted the command line in case it was relevant. xelatex test eventually gives me ! Undefined control sequence. –  Jeff E Dec 13 '12 at 3:41
@Speravir: Thanks, it didn't occur to me that it was updating the font cache. I just needed to let it run its full course. If you post that as an answer I'll accept it. –  Jeff E Dec 13 '12 at 4:09

fontspec uses a font caching system. This cache needs to be created first and later updated on a regular basis. Upon creation or updating some information about all TrueType and OpenType fonts installed in your TeX distribution and in your operating system is collected.
Depending on, how many fonts you have installed, these operations take some time, especially on the very first run, of course. That’s the reason, why you observed the hanging in both xelatex and lualatex.