local class = ltjf_find_char_class(p.char, met)
set_attr(r, attr_jchar_class, class)
ltjw.char_data = ltjf.metrics[met.jfm].size_cache[met.size].char_type[class]
- ltjw.head = r; ltjw.capsule_glyph(r, tex.mathdir , true);
+ ltjw.head = r; ltjw.capsule_glyph(r, tex.mathdir , true, met, class);
q.head = ltjw.head; node_free(p); p=q;
end
end
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
char_data = {}
return p.font==has_attr(p, attr_curjfnt)
end
+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)
- local h, box, q, fwidth, fheight, fdepth
- p.xoffset= p.xoffset - char_data.left
+function capsule_glyph(p, dir, mode, met, class)
+ local h, box, q, fwidth
if char_data.width ~= 'prop' then
fwidth = char_data.width
else fwidth = p.width end
- fheight = char_data.height
- fdepth = char_data.depth
+ 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 = -char_data.down
+ p.yoffset = -fshift.down
head, q = node.remove(head, p)
local total = fwidth - p.width
if total == 0 then
end
return q
else
- p.yoffset = p.yoffset - (has_attr(p, attr_yablshift) or 0) - char_data.down
+ p.yoffset = p.yoffset - (has_attr(p, attr_yablshift) or 0) - fshift.down
return node_next(p)
end
end
if p.id==id_glyph then
if is_japanese_glyph_node(p) then
local met = ltjf.font_metric_table[p.font]
- char_data = ltjf.metrics[met.jfm].size_cache[met.size].char_type[has_attr(p, attr_jchar_class)]
- p = capsule_glyph(p, dir, false)
+ 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
--- /dev/null
+
+luatexja.jfont.define_jfm {
+ dir = 'yoko',
+ zw = 1.0, zh = 1.0,
+
+ [0] = {
+ align = 'left', left = 0.0, down = 0.0,
+ width = 1.0, height = 0.5, depth = 0.50
+ },
+
+ [99] = { -- box末尾
+ chars = {'boxbdd', 'parbdd'},
+ },
+
+}
\ No newline at end of file
%#!lualatex
\documentclass{ltjarticle}
+\usepackage[margin=20mm]{geometry}
\begin{document}
\noindent 漢字漢字ちょっと\textgt{チェック}
「漢字←全角二分下がり?\\
「あいうえお」\textgt{「かきくけこ」}{\Large 「}
-次の例は「\texttt{min10}フォントについて」(乙部厳己)中のp.~8から拝借.
-
+次ページ以下の例は「\texttt{min10}フォントについて」(乙部厳己)中のp.~8から拝借.
\def\g#1#2#3{\leavevmode\vbox{\hsize=100pt%
\hrule height 1pt depth 0pt
-\vskip#3pt\hbox{\jfont\e=file:#1:jfm=#2 at 20pt\e あいうえお}\vskip-#3pt
+\vskip#3pt\hbox{\vrule width 40pt height 0.2pt depth 0.2pt\kern-40pt
+\jfont\e=file:#1:jfm=#2 at 20pt\e あいう◆漢}\vskip-#3pt
\hrule height 0pt depth 1pt}: #1, jfm=#2, yjabaselineshift=#3pt\par\bigskip}
+\newpage
+\paragraph{valign.luaなし}\
+
+\g{KozGoPr6N-Medium.otf}{ujis}{0}
+\g{KozGoPr6N-Medium.otf}{jis}{0.7563636}
+\g{KozGoPr6N-Medium.otf}{jis}{0}
+\g{ipaexg.ttf}{ujis}{0}
+\g{ipaexg.ttf}{jis}{0.7563636}
+\g{ipaexg.ttf}{jis}{0}
+\g{hgrgm.ttc}{ujis}{0}
+\g{hgrgm.ttc}{jis}{0}
+\g{hgrgm.ttc}{jis}{0.7563636}
+
+\g{KozGoPr6N-Medium.otf}{test2}{0}
+\g{ipaexg.ttf}{test2}{0}
+\g{hgrgm.ttc}{test2}{0}
+
+\newpage
+\directlua{dofile('valign.lua')}
+\paragraph{valign.luaあり}\
+
\g{KozGoPr6N-Medium.otf}{ujis}{0}
\g{KozGoPr6N-Medium.otf}{jis}{0.7563636}
\g{KozGoPr6N-Medium.otf}{jis}{0}
\g{hgrgm.ttc}{jis}{0}
\g{hgrgm.ttc}{jis}{0.7563636}
+\g{KozGoPr6N-Medium.otf}{test2}{0}
+\g{ipaexg.ttf}{test2}{0}
+\g{hgrgm.ttc}{test2}{0}
\end{document}
\ No newline at end of file
--- /dev/null
+require('luatexja.base'); local ltjb = luatexja.base
+require('luatexja.jfont'); local ltjf = luatexja.jfont
+
+local round = tex.round
+
+local attr_curjfnt = luatexbase.attributes['ltj@curjfnt']
+local attr_jchar_class = luatexbase.attributes['ltj@charclass']
+local attr_yablshift = luatexbase.attributes['ltj@yablshift']
+local attr_ykblshift = luatexbase.attributes['ltj@ykblshift']
+
+local ltjf_font_metric_table = ltjf.font_metric_table
+local ltjf_find_char_class = ltjf.find_char_class
+
+local function set_valign(fmtable, fn)
+ local fi = fonts.ids[fn]
+ local fa = fi.ascender / (fi.ascender + fi.descender)
+ local mt = ltjf.metrics[fmtable.jfm].char_type[0]
+ local ma = mt.height / (mt.height + mt.depth)
+ fmtable.down_offset = round((fa - ma)*fi.size)
+ print('loading :', fn, fmtable.down_offset)
+ return fmtable
+end
+luatexbase.add_to_callback("luatexja.define_jfont",
+ set_valign, "ltj.valign.define_jfont", 1)
+-- ´û¤ËÆɤ߹þ¤Þ¤ì¤Æ¤¤¤ë¥Õ¥©¥ó¥È¤ËÂФ·¤Æ¤â¡¤Æ±¤¸¤³¤È¤ò¤ä¤é¤Ê¤¤¤È¤¤¤±¤Ê¤¤
+for fn, v in pairs(ltjf_font_metric_table) do
+ ltjf_font_metric_table[fn] = set_valign(v, fn)
+end
+
+local function get_valign (fstable, fmtable, jchar_class)
+ local d = fmtable.down_offset or 0
+ fstable.down = fstable.down + d
+ return fstable
+end
+
+luatexbase.add_to_callback("luatexja.set_width",
+ get_valign, "ltj.valign.define_jfont", 1)