JFM中の同名のフィールドの値がそのまま使われている.
\end{description}
\end{itemize}
-\item[ascent\textrm{, }descent]
- 縦組時に個々のグリフを90度回転させる場合,そのグリフは(実際の高さ・深さにかかわらず)
- 便宜的に高さ\texttt{ascent},深さ\texttt{descent}を持つものだと想定して回転させる.
- この仕様は\Pkg{luaotfload}がOpenTypeフォントのVORGテーブルを読まないための暫定的なものである.
\item[chars\_cbcache]
文字クラス決定の処理で.キャッシュとして使われる.
\end{cslist}
\pageref{para-cid}ページで述べたように,\texttt{cid}キーを使って
非埋め込みの中国語・韓国語フォントを定義する場合,同様のキャッシュが生成される.
キャッシュの名称,必要となるCMapについては\autoref{tab:cid-cache}を参照して欲しい.
-
-\item[extra\_***.lua]
-フォント``\texttt{***}''における異体字セレクタの情報,縦組用字形への変換テーブル,そして
-縦組時における幅を格納している.構造は以下の通り:
%</ja>
%<*en>
\subsection{Use of cache}
if you specified \texttt{cid} key in \cs{jfont}
to use other CID-keyed non-embedded fonts for Chinese or Korean,
as in Page~\pageref{para-cid}.
-
-\item[extra\_***.lua]
-This file stores the table which stores the following.
-\begin{itemize}
- \item unicode variants in a font ``\texttt{***}''
- \item vertical width of glyphs, if it is not equal to the sum of
-the height of ascender and the depth of descender
- \item vertical variants
-\end{itemize}
-The following is the structure of the that table.
%</en>
\begin{table}[!tb]
\end{tabular}
\end{table}
-\begin{lstlisting}
-return {
- {
- [10955]={ -- U+2ACB "Subset Of Above Not Equal To"
- [65024]=983879, -- <2ACB FE00>
- ["vwidth"]=0.98, -- vertical width
- },
- [37001]={ -- U+9089 "邉"
- [0]=37001, -- <9089 E0100>
- 991049, -- <9089 E0101>
- ...
- ["vform"]=995025, -- vertical variant
- },
- ...
- ["unicodes"]={
- ["aj102.pe.vert"]=984163, -- glyph name to unicode
- ...
- }
- },
- ["chksum"]="FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF", -- checksum of the fontfile
- ["version"]=11, -- version of the cache
-}
-\end{lstlisting}
%<*ja>
\item[ltj-jisx0208.\{luc|lub\}]
\LuaTeX-ja配布中の\texttt{ltj-jisx0208.lua}をバイナリ化したものである.
description = 'Loader for Japanese fonts',
})
+luatexja.load_module('lotf_aux'); local ltju = luatexja.lotf_aux
luatexja.load_module('base'); local ltjb = luatexja.base
luatexja.load_module('charrange'); local ltjc = luatexja.charrange
luatexja.load_module('rmlgbm'); local ltjr = luatexja.rmlgbm
luatexja.load_module('direction'); local ltjd = luatexja.direction
-luatexja.load_module('lotf_aux'); local ltju = luatexja.lotf_aux
local setfield = node.direct.setfield
local getid = node.direct.getid
-- LOADING JFM
------------------------------------------------------------------------
-local metrics={} -- this table stores all metric informations
-local font_metric_table={} -- [font number] -> jfm_name, jfm_var, size
+local metrics = {} -- this table stores all metric informations
+local font_metric_table = ltju.font_metric_table -- [font number] -> jfm_name, jfm_var, size
luatexbase.create_callback("luatexja.load_jfm", "data", function (ft, jn) return ft end)
return lo%2==1
end
local vert_vrt2 = { vert=true, vrt2 = true }
- list_rotate_glyphs = function (dest, id)
+ local function list_rorate_dup (i, v, dest)
+ local f = dest[i]
+ if not f then
+ for j,_ in pairs(v) do if dest[j] then f=true; break end end
+ end
+ dest[i]=f; for j,_ in pairs(v) do dest[j]=f end
+ end
+ list_rotate_glyphs = function (tfmdata, dest)
local rot = {}
- for i,_ in pairs(id.characters) do
+ for i,_ in pairs(tfmdata.characters) do
if rotate_in_uax50(i) then rot[i] = true end
end
- ltju.loop_over_feat(id, vert_vrt2, function (i,k) rot[i] = nil end)
- -- コードポイントが共有されているグリフについて
- if id.resources and id.resources.duplicates then
- for i,v in pairs(id.resources.duplicates) do
- local f = rot[i]
- for j,_ in pairs(v) do f = f and rot[j] end
- rot[i]=f
- for j,_ in pairs(v) do rot[j] = f end
- end
- end
+ ltju.loop_over_feat(tfmdata, vert_vrt2, function (i,k) rot[i] = nil end)
+ -- 同じグリフが複数の Unicode ポイントを持っている場合.
+ -- いずれかの Unicode ポイントで rot = true ならば全体で rotate
+ ltju.loop_over_duplicates(tfmdata,
+ function (i, v)
+ local f = rot[i]
+ if not f then
+ for j,_ in pairs(v) do if rot[j] then f=true; break end end
+ end
+ rot[i]=f; for j,_ in pairs(v) do rot[j]=f end
+ end)
for i,_ in pairs(rot) do
dest = dest or {}; dest.rotation = dest.rotation or {}
dest.rotation[i] = true
end
end
--- vertical metrics
-local prepare_fl_data
-do
- local sort = table.sort
- prepare_fl_data = function (dest, id)
- local rawdata = id.shared.rawdata
- local ascender = rawdata.metadata.ascender
- local units = id.units
- local t_vorigin, t_ind_to_uni = {}, {}
- for i,v in pairs(rawdata.descriptions) do
- t_ind_to_uni[v.index] = i
- if v.tsb then
- local j = v.boundingbox[4] + v.tsb
- if j~=ascender then t_vorigin[i]=j / units end
- end
- end
- dest = dest or {}
- dest.ind_to_uni = t_ind_to_uni
- dest.vorigin = t_vorigin -- designed size = 1.0
- return dest
- end
-end
-
---
do
- local function prepare_extra_data_base(id)
- if (not id) or (not id.filename) then return end
- local bname = id.psname or file.nameonly(id.filename)
+ local nameonly, lower = file.nameonly, string.lower
+ local function prepare_extra_data_base(tfmdata)
+ if (not tfmdata) or (not tfmdata.filename) then return end
+ local bname = tfmdata.psname or nameonly(tfmdata.filename)
if not font_extra_basename[bname] then
- ltjb.remove_cache("extra_" .. string.lower(bname)) -- remove cache
- local dat = prepare_fl_data(dat, id)
- dat = list_rotate_glyphs(dat, id)
- font_extra_basename[bname] = dat or {}
+ ltjb.remove_cache("extra_" .. lower(bname)) -- remove cache
+ local dest = ltju.get_vmet_table(tfmdata, dest)
+ dest = list_rotate_glyphs(tfmdata, dest)
+ font_extra_basename[bname] = dest or {}
return bname
end
end
local function prepare_extra_data_font(id, res)
- if type(res)=='table' and res.shared and (res.psname or res.filename) then
- font_extra_info[id] = font_extra_basename[res.psname or file.nameonly(res.filename)]
+ if type(res)=='table' and (res.psname or res.filename) then
+ font_extra_info[id] = font_extra_basename[res.psname or nameonly(res.filename)]
end
end
luatexbase.add_to_callback(
-- functions which access to fonts.* will be gathered in this file.
local aux = {}
luatexja.lotf_aux = aux
+local font_metric_table = {}
+aux.font_metric_table = font_metric_table
-local getfont
-do
- local font_getfont = font.getfont
- getfont = function (id) return (type(id)=="table") and id or font_getfont(id) end
-end
- -- accept font number or table
+local getfont = font.getfont
local provides_feature = luaotfload.aux.provides_feature
function aux.exist_feature(id, name)
local t = getfont(id)
end
local function get_ascender(id) -- scaled points
+ if font_metric_table[id].ascender then return font_metric_table[id].ascender end
local t = getfont(id)
- return (t and t.parameters and t.parameters.ascender) or 0
+ local a = t and t.parameters and t.parameters.ascender or 0
+ font_metric_table[id].ascender = a; return a
end
local function get_descender(id) -- scaled points
+ if font_metric_table[id].descender then return font_metric_table[id].descender end
local t = getfont(id)
- return (t and t.parameters and t.parameters.descender) or 0
+ local a = t and t.parameters and t.parameters.descender or 0
+ font_metric_table[id].descender = a; return a
end
aux.get_ascender, aux.get_descender = get_ascender, get_descender
-function aux.get_vheight(id, c) -- scaled points
- local t = getfont(id)
- if t and t.descriptions and t.descriptions[c] and t.descriptions[c].vheight then
- return t.descriptions[c].vheight / t.units * t.size
- elseif t and t.shared and t.shared.rawdata and t.shared.rawdata.metadata then
- return t.shared.rawdata.metadata.defaultvheight / t.units * t.size
- else
- return get_ascender(id) + get_descender(id)
+local function get_vmet_table(tfmdata, dest)
+ if tfmata and tfmdata.shared then return dest end
+ local rawdata = tfmdata.shared.rawdata
+ local ascender = rawdata.metadata.ascender or 0
+ local default_vheight
+ = rawdata.metadata.defaultvheight
+ or (rawdata.metadata.descender and (ascender+rawdata.metadata.descender) or units)
+ local units = tfmdata.units
+ local t_vorigin, t_vheight, t_ind_to_uni = {}, {}, {}
+ for i,v in pairs(rawdata.descriptions) do
+ t_ind_to_uni[v.index] = i
+ if v.tsb then
+ local j = v.boundingbox[4] + v.tsb
+ if j~=ascender then t_vorigin[i]= j / units end
+ end
+ if v.vheight then
+ if v.vheight~=default_vheight then t_vheight[i] = v.vheight / units end
+ end
+ end
+ setmetatable(t_vheight, {__index = function () return default_vheight / units end } )
+ setmetatable(t_vorigin, {__index = function () return ascender / units end } )
+ dest = dest or {}
+ dest.ind_to_uni = t_ind_to_uni
+ dest.vorigin = t_vorigin -- designed size = 1.0
+ dest.vheight = t_vheight -- designed size = 1.0
+ return dest
+end
+aux.get_vmet_table = get_vmet_table
+
+local function loop_over_duplicates(id, func)
+-- func: return non-nil iff abort this fn
+ local t = (type(id)=="table") and id or getfont(id)
+ if t and t.resources and t.resources.duplicates then
+ for i,v in pairs(t.resources.duplicates) do
+ func(i,v)
+ end
end
end
+aux.loop_over_duplicates = loop_over_duplicates
local function loop_over_feat(id, feature_name, func)
-- feature_name: like { vert=true, vrt2 = true, ...}
-- func: return non-nil iff abort this fn
- local t = getfont(id)
+ local t = (type(id)=="table") and id or getfont(id)
if t and t.resources and t.resources.sequences then
for _,i in pairs(t.resources.sequences) do
if i.order[1] and feature_name[i.order[1]] then
local search
search = function (t, key, prefix)
if type(t)=="table" then
+ prefix = prefix or ''
for i,v in pairs(t) do
if i==key then print(prefix..'.'..i, v)
else search(v,key,prefix..'.'..tostring(i)) end
0.5*(get_ascender(pf)-get_descender(pf)))
end
end
- pwidth = ltju.get_vheight(pf, pc, met.size)
- ascender = feir.vorigin[pc] and (feir.vorigin[pc] * met.size) or get_ascender(pf)
+ pwidth, ascender = feir.vheight[pc]*met.size, feir.vorigin[pc]*met.size
end
fwidth = fwidth or pwidth
fshift.down = char_data.down; fshift.left = char_data.left