[latex3-commits] [git/LaTeX3-latex3-xxetex] main: graphics inclusion (5c46e2e)
David Carlisle
d.p.carlisle at gmail.com
Sat Jan 28 15:39:54 CET 2023
Repository : https://github.com/latex3/xxetex
On branch : main
Link : https://github.com/latex3/xxetex/commit/5c46e2e65c589a1d99d39d1cb214caa56dec3ca7
>---------------------------------------------------------------
commit 5c46e2e65c589a1d99d39d1cb214caa56dec3ca7
Author: David Carlisle <d.p.carlisle at gmail.com>
Date: Sat Jan 28 14:39:54 2023 +0000
graphics inclusion
>---------------------------------------------------------------
5c46e2e65c589a1d99d39d1cb214caa56dec3ca7
examples/test-pic1.tex | 36 ++++++++++++++++++++++++++++++++++++
xxetex.lua | 49 +++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 85 insertions(+)
diff --git a/examples/test-pic1.tex b/examples/test-pic1.tex
new file mode 100644
index 0000000..e05c81c
--- /dev/null
+++ b/examples/test-pic1.tex
@@ -0,0 +1,36 @@
+\ifdefined\directlua
+\ifdefined\XeTeXinterchartokenstate\else
+\input{xxetex.tex}
+\fi
+\fi
+
+\addtolength\textwidth{200pt}
+\documentclass{article}
+
+\begin{document}
+
+
+1: [\XeTeXpicfile example-image.png ]
+
+
+2: [\XeTeXpicfile example-image.png scaled 500 ]
+
+
+3: [\XeTeXpicfile example-image.png width 3cm ]
+
+
+4: [\XeTeXpicfile example-image.png rotated 90 ]
+
+\clearpage
+
+5: [\XeTeXpicfile example-image.png width 3cm rotated 90 ]
+
+6: [\XeTeXpicfile example-image.png rotated 90 width 3cm ]
+
+\clearpage
+
+7: [\XeTeXpicfile example-image.png width 3cm height 3cm ]
+
+8: [\XeTeXpicfile example-image.png height 3cm width 3cm ]
+
+\end{document}
diff --git a/xxetex.lua b/xxetex.lua
index 63720f9..66e87f0 100644
--- a/xxetex.lua
+++ b/xxetex.lua
@@ -196,6 +196,55 @@ local function xxetexinterchartoks(head)
return head
end
+-- graphics
+
+
+
+
+local function XeTeXpicfile()
+local filename = token.scan_string()
+local t=img.scan{filename=filename}
+--local t ={}
+--t.filename = token.scan_string()
+local scan=false
+-- ignore key order for now
+repeat
+ scan=false
+ token.scan_keyword(' ')
+ local scale=1
+ if token.scan_keyword('scaled') then
+ scan=true
+ scale= 0.0001*token.scan_int()
+ -- t.width=scale*t.xsize
+ -- t.height=scale*t.ysize
+ end
+ token.scan_keyword(' ')
+ if token.scan_keyword('width') then
+ scan=true
+ t.width= token.scan_dimen()
+ end
+ token.scan_keyword(' ')
+ if token.scan_keyword('height') then
+ scan=true
+ t.height= token.scan_dimen()
+ end
+ token.scan_keyword(' ')
+ if token.scan_keyword('rotated') then
+ -- full coverage would need to wrap image
+ scan=true
+ local angle=token.scan_real()
+ if angle==90 then
+ t.transform= 1
+ end
+ end
+until not(scan)
+img.write(t)
+end
+local func = luatexbase.new_luafunction 'XeTeXpicfile'
+lua.get_functions_table()[func] = XeTeXpicfile
+token.set_lua('XeTeXpicfile', func , "protected")
+token.set_lua('XeTeXpdffile', func , "protected")
+
return {
XeTeXfonttype = XeTeXfonttype,
XeTeXfirstfontchar = XeTeXfirstfontchar,
More information about the latex3-commits
mailing list.