local attr_yablshift = luatexbase.attributes['ltj@yablshift']
local attr_icflag = luatexbase.attributes['ltj@icflag']
+local ltjf_font_metric_table = ltjf.font_metric_table
+
local PACKED = 2
-local met_tb = {}
-local char_data = {}
-local head
+char_data = {}
+head = nil
-- return true if and only if p is a Japanese character node
local function is_japanese_glyph_node(p)
return p.font==has_attr(p, attr_curjfnt)
end
-local function capsule_glyph(p, dir)
- local h, box, q, fwidth, fheight, fdepth
- p.xoffset= p.xoffset - round(met_tb.size*char_data.left)
+luatexbase.create_callback("luatexja.set_width", "data",
+ function (fstable, fmtable, jchar_class)
+ return fstable
+ end)
+
+local fshift = { down = 0, left = 0}
+-- mode: true iff p will be always encapsuled by a hbox
+function capsule_glyph(p, dir, mode, met, class)
+ local h, box, q, fwidth
if char_data.width ~= 'prop' then
- fwidth = round(char_data.width*met_tb.size)
+ fwidth = char_data.width
else fwidth = p.width end
- fheight = round(met_tb.size*char_data.height)
- fdepth = round(met_tb.size*char_data.depth)
- if p.width ~= fwidth or p.height ~= fheight or p.depth ~= fdepth then
+ local fheight = char_data.height
+ local fdepth = char_data.depth
+ fshift.down = char_data.down; fshift.left = char_data.left
+ fshift = luatexbase.call_callback("luatexja.set_width", fshift, met, class)
+-- local ti =
+ p.xoffset= p.xoffset - fshift.left
+ if mode or p.width ~= fwidth or p.height ~= fheight or p.depth ~= fdepth then
local y_shift = - p.yoffset + (has_attr(p,attr_yablshift) or 0)
- p.yoffset = -round(met_tb.size*char_data.down)
+ p.yoffset = -fshift.down
head, q = node.remove(head, p)
local total = fwidth - p.width
if total == 0 then
h = p; p.next = nil
else
h = node_new(id_kern); h.subtype = 0
- if char_data.align=='left' then
- h.kern = total; p.next = h; h = p
- elseif char_data.align=='right' then
+ if char_data.align=='right' then
h.kern = total; p.next = nil; h.next = p
elseif char_data.align=='middle' then
h.kern = round(total/2); p.next = h
h = node_new(id_kern); h.subtype = 0
h.kern = total - round(total/2); h.next = p
+ else -- left
+ h.kern = total; p.next = h; h = p
end
end
box = node_new(id_hlist);
end
return q
else
- p.yoffset = p.yoffset - (has_attr(p, attr_yablshift) or 0) - round(met_tb.size*char_data.down)
+ p.yoffset = p.yoffset - (has_attr(p, attr_yablshift) or 0) - fshift.down
return node_next(p)
end
end
while p do
if p.id==id_glyph then
if is_japanese_glyph_node(p) then
- met_tb = ltjf.font_metric_table[p.font]
- char_data = ltjf.metrics[met_tb.jfm].char_type[has_attr(p, attr_jchar_class)]
- p = capsule_glyph(p, dir)
+ local met = ltjf.font_metric_table[p.font]
+ local class = has_attr(p, attr_jchar_class)
+ char_data = ltjf.metrics[met.jfm].size_cache[met.size].char_type[class]
+ p = capsule_glyph(p, dir, false, met, class)
else
p.yoffset = p.yoffset - (has_attr(p,attr_yablshift) or 0); p = node_next(p)
end