This is a continuation from another question, but the original issue there is (kind of) resolved.
For this question you need XeTeX, Minion Pro, which is shipped with Adobe Reader. greybox.png can be obtained here and background grid is taken from this answer.
The code is as follows:
\newbox\gridbox
\setbox\gridbox\line{%
\special{color push rgb .8 .8 1}%
\vrule height\baselineskip width0pt \hrulefill
\special{color pop}}
\def\grid{\vtop to0pt{\hrule height0pt\kern-\dimexpr\baselineskip-\topskip\topskip=10pt\relax
\vbox to\dimexpr\vsize+2pt\relax{\leaders\copy\gridbox\vfil}\vss}}
\def\pagebody{\vbox to\vsize{\boxmaxdepth=\maxdepth \grid\pagecontents}}
\parskip=0pt \frenchspacing \raggedbottom
\parindent=1pc
\font\rm="Minion Pro:+onum,+pnum:mapping=tex-text" at 10pt
\font\it="Minion Pro/I:+onum,+pnum:mapping=tex-text" at 10pt
\rm
\footline={\hfil\rm\folio\hfil}
\newcount\shapenum \newcount\tempnum \newcount\globpar
\newdimen\ii \newdimen\ww
\newdimen\picwidth \newbox\picbox
\catcode`\@=11
\def\oblom #1 from #2 indent #3 {\par \ii=#1 \ww=\hsize
\ifdim\ii>\z@ \advance\ww by-\ii
\else \advance\ww by\ii \ii=\z@ \fi
\shapenum=1 \tempnum=0 \def\shapelist{}
\loop \ifnum\shapenum<#2 \edef\shapelist{\shapelist\z@\hsize}
\advance\shapenum by1 \repeat
\loop \edef\shapelist{\shapelist\ii\ww}
\advance\tempnum by1 \ifnum\tempnum<#3 \repeat
\advance\shapenum by#3 \edef\shapelist{\shapelist\z@\hsize}
\doshape}
\catcode`\@=12
\def\doshape{\globpar=0 \def\par{\ifhmode\shapepar\fi}}
\def\shapepar{\prevgraf=\globpar \parshape\shapenum\shapelist
\endgraf \globpar=\prevgraf
\ifnum \prevgraf>\shapenum \global\let\par=\endgraf \doshapeA \fi}
\ifx\XeTeXpicfile\undefined
\def\pic #1{\hbox{\pdfximage width\picwidth {#1}\pdfrefximage\pdflastximage}}
\else
\def\pic #1{\hbox{\XeTeXpicfile #1 width\picwidth}}
\fi
\def\\{\par}
\def\flowpic from #1 minus #2 width #3 #4#5{\par
\dimen0=#3 \ifdim\dimen0<0pt \dimen0=-\dimen0 \fi
%\advance\dimen0 by -1pc %(margin around picture)
% create this margin differently: add margin to #3
\dimen2=#3 \ifdim\dimen2<0pt \advance\dimen2 by -1pc
\else \advance\dimen2 by 1pc \fi
\picwidth=\dimen0
\setbox0=\vbox{\hsize\picwidth\pic{#4}%\kern .7mm
\emergencystretch=2em \noindent\it #5\par}
\dimen0=\ht0
\divide\dimen0 by\baselineskip \advance\dimen0 by1sp
\advance\dimen0 by -#2sp
\oblom \dimen2 from #1 indent \dimen0
\advance\dimen0 by #2sp
\multiply\dimen0 by\baselineskip
\setbox\picbox=\vbox to\dimen0{\vss\box0}
\dimen0=\pagegoal \ifdim\pagegoal=\maxdimen \dimen0=\vsize\fi
\advance\dimen0 by-\pagetotal \advance\dimen0 by-#1\baselineskip
\ifdim\dimen0<0pt
\def\doshapeA{\tempnum=\prevgraf \advance\tempnum by-#1 \advance\tempnum by2
\line{\ifdim#3<0pt \hfill\fi \vbox to0pt{\vss\vtop to0pt{\kern0pt\box\picbox\vss}%
\kern\the\tempnum\baselineskip}\hfil}
\nobreak\vskip-\baselineskip
}
\else \def\doshapeA{}
\line{\ifdim#3<0pt \hfill\fi
\vtop to0pt{\kern-2\baselineskip\kern#1\baselineskip\box\picbox\vss}\hfil}
\nobreak\vskip-\baselineskip
\fi
}
\noindent
A work in progress, {\tt JSBox} is a self-contained
library---written in portable C---that instantiates sandbox-able,
\TeX-language interpreters within the memory space
of any C, Objective-C, or C++ 32- or 64-bit client
program. Built and documented anew, {\tt JSBox}
is faithful to the \TeX\ language's primitives,
syntax, typesetting algorithms, measurements, data
structures, and speed. At the same time, it fixes---in an
upwardly compatible manner---a variety of important
problems with or lacunæ in the current \TeX\ engine's
implementation. These include integral support for
21-bit Unicode, namespaces, OpenType font tables
and metrics, job-specific 8-bit to 21-bit Unicode
mapping, run-time settable compatibility levels,
full 32-bit fixed-point math, and more.
Especially pertinent to interactive applications---such as an
eBook reader---is that all of a document's pages can
optionally be kept as \TeX\ data structures in memory
after a job is done, with direct random access of any
requested page exported to the client program's screen
without file I/O or DVI or PDF conversion if unneeded.
Tracing (including recursive expansion, re-tracing
interrupted commands, alignments, math, etc.) and
all error messages have been significantly improved
over what \TeX\ does. The author will demo what
{\tt JSBox} can do now, and discuss what it
could do in the future.
A work in progress, {\tt JSBox} is a self-contained
library---written in portable C---that instantiates sandbox-able,
\TeX-language interpreters within the memory space
of any C, Objec\-tive-C, or C++ 32- or 64-bit client
program. Built and documented anew, {\tt JSBox}
is faithful to the \TeX\ language's primitives,
syntax, typesetting algorithms, measurements, data
structures, and speed. At the same time, it fixes
in an
upwardly compatible manner---a variety of important
problems with or lacunæ in the current \TeX\ engine's
implementation. These include integral support for
21-bit Unicode, namespaces, OpenType font tables
and metrics, job-specific 8-bit to 21-bit Unicode
mapping, run-time settable compatibility levels,
full 32-bit fixed-point math, and more. Especially
pertinent to interactive applications---such as an
eBook reader---is that all of a document's pages can
optionally be kept as \TeX\ data structures in memory
after a job is done, with direct random access of any
requested page exported to the client program's screen
without file I/O or DVI or PDF conversion if unneeded.
Tracing (including recursive expansion, re-tracing
interrupted commands, alignments, math, etc.) and
all error messages have been significantly improved
over what \TeX\ does. The author will demo what
{\tt JSBox} can do now, and discuss what it
could do in the future.
\flowpic from 11 minus 0 width -7cm {greybox.png}{The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog.}
A work in progress, {\tt JSBox} is a self-contained
library---written in portable C---that instantiates sandbox-able,
\TeX-language interpreters within the memory space
of any C, Objective-C, or C++ 32- or 64-bit client
program. Built and documented anew, {\tt JSBox}
is faithful to the \TeX\ language's primitives,
syntax, typesetting algorithms, measurements, data
structures, and speed. At the same time, it fixes---in an
upwardly compatible manner---a variety of important
problems with or lacunæ in the current \TeX\ engine's
implementation. These include integral support for
21-bit Unicode, namespaces, OpenType font tables
and metrics, job-spe\-cific 8-bit to 21-bit Unicode
mapping, run-time settable compatibility levels,
full 32-bit\nobreak\ fixed-point math, and more.
Especially pertinent to interactive applications---such as an
eBook reader---is that all of a document's pages
can optionally be kept as \TeX\ data structures in memory
after a job is done, with direct random access of any
requested page exported to the client program's screen
without file I/O or DVI or PDF conversion if unneeded.
Tracing (including recursive expansion, re-tracing
interrupted commands, alignments, math, etc.) and
all error messages have been significantly improved
over what \TeX\ does. The author will demo what
{\tt JSBox} can do now, and discuss what it
could do in the future.
A work in progress, {\tt JSBox} is a self-contained
library---written in portable C---that instantiates sandbox-able,
\TeX-language interpreters within the memory space
of any C, Objective-C, or C++ 32- or 64-bit client
program. Built and documented anew, {\tt JSBox}
is faithful to the \TeX\ language's primitives,
syntax, typesetting algorithms, measurements, data
structures, and speed. At the same time, it fixes---in an
upwardly compatible manner---a variety of important
problems with or lacunæ in the current \TeX\ engine's
implementation. These include integral support for
21-bit Unicode, namespaces, OpenType font tables
and metrics, job-specific 8-bit to 21-bit Unicode
mapping, run-time settable compatibility levels,
full 32-bit fixed-point math, and more.
These include integral support for
21-bit Unicode, namespaces, OpenType font tables
and metrics, job-specific 8-bit to 21-bit Unicode
mapping, run-time settable compatibility levels,
full 32-bit fixed-point\nobreak\ math, and more. These include integral support for
21-bit Unicode,{\parfillskip=0pt\par}
\flowpic from 1 minus 0 width -7cm {greybox.png}{The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog.}
\noindent namespaces, OpenType font tables
and metrics, job-specific 8-bit to 21-bit Unicode
mapping, run-time settable compatibilitylevels,
full 32-bit fixed-point math, and more. Especially
pertinent to interactive applications---such as an
eBook reader---is that all of a document's pages can
optionally be kept as \TeX\ data structures in memory
after a job is done, with direct random access of any
requested page exported to the client program's screen
without file I/O or DVI or PDF conversion if unneeded.
Tracing (including recursive expansion, re-tracing
interrupted commands, alignments, math, etc.) and
all error messages have been significantly improved
over what \TeX\ does. The author will demo what
{\tt JSBox} can do now, and discuss what it
could do in the future.
A work in progress, {\tt JSBox} is a self-contained
library---written in portable C---that instantiates sandbox-able,
\TeX-language interpreters within the memory space
of any C, Objective-C, or C++ 32- or 64-bit client
program. Built and documented anew, {\tt JSBox}
is faithful to the \TeX\ language's primitives,
syntax, typesetting algorithms, measurements, data
structures, and speed. At the same time, it fixes---in an
upwardly compatible manner---a variety of important %\nobreak\
problems with or lacunæ in the current \TeX\ engine's
implementation. These include integral support for
21-bit Unicode, namespaces, OpenType font tables
and metrics, job-specific 8-bit to 21-bit Unicode
mapping, run-time settable compatibility levels,
full 32-bit fixed-point math, and more. Especially
pertinent to interactive applications---such as an
eBook reader---is that all of a document's pages can
optionally be kept as \TeX\ data structures in memory
after a job is done, with direct random access of any
requested page exported to the client program's screen
without file I/O or DVI or PDF conversion if unneeded.
Tracing (including recursive expansion, re-tracing
interrupted commands, alignments, math, etc.) and
all error messages have been significantly improved
over what \TeX\ does. The author will demo what
{\tt JSBox} can do now, and discuss what it
could do in the future.
\bye
As you can see, the picture on page 2 is moved to the left:

(also note the wider caption below the picture). The strange thing is that when I remove the (re)declaration of \rm, so cmr10 is used, the image isn't moved to the left (the use of Minion Italic in the caption apparently doesn't matter).
Why is this? Is this a bug in XeTeX?
\flowpic. The\partoken at the end of the\vbox(... \noindent\it #5\par}...) is the source of the problem: this token is temporary redefined as a macro and it works as this (unwanted) macro when caption is formatted. Remove this token\par. The end of paragraph is processed at the end of\vboxwithout explicitly\partoken, so it needn't to be here. Or replace the token\parby\endgrafhere. – wipet Dec 30 '14 at 16:02\brokenpenaltyregister. But I was successful after little tests with cmr10 only. – wipet Dec 31 '14 at 03:56