OSDN Git Service

Add the description of 'luatexja.set_width' callback.
authorHironori Kitagawa <h_kitagawa2001@yahoo.co.jp>
Sat, 22 Oct 2011 00:54:55 +0000 (09:54 +0900)
committerHironori Kitagawa <h_kitagawa2001@yahoo.co.jp>
Sat, 22 Oct 2011 00:54:55 +0000 (09:54 +0900)
doc/man-en.pdf
doc/man-ja.pdf
doc/manual.dtx
src/luatexja-core.lua
test/test12-ltjarticle.pdf
test/valign.lua

index dc41176..de256b9 100644 (file)
Binary files a/doc/man-en.pdf and b/doc/man-en.pdf differ
index 3840bbd..4338e16 100644 (file)
Binary files a/doc/man-ja.pdf and b/doc/man-ja.pdf differ
index 4ae38f1..f6abf99 100644 (file)
@@ -1168,7 +1168,8 @@ be accessed via \verb+luatexbase.add_to_callback+ function and so on, as other c
 \begin{list}{}%
 {\def\makelabel#1{\bfseries#1}}
 \item[\texttt{luatexja.load\_jfm} callback]
-With this callback you can overwrite JFMs.
+With this callback you can overwrite JFMs. 
+This callback is called when a new JFM is loaded.
 
 \begin{verbatim}
 function (<table> jfm_info, <string> jfm_name)
@@ -1234,8 +1235,36 @@ The argument \verb+char_class+ is the result of \LuaTeX-ja's default
 
 This callback doesn't replace any code of \LuaTeX-ja.
 
+\item[\texttt{luatexja.set\_width} callback]
+This callback is called when \LuaTeX-ja is trying to encapsule a
+            \textbf{JAchar} \textit{glyph\_node}, to adjust its
+            dimension and position.
+\begin{lstlisting}[numbers=left]
+function (<table> shift_info, <table> jfont_info, <number> char_class)
+  return <table> new_shift_info
+end
+\end{lstlisting}
 
+The argument \verb+shift_info+ and the returned \verb+new_shift_info+ have 
+\texttt{down} and \texttt{left} fields, which are the amount of shifting
+            down/left the character in a scaled-point.
 
+%<*ja>
+良い例が\Pkg{test/valign.lua}である.このファイルが読み込まれた状態では,
+            JFM内で規定された文字クラス0の文字における$(\hbox{高
+            さ}):(\hbox{深さ})$の比になるように,実際のフォントの出力上
+            下位置が自動調整される.例えば,
+\begin{itemize}
+\item JFM側の設定:$(\hbox{高さ})=88x$, $(\hbox{深さ})=12x$%
+(和文OpenTypeフォントの標準値)
+\item 実フォント側の数値:$(\hbox{高さ})=28y$, $(\hbox{深さ})=5y$(和文TrueTypeフォントの標準値)
+\end{itemize}
+となっていたとする.すると,実際の文字の出力位置は,
+\[
+ \frac{88x}{88x+12x} (28y+5y) - 28y = \frac{26}{825}y= 0.03\dot1\dot5y
+\]
+だけ上にずらされることになる,
+%</ja>
 \end{list}
 
 
@@ -1567,8 +1596,8 @@ As explained in Subsection~\ref{ssec-plain}, \verb+\jQ+ is equal to
                        a unit used in Japanese phototypesetting. So one should not change the value of this dimension. 
 \dim{jH}
 There is also a unit called `歯' which equals to $0.25\,\textrm{mm}$ and
-                       used in Japanese phototypesetting. The dimension
-                       \verb+\jH+ stores this length, similar to \verb+\jQ+. 
+                       used in Japanese phototypesetting. This
+                       \verb+\jH+ is a synonym of \verb+\jQ+.
 \dim{ltj@zw} A temporal register for the `full-width' of current Japanese font.
 \dim{ltj@zh} A temporal register for the `full-height' (usually the sum of height of imaginary body and its depth) of current Japanese font.
 \attr{jfam} Current number of Japanese font family for math formulas.
index 8190708..673f581 100644 (file)
@@ -61,7 +61,7 @@ end
 
 -- Three aux. functions, bollowed from tex.web
 local unity=65536
-local function print_scaled(s)
+function print_scaled(s)
    local out=''
    local delta=10
    if s<0 then 
index 697cd2b..a242da5 100644 (file)
Binary files a/test/test12-ltjarticle.pdf and b/test/test12-ltjarticle.pdf differ
index 819504e..c044e6f 100644 (file)
@@ -13,11 +13,11 @@ 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)
+   local ma = mt.height / (mt.height + mt.depth) * (fi.ascender + fi.descender)
+   fmtable.down_offset = round(fi.ascender - ma)
+   print('loading :', fn, print_scaled(fmtable.down_offset)
+      .. ' / ' .. print_scaled(fi.size))
    return fmtable
 end
 luatexbase.add_to_callback("luatexja.define_jfont",