Question: I'm using `standalone` document class and trying to draw a TikZ picture. The picture have border which is the border of the page. I do it [like this](http://papeeria.com/p/c6949888bcd012d5fcc4ca5bd8ba79a9#/without-fontspec.tex):

```
\documentclass{standalone}
\usepackage{tikz}

\def\W{220}
\def\H{250}

\begin{document}
\begin{tikzpicture}[x=1pt,y=1pt]
    \draw[ultra thick] (0,0) -- (\W,0) -- (\W,\H) -- (0,\H) -- (0,0);
\end{tikzpicture}
\end{document}

```

And it looks like this (I've added red background just to make the difference visible, and I've done it using gimp, it's not a part of the question)

![the left border at very left](https://i.stack.imgur.com/yZ64i.jpg)

But if I just add `\usepackage{fontspec}` to the preamble then some left margin appears and it looks [like this](http://papeeria.com/p/c6949888bcd012d5fcc4ca5bd8ba79a9#/with-fontspec.tex)

![the left border moves to the right](https://i.stack.imgur.com/zFyqb.jpg)

So, where does it come from? How can I get rid of it?

Answer: 
I see the effect with TexLive 2013, but not with 2014 and miktex. So you will probably have to update something (fontspec?). The effect disappears if I add `\unskip` after `\begin{document}`. So it looks like an spurious space somewhere.
[Ulrike has shown](https://tex.stackexchange.com/a/200655) that this is a `fontspec` issue. The actually faulty code is 

```
\tl_put_right:Nn \document
 {
  \tl_set_eq:NN \cyrillicencoding \g_fontspec_encoding_tl
  \tl_set_eq:NN \latinencoding    \g_fontspec_encoding_tl
 }

```

which is used to do something 'really late', just before the start of the document. The problem is that this gets added after the `\ignorespaces` that is at the end of the standard `\document` macro. This causes issues as there is a space (line end) after `\begin{document}`. Newer versions of `fontspec` avoid this by using the standard `\AtBeginDocument` hook, so the issue goes away. In cases where you *really* need to hook right at the end of `\document`, you have to always add an `\ignorespaces` as well as what you need, or use a 'patch' approach to essentially do the same thing.