summaryrefslogtreecommitdiff
path: root/tex/context/base/mkii/spec-xet.mkii
blob: 0cbd55ba7fdef6bfcaab17ff08e2f39c69bd7950 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
%D \module
%D   [       file=spec-xtx,
%D        version=2004.11.08,
%D          title=\CONTEXT\ Special Macros,
%D       subtitle=\XETEX\ support,
%D         author={Adam Lindsay \& Hans Hagen \& \unknown},
%D           date=\currentdate,
%D      copyright={Adam Lindsay \& Hans Hagen}]

\unprotect

\definespecial\doinsertfile
  {\dofileinsertion{xtx}\@@DriverImageType}

\definefileinsertion{xtx}{jpg}{\xtxhandleotherimage}
\definefileinsertion{xtx}{png}{\xtxhandleotherimage}
\definefileinsertion{xtx}{gif}{\xtxhandleotherimage}
\definefileinsertion{xtx}{tif}{\xtxhandleotherimage}
\definefileinsertion{xtx}{pdf}{\xtxhandlepdfimage  }

\def\checkpdfimagepagenumber
  {\edef\pdfimagepagenumber
     {\ifx\@@DriverImagePage\empty\else\ifnum\@@DriverImagePage>\zerocount
        \space page\space\@@DriverImagePage\space
      \fi\fi}}

\def\xtxhandleotherimage
  {\XeTeXpicfile "\@@DriverImageFile"
     \ifdim\@@DriverImageWidth >\zeropoint \!!width  \@@DriverImageWidth \space\fi
     \ifdim\@@DriverImageHeight>\zeropoint \!!height \@@DriverImageHeight      \fi
   \relax}

\def\xtxhandlepdfimage
  {\checkpdfimagepagenumber
   \XeTeXpdffile "\@@DriverImageFile"
     \pdfimagepagenumber
     \ifdim\@@DriverImageWidth >\zeropoint \!!width  \@@DriverImageWidth \space\fi
     \ifdim\@@DriverImageHeight>\zeropoint \!!height \@@DriverImageHeight      \fi
   \relax}

\def\dogetXTXfiguresize
  {\setbox\foundexternalfigure\vbox{\XeTeXpicfile "\@@DriverImageFile"\relax}%
   \xdef\analyzedfigurewidth {\the\wd\foundexternalfigure}%
   \xdef\analyzedfigureheight{\the\ht\foundexternalfigure}}

\def\dogetXTXpdfsize
  {\checkpdfimagepagenumber
   \setbox\foundexternalfigure\vbox{\XeTeXpdffile "\@@DriverImageFile" \pdfimagepagenumber\relax}%
   \xdef\analyzedfigurewidth {\the\wd\foundexternalfigure}%
   \xdef\analyzedfigureheight{\the\ht\foundexternalfigure}}

\definefilechecker{xtx}{png}{\dogetXTXfiguresize}
\definefilechecker{xtx}{jpg}{\dogetXTXfiguresize}
\definefilechecker{xtx}{gif}{\dogetXTXfiguresize}
\definefilechecker{xtx}{tif}{\dogetXTXfiguresize}
\definefilechecker{xtx}{pdf}{\dogetXTXpdfsize   }

\definespecial\dogetfiguresize
  {\dofilechecker{xtx}\@@DriverImageType}

%D The figure object system caused no end of headaches. They all
%D went away with this single line:

\setupexternalfigures[\c!object=\v!no]

\protect \endinput