OSDN Git Service
(root)
/
luatex-ja
/
luatexja.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
luatexja-preset.sty: 90jis/jis2004 only affect with mincho/gothic(/mg).
[luatex-ja/luatexja.git]
/
src
/
ltj-jfont.lua
diff --git
a/src/ltj-jfont.lua
b/src/ltj-jfont.lua
index
a942655
..
1b4d04d
100644
(file)
--- a/
src/ltj-jfont.lua
+++ b/
src/ltj-jfont.lua
@@
-3,8
+3,7
@@
--
luatexbase.provides_module({
name = 'luatexja.jfont',
--
luatexbase.provides_module({
name = 'luatexja.jfont',
- date = '2011/06/27',
- version = '0.1',
+ date = '2011/05/11',
description = 'Loader for Japanese fonts',
})
module('luatexja.jfont', package.seeall)
description = 'Loader for Japanese fonts',
})
module('luatexja.jfont', package.seeall)
@@
-16,6
+15,7
@@
local node_new = node.new
local has_attr = node.has_attribute
local set_attr = node.set_attribute
local round = tex.round
local has_attr = node.has_attribute
local set_attr = node.set_attribute
local round = tex.round
+local getfont = font.getfont
local attr_icflag = luatexbase.attributes['ltj@icflag']
local attr_curjfnt = luatexbase.attributes['ltj@curjfnt']
local attr_icflag = luatexbase.attributes['ltj@icflag']
local attr_curjfnt = luatexbase.attributes['ltj@curjfnt']
@@
-24,8
+24,9
@@
local id_kern = node.id('kern')
local id_glue_spec = node.id('glue_spec')
local id_glue = node.id('glue')
local cat_lp = luatexbase.catcodetables['latex-package']
local id_glue_spec = node.id('glue_spec')
local id_glue = node.id('glue')
local cat_lp = luatexbase.catcodetables['latex-package']
-local ITALIC = 1
-local FROM_JFM = 6
+local ITALIC = luatexja.icflag_table.ITALIC
+local FROM_JFM = luatexja.icflag_table.FROM_JFM
+
------------------------------------------------------------------------
-- LOADING JFM
------------------------------------------------------------------------
------------------------------------------------------------------------
-- LOADING JFM
------------------------------------------------------------------------
@@
-74,6
+75,9
@@
function define_jfm(t)
defjfm_res= nil; return
end
end
defjfm_res= nil; return
end
end
+ if type(v.align)~='string' then
+ v.align = 'left' -- left
+ end
if real_char then
if not (type(v.width)=='number' or v.width~='prop') then
defjfm_res= nil; return
if real_char then
if not (type(v.width)=='number' or v.width~='prop') then
defjfm_res= nil; return
@@
-93,9
+97,6
@@
function define_jfm(t)
if type(v.down)~='number' then
v.down = 0.0
end
if type(v.down)~='number' then
v.down = 0.0
end
- if type(v.align)~='string' then
- v.align = 'left'
- end
end
end
v.chars = nil
end
end
v.chars = nil
@@
-172,7
+173,7
@@
luatexbase.create_callback("luatexja.find_char_class", "data",
function find_char_class(c,m)
-- c: character code, m:
if not m then return 0 end
function find_char_class(c,m)
-- c: character code, m:
if not m then return 0 end
- return m.
size_cache.
chars[c] or
+ return m.chars[c] or
luatexbase.call_callback("luatexja.find_char_class", 0, m, c)
end
luatexbase.call_callback("luatexja.find_char_class", 0, m, c)
end
@@
-217,7
+218,7
@@
luatexbase.create_callback("luatexja.define_jfont", "data", function (ft, fn) re
function jfontdefY() -- for horizontal font
local j = load_jfont_metric()
local fn = font.id(cstemp)
function jfontdefY() -- for horizontal font
local j = load_jfont_metric()
local fn = font.id(cstemp)
- local f =
font.fonts[fn]
+ local f =
getfont(fn)
if not j then
ltjb.package_error('luatexja',
"bad JFM `" .. jfm_file_name .. "'",
if not j then
ltjb.package_error('luatexja',
"bad JFM `" .. jfm_file_name .. "'",
@@
-228,8
+229,13
@@
function jfontdefY() -- for horizontal font
return
end
update_jfm_cache(j, f.size)
return
end
update_jfm_cache(j, f.size)
+ local sz = metrics[j].size_cache[f.size]
local fmtable = { jfm = j, size = f.size, var = jfm_var,
local fmtable = { jfm = j, size = f.size, var = jfm_var,
- size_cache = metrics[j].size_cache[f.size] }
+ zw = sz.zw, zh = sz.zh,
+ chars = sz.chars, char_type = sz.char_type,
+ kanjiskip = sz.kanjiskip, xkanjiskip = sz.xkanjiskip,
+ }
+
fmtable = luatexbase.call_callback("luatexja.define_jfont", fmtable, fn)
font_metric_table[fn]=fmtable
tex.sprint(cat_lp, luatexja.is_global .. '\\protected\\expandafter\\def\\csname '
fmtable = luatexbase.call_callback("luatexja.define_jfont", fmtable, fn)
font_metric_table[fn]=fmtable
tex.sprint(cat_lp, luatexja.is_global .. '\\protected\\expandafter\\def\\csname '
@@
-240,7
+246,7
@@
end
function load_zw()
local a = font_metric_table[tex.attribute[attr_curjfnt]]
if a then
function load_zw()
local a = font_metric_table[tex.attribute[attr_curjfnt]]
if a then
- tex.setdimen('ltj@zw', a.
size_cache.
zw)
+ tex.setdimen('ltj@zw', a.zw)
else
tex.setdimen('ltj@zw',0)
end
else
tex.setdimen('ltj@zw',0)
end
@@
-249,7
+255,7
@@
end
function load_zh()
local a = font_metric_table[tex.attribute[attr_curjfnt]]
if a then
function load_zh()
local a = font_metric_table[tex.attribute[attr_curjfnt]]
if a then
- tex.setdimen('ltj@zh', a.
size_cache.
zh)
+ tex.setdimen('ltj@zh', a.zh)
else
tex.setdimen('ltj@zh',0)
end
else
tex.setdimen('ltj@zh',0)
end
@@
-283,17
+289,17
@@
local function extract_metric(name)
end
-- replace fonts.define.read()
end
-- replace fonts.define.read()
-local ljft_dr_orig = fonts.define.read
-function fonts.define.read(name, size, id)
+function font_callback(name, size, id, fallback)
extract_metric(name)
-- In the present imple., we don't remove "jfm=..." from name.
extract_metric(name)
-- In the present imple., we don't remove "jfm=..." from name.
- return
ljft_dr_orig
(name, size, id)
+ return
fallback
(name, size, id)
end
------------------------------------------------------------------------
-- MISC
------------------------------------------------------------------------
end
------------------------------------------------------------------------
-- MISC
------------------------------------------------------------------------
+local is_ucs_in_japanese_char = ltjc.is_ucs_in_japanese_char
-- EXT: italic correction
function append_italic()
local p = tex.nest[tex.nest.ptr].tail
-- EXT: italic correction
function append_italic()
local p = tex.nest[tex.nest.ptr].tail
@@
-301,13
+307,18
@@
function append_italic()
local f = p.font
local g = node_new(id_kern)
g.subtype = 1; node.set_attribute(g, attr_icflag, ITALIC)
local f = p.font
local g = node_new(id_kern)
g.subtype = 1; node.set_attribute(g, attr_icflag, ITALIC)
- if
ltjc.
is_ucs_in_japanese_char(p) then
+ if is_ucs_in_japanese_char(p) then
f = has_attr(p, attr_curjfnt)
local j = font_metric_table[f]
f = has_attr(p, attr_curjfnt)
local j = font_metric_table[f]
- local c = find_char_class(p.char, j)
- g.kern = j.size_cache.char_type[c].italic
+ g.kern = j.char_type[find_char_class(p.char, j)].italic
else
else
- g.kern = font.fonts[f].characters[p.char].italic
+ local h = getfont(f)
+ if h then
+ g.kern = h.characters[p.char].italic
+ else
+ tex.attribute[attr_icflag] = -(0x7FFFFFFF)
+ return node.free(g)
+ end
end
node.write(g)
tex.attribute[attr_icflag] = -(0x7FFFFFFF)
end
node.write(g)
tex.attribute[attr_icflag] = -(0x7FFFFFFF)