summaryrefslogtreecommitdiff
path: root/tex/generic
diff options
context:
space:
mode:
authorHans Hagen <pragma@wxs.nl>2013-04-05 22:00:00 +0200
committerHans Hagen <pragma@wxs.nl>2013-04-05 22:00:00 +0200
commit67eb8a2fa983fc472649cfdcb5b4a6ebe4739f62 (patch)
treeffa5a2fdbf7b456c7afbb3b947e5d31241f49375 /tex/generic
parent94cf6213fbed1c43b46b4debdf05b682d5dba543 (diff)
downloadcontext-67eb8a2fa983fc472649cfdcb5b4a6ebe4739f62.tar.gz
beta 2013.04.05 22:00
Diffstat (limited to 'tex/generic')
-rw-r--r--tex/generic/context/luatex/luatex-fonts-merged.lua29
-rw-r--r--tex/generic/context/luatex/luatex-swiglib-test.lua25
-rw-r--r--tex/generic/context/luatex/luatex-swiglib-test.tex11
-rw-r--r--tex/generic/context/luatex/luatex-swiglib.lua62
-rw-r--r--tex/generic/context/luatex/luatex-swiglib.tex20
5 files changed, 139 insertions, 8 deletions
diff --git a/tex/generic/context/luatex/luatex-fonts-merged.lua b/tex/generic/context/luatex/luatex-fonts-merged.lua
index 820ea3852..d1b4bcda9 100644
--- a/tex/generic/context/luatex/luatex-fonts-merged.lua
+++ b/tex/generic/context/luatex/luatex-fonts-merged.lua
@@ -1,6 +1,6 @@
-- merged file : luatex-fonts-merged.lua
-- parent file : luatex-fonts.lua
--- merge date : 04/02/13 11:22:33
+-- merge date : 04/05/13 22:00:23
do -- begin closure to overcome local limits and interference
@@ -123,7 +123,7 @@ local function addpath(what,paths,extras,hash,...)
local path=cleanpath(path)
if not hash[path] then
if trace then
- report("! extra %s path: %s",what,path)
+ report("extra %s path: %s",what,path)
end
paths [#paths+1]=path
extras[#extras+1]=path
@@ -157,13 +157,13 @@ searchers[3]=nil
local function loadedaslib(resolved,rawname)
local init="luaopen_"..gsub(rawname,"%.","_")
if helpers.trace then
- helpers.report("! calling loadlib with '%s' with init '%s'",resolved,init)
+ helpers.report("calling loadlib with '%s' with init '%s'",resolved,init)
end
return package.loadlib(resolved,init)
end
local function loadedbylua(name)
if helpers.trace then
- helpers.report("! locating '%s' using normal loader",name)
+ helpers.report("locating '%s' using normal loader",name)
end
return true,searchers[-2](name)
end
@@ -171,17 +171,17 @@ local function loadedbypath(name,rawname,paths,islib,what)
local trace=helpers.trace
local report=helpers.report
if trace then
- report("! locating '%s' as '%s' on '%s' paths",rawname,name,what)
+ report("locating '%s' as '%s' on '%s' paths",rawname,name,what)
end
for p=1,#paths do
local path=paths[p]
local resolved=filejoin(path,name)
if trace then
- report("! checking for '%s' using '%s' path '%s'",name,what,path)
+ report("checking for '%s' using '%s' path '%s'",name,what,path)
end
if isreadable(resolved) then
if trace then
- report("! lib '%s' located on '%s'",name,resolved)
+ report("lib '%s' located on '%s'",name,resolved)
end
if islib then
return true,loadedaslib(resolved,rawname)
@@ -10704,6 +10704,19 @@ function definers.loadfont(specification)
end
return tfmdata
end
+local function checkvirtual(tfmdata)
+ local fonts=tfmdata.fonts
+ local selfid=font.nextid()
+ if fonts and #fonts>0 then
+ for i=1,#fonts do
+ if fonts[i][2]==0 then
+ fonts[i][2]=selfid
+ end
+ end
+ else
+ tfmdata.fonts={ "id",selfid }
+ end
+end
function constructors.readanddefine(name,size)
local specification=definers.analyze(name,size)
local method=specification.method
@@ -10716,7 +10729,7 @@ function constructors.readanddefine(name,size)
if not id then
local tfmdata=definers.loadfont(specification)
if tfmdata then
- tfmdata.properties.hash=hash
+ checkvirtual(tfmdata)
id=font.define(tfmdata)
definers.register(tfmdata,id)
else
diff --git a/tex/generic/context/luatex/luatex-swiglib-test.lua b/tex/generic/context/luatex/luatex-swiglib-test.lua
new file mode 100644
index 000000000..db6a72909
--- /dev/null
+++ b/tex/generic/context/luatex/luatex-swiglib-test.lua
@@ -0,0 +1,25 @@
+local gm = swiglib("gmwand.core")
+
+gm.InitializeMagick(".")
+
+local magick_wand = gm.NewMagickWand()
+local drawing_wand = gm.NewDrawingWand()
+
+gm.MagickSetSize(magick_wand,800,600)
+gm.MagickReadImage(magick_wand,"xc:red")
+
+gm.DrawPushGraphicContext(drawing_wand)
+
+gm.DrawSetFillColor(drawing_wand,gm.NewPixelWand())
+
+-- gm.DrawSetFont(drawing_wand, kpse.findfile("DejaVuSerifBold.ttf"))
+-- gm.DrawSetFontSize(drawing_wand, 96)
+-- gm.DrawAnnotation(drawing_wand,300,200, "LuaTeX")
+
+gm.DrawPopGraphicContext(drawing_wand)
+gm.MagickDrawImage(magick_wand,drawing_wand)
+
+gm.MagickWriteImages(magick_wand,"./luatex-swiglib-test.jpg",1)
+
+gm.DestroyDrawingWand(drawing_wand)
+gm.DestroyMagickWand(magick_wand)
diff --git a/tex/generic/context/luatex/luatex-swiglib-test.tex b/tex/generic/context/luatex/luatex-swiglib-test.tex
new file mode 100644
index 000000000..d26bb6ffb
--- /dev/null
+++ b/tex/generic/context/luatex/luatex-swiglib-test.tex
@@ -0,0 +1,11 @@
+% luatex --fmt=luatex=plain luatex-swiglib-test.tex
+
+\input luatex-swiglib.tex
+
+\directlua {
+ dofile("luatex-swiglib-test.lua")
+}
+
+\pdfximage {luatex-swiglib-test.jpg} \pdfrefximage\pdflastximage
+
+\end
diff --git a/tex/generic/context/luatex/luatex-swiglib.lua b/tex/generic/context/luatex/luatex-swiglib.lua
new file mode 100644
index 000000000..7ffcdc375
--- /dev/null
+++ b/tex/generic/context/luatex/luatex-swiglib.lua
@@ -0,0 +1,62 @@
+if not modules then modules = { } end modules ['luatex-swiglib'] = {
+ version = 1.001,
+ comment = "companion to luatex-swiglib.tex",
+ author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
+ copyright = "PRAGMA ADE / ConTeXt Development Team",
+ license = "see context related readme files"
+}
+
+local savedrequire = require
+
+local libsuffix = os.type == "windows" and ".dll" or ".so"
+
+function requireswiglib(required,version)
+ local library = package.loaded[required]
+ if library then
+ return library
+ else
+ local name = string.gsub(required,"%.","/") .. libsuffix
+ local list = kpse.show_path("clua")
+ for root in string.gmatch(list,"([^;]+)") do
+ local full = false
+ if type(version) == "string" and version ~= "" then
+ full = root .. "/" .. version .. "/" .. name
+ full = lfs.isfile(full) and full
+ end
+ if not full then
+ full = root .. "/" .. name
+ full = lfs.isfile(full) and full
+ end
+ if full then
+ local path, base = string.match(full,"^(.-)([^\\/]+)" .. libsuffix .."$")
+ local savedlibrary = package.loaded[base]
+ package.loaded[base] = nil
+ local savedpath = lfs.currentdir()
+ lfs.chdir(path)
+ library = package.loadlib(full,"luaopen_" .. base)
+ if type(library) == "function" then
+ library = library()
+ texio.write("<swiglib: '",required,"' is loaded>")
+ end
+ lfs.chdir(savedpath)
+ package.loaded[base] = savedlibrary
+ package.loaded[required] = library
+ return library
+ end
+ end
+ texio.write("<swiglib: '",name,"'is not found on '",list,"'")
+ end
+ texio.write("<swiglib: '",required,"' is not found>")
+end
+
+function require(name)
+ if string.find(name,"^swiglib%.") then
+ return requireswiglib(name)
+ else
+ return savedrequire(name)
+ end
+end
+
+function swiglib(name,version)
+ return requireswiglib("swiglib." .. name,version)
+end
diff --git a/tex/generic/context/luatex/luatex-swiglib.tex b/tex/generic/context/luatex/luatex-swiglib.tex
new file mode 100644
index 000000000..7c4377515
--- /dev/null
+++ b/tex/generic/context/luatex/luatex-swiglib.tex
@@ -0,0 +1,20 @@
+%D \module
+%D [ file=luatex-swiglib,
+%D version=2013.03.30,
+%D title=\LUATEX\ Support Macros,
+%D subtitle=Generic \SWIGLIB\ Font Handler,
+%D author=Hans Hagen,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+
+%D This is an experimental setup. Usage:
+%D
+%D \starttyping
+%D local gm = swiglib("gmwand.core")
+%D local gm = require("swiglib.gmwand.core")
+%D local sq = swiglib("mysql.core")
+%D local sq = swiglib("mysql.core","5.6")
+%D \stoptyping
+
+\directlua {
+ dofile(kpse.find_file("luatex-swiglib.lua","tex"))
+}