summaryrefslogtreecommitdiff
path: root/tex/context/base/mkxl/driv-usr.lmt
diff options
context:
space:
mode:
Diffstat (limited to 'tex/context/base/mkxl/driv-usr.lmt')
-rw-r--r--tex/context/base/mkxl/driv-usr.lmt261
1 files changed, 220 insertions, 41 deletions
diff --git a/tex/context/base/mkxl/driv-usr.lmt b/tex/context/base/mkxl/driv-usr.lmt
index 2dc3cda73..5ff601f2a 100644
--- a/tex/context/base/mkxl/driv-usr.lmt
+++ b/tex/context/base/mkxl/driv-usr.lmt
@@ -14,6 +14,8 @@ local getdirection = nuts.getdirection
local getlist = nuts.getlist
local getoffsets = nuts.getoffsets
local getorientation = nuts.getorientation
+local getanchors = nuts.getanchors
+local getgeometry = nuts.getgeometry
local getwhd = nuts.getwhd
local getkern = nuts.getkern
local getwidth = nuts.getwidth
@@ -67,6 +69,7 @@ local pos_h = 0
local pos_v = 0
local pos_r = lefttoright_code
+local applyorientation = drivers.applyorientation
local applyanchor = drivers.applyanchor
local initialize
@@ -119,42 +122,88 @@ hlist_out = function(this_box,current)
local list = getlist(current)
if list then
local boxdir = getdirection(current) or lefttoright_code
- local shift, orientation = getshift(current)
- if not orientation then
- local basepoint_h = boxdir ~= pos_r and width or 0
- if pos_r == righttoleft_code then
- pos_h = ref_h - (cur_h + basepoint_h)
- else
- pos_h = ref_h + (cur_h + basepoint_h)
- end
- pos_v = ref_v - shift
- elseif orientation == 0x1000 then
- local orientation, xoffset, yoffset = getorientation(current)
- local basepoint_h = boxdir ~= pos_r and width or 0
- if pos_r == righttoleft_code then
- pos_h = ref_h - (cur_h + basepoint_h + xoffset)
- else
- pos_h = ref_h + (cur_h + basepoint_h + xoffset)
- end
- pos_v = ref_v - (shift - yoffset)
- else
+ local shift = getshift(current)
+ local geometry, hasoffset, hasorientation, hasanchor = getgeometry(current,true)
+ local anchor, source, target, targetdata
+ local anc_h, anc_v
+ local usedorientation = false
+ if hasanchor then
+ anchor, source, target = getanchors(current)
+ end
+ if hasorientation then
local orientation, xoffset, yoffset, woffset, hoffset, doffset = getorientation(current)
- local orientation, basepoint_h, basepoint_v = applyanchor(orientation,0,shift,width,height,depth,woffset,hoffset,doffset,xoffset,yoffset)
+ local orientation, basepoint_h, basepoint_v = applyorientation(orientation,0,shift,width,height,depth,woffset,hoffset,doffset,xoffset,yoffset)
if orientation == 1 then
basepoint_h = basepoint_h + doffset
if boxdir == pos_r then
basepoint_v = basepoint_v - height
end
+ usedorientation = orientation
elseif orientation == 2 then
if boxdir == pos_r then
basepoint_h = basepoint_h + width
end
+ usedorientation = orientation
elseif orientation == 3 then
basepoint_h = basepoint_h + hoffset
if boxdir ~= pos_r then
basepoint_v = basepoint_v - height
end
+ usedorientation = orientation
+ end
+ if target then
+ targetdata = anchors[target]
+ if targetdata then
+ anc_h = basepoint_h
+ anc_v = - basepoint_v
+ goto posdone
+ end
+ end
+ if pos_r == righttoleft_code then
+ pos_h = ref_h - (cur_h + basepoint_h)
+ else
+ pos_h = ref_h + (cur_h + basepoint_h)
+ end
+ -- pos_v = ref_v - (cur_v + basepoint_v)
+ pos_v = ref_v - basepoint_v
+ elseif hasoffset then
+ local orientation, xoffset, yoffset = getorientation(current)
+ local basepoint_h = boxdir ~= pos_r and width or 0
+ local basepoint_v = shift
+ if target then
+ targetdata = anchors[target]
+ if targetdata then
+ anc_h = xoffset + basepoint_h
+ anc_v = yoffset - basepoint_v
+ goto posdone
+ end
+ end
+ if pos_r == righttoleft_code then
+ pos_h = ref_h - (cur_h + basepoint_h + xoffset)
+ else
+ pos_h = ref_h + (cur_h + basepoint_h + xoffset)
+ end
+ pos_v = ref_v - (basepoint_v - yoffset)
+ elseif hasanchor then
+ local basepoint_h = boxdir ~= pos_r and width or 0
+ local basepoint_v = shift
+ if target then
+ targetdata = anchors[target]
+ if targetdata then
+ anc_h = basepoint_h
+ anc_v = - basepoint_v
+ goto posdone
+ end
+ end
+ if pos_r == righttoleft_code then
+ pos_h = ref_h - (cur_h + basepoint_h)
+ else
+ pos_h = ref_h + (cur_h + basepoint_h)
end
+ pos_v = ref_v - basepoint_v
+ else
+ local basepoint_h = boxdir ~= pos_r and width or 0
+ local basepoint_v = shift
if pos_r == righttoleft_code then
pos_h = ref_h - (cur_h + basepoint_h)
else
@@ -162,13 +211,47 @@ hlist_out = function(this_box,current)
end
pos_v = ref_v - basepoint_v
end
+ goto process
+ ::posdone::
+ if pos_r == righttoleft_code then
+ pos_h = targetdata[1] - anc_h
+ else
+ pos_h = targetdata[1] + anc_h
+ end
+ pos_v = targetdata[2] + anc_v
+ if anchor and anchor > 0 then
+ pos_h, pos_v = applyanchor(anchor,true,pos_h,pos_v,targetdata[3],targetdata[4],targetdata[5])
+ pos_h, pos_v = applyanchor(anchor,false,pos_h,pos_v,width,height,depth)
+ end
+ ::process::
+ if source then
+ local anchor_h = pos_h
+ local anchor_v = pos_v
+ if usedorientation then
+ if usedorientation == 1 then
+ anchor_v = anchor_v - (width - height)
+ elseif usedorientation == 2 then
+ anchor_v = anchor_v - (depth - height)
+ elseif usedorientation == 3 then -- weird
+ anchor_v = anchor_v + (height - width)
+ end
+ end
+ anchors[source] = { anchor_h, anchor_v, width, height, depth }
+ end
+ -- if usedorientation then
+ -- pushorientation(usedorientation,pos_h,pos_v,pos_r)
+ -- end
if id == vlist_code then
vlist_out(current,list)
else
hlist_out(current,list)
end
+ -- if usedorientation then
+ -- poporientation(usedorientation,pos_h,pos_v,pos_r)
+ -- end
end
cur_h = cur_h + width
+
elseif id == kern_code then
local kern, factor = getkern(current,true)
if kern ~= 0 then
@@ -271,54 +354,150 @@ vlist_out = function(this_box,current)
local list = getlist(current)
if list then
local boxdir = getdirection(current) or lefttoright_code
- local shift, orientation = getshift(current)
- if not orientation then
- if boxdir ~= pos_r then
- shift = shift + width
+ local shift = getshift(current)
+ local geometry, hasoffset, hasorientation, hasanchor = getgeometry(current,true)
+ local anchor, source, target, targetdata
+ local usedorientation = false
+ if hasanchor then
+ anchor, source, target = getanchors(current)
+ end
+ if hasorientation then
+ local orientation, xoffset, yoffset, woffset, hoffset, doffset = getorientation(current)
+ local orientation, basepoint_h, basepoint_v = applyorientation(orientation,shift,height,width,height,depth,woffset,hoffset,doffset,xoffset,yoffset)
+ if orientation == 1 then
+ basepoint_h = basepoint_h + width - height -- hm
+ basepoint_v = basepoint_v - height
+ usedorientation = orientation
+ elseif orientation == 2 then
+ basepoint_h = basepoint_h + width
+ basepoint_v = basepoint_v + depth - height
+ usedorientation = orientation
+ elseif orientation == 3 then -- weird
+ basepoint_h = basepoint_h + height
+ usedorientation = orientation
+ end
+ if target then
+ targetdata = anchors[target]
+ if targetdata then
+ if pos_r == righttoleft_code then
+ pos_h = targetdata[1] - basepoint_h
+ else
+ pos_h = targetdata[1] + basepoint_h
+ end
+ pos_v = targetdata[2] - basepoint_v
+ goto posdone
+ end
end
if pos_r == righttoleft_code then
- pos_h = ref_h - shift
+ pos_h = ref_h - basepoint_h
else
- pos_h = ref_h + shift
+ pos_h = ref_h + basepoint_h
end
- pos_v = ref_v - (cur_v + height)
- elseif orientation == 0x1000 then
+ pos_v = ref_v - (cur_v + basepoint_v)
+ elseif hasoffset then
local orientation, xoffset, yoffset = getorientation(current)
+ -- local basepoint_h = shift
+ -- local basepoint_v = height
if boxdir ~= pos_r then
shift = shift + width
end
+ if target then
+ targetdata = anchors[target]
+ if targetdata then
+ if pos_r == righttoleft_code then
+ pos_h = targetdata[1] - (shift + xoffset)
+ else
+ pos_h = targetdata[1] + (shift + xoffset)
+ end
+ pos_v = targetdata[2] - (height - yoffset)
+ goto posdone
+ end
+ end
if pos_r == righttoleft_code then
pos_h = ref_h - (shift + xoffset)
else
pos_h = ref_h + (shift + xoffset)
end
pos_v = ref_v - (cur_v + height - yoffset)
+ elseif hasanchor then
+ -- local basepoint_h = shift
+ -- local basepoint_v = height
+ if boxdir ~= pos_r then
+ shift = shift + width
+ end
+ if target then
+ local a = anchors[target]
+ if a then
+ if pos_r == righttoleft_code then
+ pos_h = targetdata[1] - shift
+ else
+ pos_h = targetdata[1] + shift
+ end
+ pos_v = targetdata[2] - height
+ goto posdone
+ end
+ end
+ if pos_r == righttoleft_code then
+ pos_h = ref_h - shift
+ else
+ pos_h = ref_h + shift
+ end
+ pos_v = ref_v - (cur_v + height)
else
- local orientation, xoffset, yoffset, woffset, hoffset, doffset = getorientation(current)
- local orientation, basepoint_h, basepoint_v = applyanchor(orientation,shift,height,width,height,depth,woffset,hoffset,doffset,xoffset,yoffset)
- if orientation == 1 then
- basepoint_h = basepoint_h + width - height
- basepoint_v = basepoint_v - height
- elseif orientation == 2 then
- basepoint_h = basepoint_h + width
- basepoint_v = basepoint_v + depth - height
- elseif orientation == 3 then -- weird
- basepoint_h = basepoint_h + height
+ -- local basepoint_h = shift
+ -- local basepoint_v = height
+ if boxdir ~= pos_r then
+ shift = shift + width
end
if pos_r == righttoleft_code then
- pos_h = ref_h - basepoint_h
+ pos_h = ref_h - shift
else
- pos_h = ref_h + basepoint_h
+ pos_h = ref_h + shift
end
- pos_v = ref_v - (cur_v + basepoint_v)
+ pos_v = ref_v - (cur_v + height)
+ end
+ goto process
+ ::posdone::
+ if anchor and anchor > 0 then
+ pos_h, pos_v = applyanchor(anchor,true,pos_h,pos_v,targetdata[3],targetdata[4],targetdata[5])
+ pos_h, pos_v = applyanchor(anchor,false,pos_h,pos_v,width,height,depth)
+ end
+ ::process::
+ if source then
+ -- move this into apply_anchor
+ local anchor_h = pos_h
+ local anchor_v = pos_v
+ if usedorientation then
+ if usedorientation == 1 then
+ anchor_v = anchor_v - (width - height)
+ elseif usedorientation == 2 then
+ anchor_v = anchor_v - (depth - height)
+ elseif usedorientation == 3 then -- weird
+ anchor_v = anchor_v + (height - width)
+ end
+ end
+ anchors[source] = { anchor_h, anchor_v, width, height, depth }
end
+ -- if usedorientation then
+ -- pushorientation(usedorientation,pos_h,pos_v,pos_r)
+ -- end
+ -- if source then
+ -- flushstored(current,source,true)
+ -- end
if id == vlist_code then
vlist_out(current,list)
else
hlist_out(current,list)
end
+ -- if source then
+ -- flushstored(current,source,false)
+ -- end
+ -- if usedorientation then
+ -- poporientation(usedorientation,pos_h,pos_v,pos_r)
+ -- end
end
cur_v = cur_v + height + depth
+
elseif id == kern_code then
cur_v = cur_v + getkern(current)
elseif id == rule_code then