summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2013-07-06 21:47:47 +0000
committerKarl Berry <karl@freefriends.org>2013-07-06 21:47:47 +0000
commit004cdf7cf1c86993de5cd6bca1e51c12f292eb49 (patch)
tree967593ef558f1cbe244f14c603b53b4c82e063f3
parent92df2e9ea55c660a25f0fea16c4e943fae974140 (diff)
luatexko (6jul13)
git-svn-id: svn://tug.org/texlive/trunk@31120 c570f23f-e606-0410-a88d-b1316a301751
-rw-r--r--Master/texmf-dist/doc/luatex/luatexko/ChangeLog11
-rw-r--r--Master/texmf-dist/doc/luatex/luatexko/README4
-rw-r--r--Master/texmf-dist/doc/luatex/luatexko/luatexko-doc.pdfbin466390 -> 466358 bytes
-rw-r--r--Master/texmf-dist/doc/luatex/luatexko/luatexko-doc.tex26
-rw-r--r--Master/texmf-dist/tex/luatex/luatexko/luatexko-core.sty63
-rw-r--r--Master/texmf-dist/tex/luatex/luatexko/luatexko-normalize.lua25
-rw-r--r--Master/texmf-dist/tex/luatex/luatexko/luatexko-uhc2utf8.lua22
-rw-r--r--Master/texmf-dist/tex/luatex/luatexko/luatexko.lua162
-rw-r--r--Master/texmf-dist/tex/luatex/luatexko/luatexko.sty55
9 files changed, 216 insertions, 152 deletions
diff --git a/Master/texmf-dist/doc/luatex/luatexko/ChangeLog b/Master/texmf-dist/doc/luatex/luatexko/ChangeLog
index e268d1f4584..92e9544b4d9 100644
--- a/Master/texmf-dist/doc/luatex/luatexko/ChangeLog
+++ b/Master/texmf-dist/doc/luatex/luatexko/ChangeLog
@@ -1,3 +1,14 @@
+2013-07-03 Dohyun Kim <nomos at ktug org>
+
+ Version 1.2
+
+ * luatexko.sty: move Hangul caption setting to AtBeginDocument
+
+ * luatexko.lua: implemented reordering of hangul tone marks;
+ fix a bug wrt. \dotemph of old hangul.
+
+ * luatexko-core.sty: adapt to \fontname fix by luaotfload
+
2013-05-19 Dohyun Kim <nomos at ktug org>
Version 1.1
diff --git a/Master/texmf-dist/doc/luatex/luatexko/README b/Master/texmf-dist/doc/luatex/luatexko/README
index c7b2f4ae660..09509d3e75d 100644
--- a/Master/texmf-dist/doc/luatex/luatexko/README
+++ b/Master/texmf-dist/doc/luatex/luatexko/README
@@ -1,4 +1,4 @@
-LuaTeX-ko Package version 1.1 (2013/05/19)
+LuaTeX-ko Package version 1.2 (2013/07/03)
==========================================
This is a Lua(La)TeX macro package that supports typesetting Korean
@@ -120,7 +120,7 @@ Set spacing between Hangul characters.
Set spacing between CJK and Latin characters.
[PunctRaise=<dimen>]
-Raise Latin fullstop and comma after CJK character.
+Raise Latin fullstop after CJK character.
[QuoteRaise=<dimen>]
Raise Latin quotation marks and parentheses around CJK text.
diff --git a/Master/texmf-dist/doc/luatex/luatexko/luatexko-doc.pdf b/Master/texmf-dist/doc/luatex/luatexko/luatexko-doc.pdf
index 1fe17dcecbf..37b949c3806 100644
--- a/Master/texmf-dist/doc/luatex/luatexko/luatexko-doc.pdf
+++ b/Master/texmf-dist/doc/luatex/luatexko/luatexko-doc.pdf
Binary files differ
diff --git a/Master/texmf-dist/doc/luatex/luatexko/luatexko-doc.tex b/Master/texmf-dist/doc/luatex/luatexko/luatexko-doc.tex
index 0b513f738f7..2201e567457 100644
--- a/Master/texmf-dist/doc/luatex/luatexko/luatexko-doc.tex
+++ b/Master/texmf-dist/doc/luatex/luatexko/luatexko-doc.tex
@@ -20,15 +20,16 @@
InterLatinCJK=.125em,
]{NanumGothic}
\usepackage[svgnames]{xcolor}
-\usepackage{mflogo}
-\usepackage{metalogo}
+\usepackage{hologo}
+\def\luatex{\hologo{LuaTeX}}
+\def\MP{\hologo{METAPOST}}
+\def\XeTeX{\hologo{XeTeX}}
\usepackage[unicode,bookmarksnumbered]{hyperref}
\edef\verbatim{\unexpanded\expandafter{\verbatim
\linespread{1.1}\selectfont\color{MidnightBlue}}}
\edef\itemize{\unexpanded\expandafter{\itemize\small}}
\catcode`|=13 \def|{\verb|\color{MidnightBlue}} %|
-\let\luatex\LuaTeX
\def\luatexko{\luatex-k$o$}
\def\texlive{\TeX\ Live}
\def\kotex{\textsf{k}\kern-.1em \textit{o}\kern-.1ex .\kern-.1667em \TeX}
@@ -39,7 +40,7 @@
\title{\luatexko\ 간단 매뉴얼}
\author{Dohyun Kim \normalsize <|nomos at ktug org|> \and
\normalsize <|http://github.com/dohyunkim/luatexko|>}
-\date{Version 1.1\quad\today}
+\date{Version 1.2\quad\today}
\maketitle
\begin{quote}\small
@@ -234,14 +235,6 @@ fontspec의 글꼴 옵션 외에 \luatexko가 따로 제공하는 것들이
현재 한글만 쓸 수 있게 설정되어 있다.
\section{}
-\luatex 에서는 아직 \hemph{세로쓰기를 지원하지 않는다}.%
-\footnote{굳이 세로쓰기를 실험해보고자 한다면 |ttx -t vmtx <폰트>.ttf|
- 명령의 결과물인 |<폰트>.ttx| 파일을 현재 디렉토리에 두어야 한다. 그런 다음
- |\string\begin\string{vertical\string}\string{<dimen>\string}
- ...\string\end\string{vertical\string}| 환경을 이용하라. ttx에 대해선
- \url{http://sourceforge.net/projects/fonttools/} 참조.
- 문서 전체에 대해 세로쓰기를 하려면 이 환경을 쓰는 대신
- |\string\verticaltypesetting| 명령을 전처리부에 선언한다.}
%\begin{figure}
%\hfil\framebox[\linewidth]{\begin{vertical}{16em}
@@ -265,6 +258,15 @@ fontspec의 글꼴 옵션 외에 \luatexko가 따로 제공하는 것들이
%\caption{세로쓰기의 예}\label{fig:vertical}
%\end{figure}
+\luatex 에서는 아직 \hemph{세로쓰기를 지원하지 않는다}.%
+\footnote{굳이 세로쓰기를 실험해보고자 한다면 |ttx -t vmtx <폰트>.ttf|
+ 명령의 결과물인 |<폰트>.ttx| 파일을 현재 디렉토리에 두어야 한다. 그런 다음
+ |\string\begin\string{vertical\string}\string{<dimen>\string}
+ ...\string\end\string{vertical\string}| 환경을 이용하라. ttx에 대해선
+ \url{http://sourceforge.net/projects/fonttools/} 참조.
+ 문서 전체에 대해 세로쓰기를 하려면 이 환경을 쓰는 대신
+ |\string\verticaltypesetting| 명령을 전처리부에 선언한다.}
+
\section{}
전처리부에서 |\usepackage{luamplib}|을 선언하면 \MP\ 코드를 문서 중간에 삽입할 수 있다.
한글이나 수식은 |btex| ... |etex| 안에 넣어야 한다. 그림~\ref{fig:mplib} 참조.
diff --git a/Master/texmf-dist/tex/luatex/luatexko/luatexko-core.sty b/Master/texmf-dist/tex/luatex/luatexko/luatexko-core.sty
index bff0ddebdcc..6984b79d460 100644
--- a/Master/texmf-dist/tex/luatex/luatexko/luatexko-core.sty
+++ b/Master/texmf-dist/tex/luatex/luatexko/luatexko-core.sty
@@ -14,8 +14,8 @@
\input luaotfload.sty
\catcode`@ = 11
\else
- \ProvidesPackage{luatexko-core}[2013/05/19 v1.1 Typesetting Korean with LuaTeX]
- \RequirePackage{luaotfload}
+ \ProvidesPackage{luatexko-core}[2013/07/03 v1.2 Typesetting Korean with LuaTeX]
+ \RequirePackage{luaotfload}[2013/05/23]
\fi
%% attributes
@@ -95,13 +95,19 @@
\vrule width\z@ height.88em depth\z@\relax #1}%
\setbox\tw@\hbox{% ruby
\ifdefined\rubyfont \rubyfont \fi
- \expandafter\dimen@\pdffontsize\the\font
- \dimen@\rubysize\dimen@
\ifcsname selectfont\endcsname
+ \expandafter\dimen@\pdffontsize\font
+ \dimen@\rubysize\dimen@
\fontsize\dimen@\dimen@\selectfont
\else
\ifdefined\rubyfont \else
- \resizecurrentfont{\the\dimen@}%
+ \luatexko@resize@font\font\resized@font\font\rubysize
+ \ifdefined\hangul@font
+ \luatexko@resize@font\hangulfont{}\hangul@font\rubysize
+ \fi
+ \ifdefined\hanja@font
+ \luatexko@resize@font\hanjafont{}\hanja@font\rubysize
+ \fi
\fi
\fi #2}\ht\tw@\z@\dp\tw@\z@
\directlua{%
@@ -114,23 +120,15 @@
\ifcsname selectfont\endcsname\else
% font resize under plain tex
- % ex: \resizecurrentfont{9pt}
- \def\resizecurrentfont#1{%
- \edef\curr@font@name{\directlua{
- local f = font.current()
- f = f and fonts.hashes.identifiers[f]
- f = f and f.properties and f.properties.name
- if not f then
- f = "\fontname\font"
- f = string.gsub(f," at .+","")
- end
- if f then
- tex.sprint(f)
- else
- error("cannot get current font name")
- end
- }}%
- \font\resized@font={\curr@font@name} at #1\resized@font}
+ \def\luatexko@resize@font#1#2#3#4{%
+ \expandafter\dimen@\pdffontsize#3\relax
+ \edef\luatexko@tmp@fontname{%
+ \directlua{
+ local f = [===[\fontname#3]===]
+ f = string.gsub(f," at .+","")
+ tex.sprint(f) }}%
+ #1#2=\luatexko@tmp@fontname\space at #4\dimen@
+ #2}
\fi
%% vertical typesetting
@@ -147,7 +145,6 @@
\setbox\z@\vbox\bgroup
\hsize#1\relax
\luatexko@vertical
- \parindent\z@
\everypar{}%
\leftskip\z@
\rightskip\z@ }
@@ -223,9 +220,9 @@
\let\luatexko@hanja@selectfont\relax
\check@hangul@family
\ifdefined\hangul@font \hangul@font \fi
- \expandafter\endgroup
- \directlua{ luatexko.cjkfontidtmp = font.current() }%
- \hangfntattr\directlua{ tex.sprint(luatexko.cjkfontidtmp) }\relax
+ \expandafter\expandafter\expandafter
+ \endgroup
+ \expandafter\hangfntattr\luatexfontid\font\relax
}
\def\luatexko@hanja@selectfont{%
\begingroup
@@ -233,9 +230,9 @@
\let\luatexko@hanja@selectfont\relax
\check@hanja@family
\ifdefined\hanja@font \hanja@font \fi
- \expandafter\endgroup
- \directlua{ luatexko.cjkfontidtmp = font.current() }%
- \hanjfntattr\directlua{ tex.sprint(luatexko.cjkfontidtmp) }\relax
+ \expandafter\expandafter\expandafter
+ \endgroup
+ \expandafter\hanjfntattr\luatexfontid\font\relax
\ifnum\cjtypesetattr>\z@\luatexkolatinspaceskip\fi
}
\let\check@hangul@family\relax
@@ -250,17 +247,17 @@
\def\setmathhangulblock#1#2{%
\count@="#1
\loop
- \luatexUmathcode\count@ = 7 \symmathhangul \count@
+ \Umathcode\count@ = 7 \symmathhangul \count@
\ifnum\count@<"#2
\advance\count@\@ne
\repeat}
+\def\setmathhangulfont#1#{\setmathhangul@font@}
\ifdefined\ProvidesPackage
- \let\setmathhangulfont\@gobble
+ \let\setmathhangul@font@\@gobble
\else
% for plain; see luatexko.sty for latex
\newfam\symmathhangul
- \def\setmathhangulfont#1#{\setmathhangulfont@}
- \def\setmathhangulfont@#1{%
+ \def\setmathhangul@font@#1{%
\font\tenhangul = "#1" at 10pt
\font\sevenhangul = "#1" at 7pt
\font\fivehangul = "#1" at 5pt
diff --git a/Master/texmf-dist/tex/luatex/luatexko/luatexko-normalize.lua b/Master/texmf-dist/tex/luatex/luatexko/luatexko-normalize.lua
index e131ec384fd..2b8d33bd521 100644
--- a/Master/texmf-dist/tex/luatex/luatexko/luatexko-normalize.lua
+++ b/Master/texmf-dist/tex/luatex/luatexko/luatexko-normalize.lua
@@ -10,17 +10,18 @@
-- and version 1.3c or later is part of all distributions of LaTeX
-- version 2006/05/20 or later.
-module('luatexkonormalize', package.seeall)
-
luatexbase.provides_module({
name = "luatexko-normalize",
- version = 1.0,
- date = "2013/05/10",
+ version = 1.2,
+ date = "2013/06/10",
author = "Dohyun Kim",
description = "Hangul normalization",
license = "LPPL v1.3+",
})
+luatexkonormalize = luatexkonormalize or {}
+local luatexkonormalize = luatexkonormalize
+
local cho = "[\225\132\128-\225\132\146]"
local jung = "[\225\133\161-\225\133\181]"
local jong = "[\225\134\168-\225\135\130]"
@@ -403,7 +404,7 @@ local char = unicode.utf8.char
local add_to_callback = luatexbase.add_to_callback
local remove_from_callback = luatexbase.remove_from_callback
-local syllable2jamo = function(l,v,t)
+local jamo2syllable = function(l,v,t)
l, v = byte(l), byte(v)
local s = (l - 0x1100) * 21
s = (s + v - 0x1161) * 28
@@ -449,9 +450,9 @@ end
local hangulcompose = function(buffer)
buffer = hanguldecompose(buffer)
- buffer = gsub(buffer, "("..cho..")("..jung..")("..jong..")", syllable2jamo)
+ buffer = gsub(buffer, "("..cho..")("..jung..")("..jong..")", jamo2syllable)
buffer = gsub(buffer, "("..cho..")("..jung..ojong..")", "%1\1%2")
- buffer = gsub(buffer, "("..cho..")("..jung..")", syllable2jamo)
+ buffer = gsub(buffer, "("..cho..")("..jung..")", jamo2syllable)
buffer = gsub(buffer, "([\225\132\128-\225\133\153])\225\133\160", jamo2cjamocho)
buffer = gsub(buffer, "\225\133\159([\225\133\161-\225\134\161])", jamo2cjamojung)
buffer = gsub(buffer, "\1", "")
@@ -461,26 +462,28 @@ end
local loaded = false
-function compose()
+local function compose()
if loaded then
remove_from_callback('process_input_buffer', 'luatexko-hangul-normalize')
end
loaded = true
add_to_callback('process_input_buffer', hangulcompose, 'luatexko-hangul-normalize')
end
+luatexkonormalize.compose = compose
-function decompose()
+local function decompose()
if loaded then
remove_from_callback('process_input_buffer', 'luatexko-hangul-normalize')
end
loaded = true
add_to_callback('process_input_buffer', hanguldecompose, 'luatexko-hangul-normalize')
end
+luatexkonormalize.decompose = decompose
-function unload()
+local function unload()
if loaded then
remove_from_callback('process_input_buffer', 'luatexko-hangul-normalize')
end
loaded = false
end
-
+luatexkonormalize.unload = unload
diff --git a/Master/texmf-dist/tex/luatex/luatexko/luatexko-uhc2utf8.lua b/Master/texmf-dist/tex/luatex/luatexko/luatexko-uhc2utf8.lua
index 9f498132132..595af6b1530 100644
--- a/Master/texmf-dist/tex/luatex/luatexko/luatexko-uhc2utf8.lua
+++ b/Master/texmf-dist/tex/luatex/luatexko/luatexko-uhc2utf8.lua
@@ -10,17 +10,18 @@
-- and version 1.3c or later is part of all distributions of LaTeX
-- version 2006/05/20 or later.
-module('luatexkouhc2utf8', package.seeall)
-
luatexbase.provides_module({
name = "luatexko-uhc2utf8",
- version = 1.0,
- date = "2013/05/10",
+ version = 1.2,
+ date = "2013/06/10",
author = "Dohyun Kim",
description = "UHC (CP949) input encoding",
license = "LPPL v1.3+",
})
+luatexkouhc2utf8 = luatexkouhc2utf8 or {}
+local luatexkouhc2utf8 = luatexkouhc2utf8
+
local find = string.find
local gsub = string.gsub
local byte = string.byte
@@ -30,7 +31,6 @@ local ugsub = unicode.utf8.gsub
local ubyte = unicode.utf8.byte
local uchar = unicode.utf8.char
local floor = math.floor
-local isfile = lfs.isfile
local kpse_find_file = kpse.find_file
local add_to_callback = luatexbase.add_to_callback
local remove_from_callback = luatexbase.remove_from_callback
@@ -77,13 +77,15 @@ local uhc_to_utf8 = function(buffer)
return buffer
end
-function startconvert ()
+local function startconvert ()
add_to_callback('process_input_buffer', uhc_to_utf8, 'luatexko-uhctoutf8', 1)
end
+luatexkouhc2utf8.startconvert = startconvert
-function stopconvert ()
+local function stopconvert ()
remove_from_callback('process_input_buffer', 'luatexko-uhctoutf8')
end
+luatexkouhc2utf8.stopconvert = stopconvert
-----------------------------------------
-- Hangul Windows OS uses CP949 filenames
@@ -117,14 +119,16 @@ local function uhc_find_file (file, ...)
return f
end
-function start_uhc_filename ()
+local function start_uhc_filename ()
add_to_callback('find_read_file', function(id, name) return uhc_find_file(name) end, 'luatexko-touhc-findreadfile')
add_to_callback('find_image_file', uhc_find_file, 'luatexko-touhc-findimagefile')
kpse.find_file = uhc_find_file
end
+luatexkouhc2utf8.start_uhc_filename = start_uhc_filename
-function stop_uhc_filename ()
+local function stop_uhc_filename ()
remove_from_callback('find_read_file', 'luatexko-touhc-findreadfile')
remove_from_callback('find_image_file', 'luatexko-touhc-findimagefile')
kpse.find_file = kpse_find_file
end
+luatexkouhc2utf8.stop_uhc_filename = stop_uhc_filename
diff --git a/Master/texmf-dist/tex/luatex/luatexko/luatexko.lua b/Master/texmf-dist/tex/luatex/luatexko/luatexko.lua
index 1165d706bd7..b85cb734817 100644
--- a/Master/texmf-dist/tex/luatex/luatexko/luatexko.lua
+++ b/Master/texmf-dist/tex/luatex/luatexko/luatexko.lua
@@ -10,17 +10,25 @@
-- and version 1.3c or later is part of all distributions of LaTeX
-- version 2006/05/20 or later.
-module('luatexko', package.seeall)
-
local err,warn,info,log = luatexbase.provides_module({
name = 'luatexko',
- date = '2013/05/19',
- version = '1.1',
+ date = '2013/07/03',
+ version = 1.2,
description = 'Korean linebreaking and font-switching',
author = 'Dohyun Kim',
license = 'LPPL v1.3+',
})
+luatexko = luatexko or {}
+local luatexko = luatexko
+
+local dotemphnode,rubynode,ulinebox = {},{},{}
+luatexko.dotemphnode = dotemphnode
+luatexko.rubynode = rubynode
+luatexko.ulinebox = ulinebox
+luatexko.hangulmain = luatexko.hangulmain or false
+luatexko.hanjafontforhanja = luatexko.hanjafontforhanja or false
+
local stringbyte = string.byte
local stringgsub = string.gsub
local stringchar = string.char
@@ -28,14 +36,14 @@ local stringfind = string.find
local stringmatch = string.match
local stringgmatch = string.gmatch
local stringformat = string.format
+local string_sub = string.sub
local mathfloor = math.floor
local tex_round = tex.round
local tex_sp = tex.sp
local fontdefine = font.define
+local utf8char = unicode.utf8.char
local fontdata = fonts.hashes.identifiers
-local font_define_func = callback.find("define_font")
-local utf8char = unicode.utf8.char
local remove_node = node.remove
local insert_before = node.insert_before
@@ -67,7 +75,6 @@ local add_to_callback = luatexbase.add_to_callback
local gluenode = node.id("glue")
local gluespecnode = node.id("glue_spec")
local glyphnode = node.id("glyph")
-local discnode = node.id("disc")
local mathnode = node.id("math")
local hlistnode = node.id("hlist")
local vlistnode = node.id("vlist")
@@ -85,11 +92,6 @@ local new_rule = node.new(rulenode)
local emsize = 655360
-dotemphnode = {}
-rubynode = {}
-ulinebox = {}
-hanjafontforhanja = false
-
local cjkclass = {
[0x2018] = 1, -- ‘
[0x201C] = 1, -- “
@@ -383,6 +385,7 @@ local latin_fullstop = {
local latin_quotes = {
[0x0028] = 0x0029, -- ( )
+ [0x003C] = 0x003E, -- < >
[0x2018] = 0x2019, -- ‘ ’
[0x201C] = 0x201D, -- “ ”
}
@@ -528,7 +531,7 @@ local function get_font_table (fid)
if fontdata[fid] then
return fontdata[fid]
else
- return font.getfont(fid)
+ return font.fonts[fid]
end
end
end
@@ -564,15 +567,20 @@ local function get_char_boundingbox(fid, chr)
end
local function get_unicode_char(curr)
- if curr.char > 0 and curr.char < 0xF0000 then return curr.char end
- local uni = has_attribute(curr, luakounicodeattr)
+ if (curr.char > 0 and curr.char < 0xE000) -- no pua
+ or (curr.char > 0xF8FF and curr.char < 0xF0000) then
+ return curr.char
+ end
+ -- tounicode is not reliable. backend bug
+ local uni = get_font_char(curr.font, curr.char)
+ uni = uni and uni.tounicode
+ uni = uni and string_sub(uni,1,4) -- seems ok for old hangul
+ if uni then return tonumber(uni,16) end
+ uni = has_attribute(curr, luakounicodeattr)
if uni then return uni end
return curr.char
end
-----------------------------
--- cjk linebreak and spacing
-----------------------------
local function get_hlist_class_first (hlist)
local curr = hlist.head
while curr do
@@ -606,6 +614,9 @@ local function get_hlist_class_last (hlist,prevchar,prevfont)
return prevchar, prevfont
end
+----------------------------
+-- cjk linebreak and spacing
+----------------------------
local function kanjiskip (head,curr)
insert_before(head,curr,make_luako_glue(0, emsize*0.1, emsize*0.02))
end
@@ -732,7 +743,7 @@ local function cjk_insert_nodes(head,curr,currchar,currfont,prevchar,prevfont)
local stretch = 0
local shrink = emsize * cjk_glue_spec[p][c][2]
insert_before(head,curr,make_luako_glue(width, stretch, shrink))
- elseif p < 10 and c < 10 and p ~= 8 and c ~= 9 then
+ elseif p < 10 and c < 9 then -- break between chosong and chosong
kanjiskip(head,curr)
elseif (p < 10 and c == 10) or (p == 10 and c < 10) then
if xspcode[currchar] then
@@ -780,20 +791,11 @@ local function cjk_insert_nodes(head,curr,currchar,currfont,prevchar,prevfont)
koreanlatinskip(head,curr,currfont,prevfont,was_penalty)
elseif p == 7 and c == 7 then
interhangulskip(head,curr,currfont,prevfont,was_penalty)
- elseif p < 10 and c < 10 and p ~= 8 and c ~= 9 then
+ elseif p < 10 and c < 9 then -- break between chosong and chosong
interhanjaskip(head,curr,was_penalty)
end
end
end
- -- for dot emphasis
- if has_attribute(curr,dotemphattr)
- and c ~= 0
- and c ~= 7
- and p ~= 8
- and c ~= 8 then
- unset_attribute(curr,dotemphattr)
- end
-
return currchar,currfont
end
@@ -1348,26 +1350,22 @@ local function hangulspaceskip (engfont, hfontid, nglue)
return tex_round(hsp), tex_round(hst), tex_round(hsh)
end
-local hangulfontlist = {}
-
local function font_substitute(head)
for curr in traverse_id(glyphnode, head) do
local eng = get_font_table(curr.font)
local engfontchar = get_font_char(curr.font, curr.char)
- if not eng then -- no font table of plain tex cm font
- engfontchar = get_cjk_class(curr.char) == 10
- end
if curr.char and not engfontchar then
local korid = false
local hangul = has_attribute(curr, hangfntattr)
local hanja = has_attribute(curr, hanjfntattr)
local ftable = {hangul, hanja}
- if hanjafontforhanja then
+ if luatexko.hanjafontforhanja then
local uni = get_unicode_char(curr)
uni = uni and get_cjk_class(uni)
if uni and uni < 7 then ftable = {hanja, hangul} end
end
- for _,fid in ipairs(ftable) do
+ for i=1,#ftable do
+ local fid = ftable[i]
if fid then
local c = get_font_char(fid, curr.char)
if c then
@@ -1375,7 +1373,9 @@ local function font_substitute(head)
curr.font = fid
-- adjust next glue by hangul font space
local nxt = curr.next
- if hangulmain and nxt and nxt.id == gluenode and nxt.subtype and nxt.subtype == 0 then
+ local hangulmain = eng and nxt and luatexko.hangulmain
+ hangulmain = hangulmain and get_font_char(fid, 32)
+ if hangulmain and nxt.id == gluenode and nxt.subtype and nxt.subtype == 0 then
local sp,st,sh = hangulspaceskip(eng, fid, nxt)
if sp and st and sh then
nxt.spec.width = sp
@@ -1414,7 +1414,7 @@ end
------------------------------------
--- vetical typesetting: EXPERIMENTAL -- don't use this
+-- vertical typesetting: EXPERIMENTAL -- don't use this
------------------------------------
---[[no vwidth in luaotfload v2
local tsbtable = {}
@@ -1523,10 +1523,12 @@ local function cjk_vertical_font (vf)
end
local function activate_vertical_virtual (tfmdata,value)
- if value then
+ local loaded = luatexbase.priority_in_callback("luaotfload.patch_font",
+ "luatexko.vertical_virtual_font")
+ if value and not loaded then
add_to_callback("luaotfload.patch_font",
cjk_vertical_font,
- "luatexko.vetical_virtual_font")
+ "luatexko.vertical_virtual_font")
end
end
@@ -1540,6 +1542,28 @@ otffeatures.register {
}
--no vwidth in luaotfload v2]]
+local function reorderTM (head)
+ for curr in traverse_id(glyphnode, head) do
+ if curr.width > 0 then -- old hangul vertical typesetting is broken?
+ local uni = get_unicode_char(curr)
+ if uni and (uni == 0x302E or uni == 0x302F) then
+ local p = curr.prev
+ while p do
+ if p.id ~= glyphnode then break end
+ local pc = get_cjk_class(get_unicode_char(p))
+ if pc == 7 or pc == 8 then
+ head = insert_before(head,p,copy_node(curr))
+ head = remove_node(head,curr)
+ break
+ end
+ p = p.prev
+ end
+ end
+ end
+ end
+ return head
+end
+
----------------------------------
-- add to callback : pre-linebreak
----------------------------------
@@ -1557,6 +1581,7 @@ add_to_callback('hpack_filter', function(head)
spread_ruby_base_box(head)
head = compress_fullwidth_punctuations(head)
-- head = no_ruby_at_margin(head)
+ head = reorderTM(head)
return head
end, 'luatexko.hpack_filter')
@@ -1575,6 +1600,7 @@ add_to_callback('pre_linebreak_filter', function(head)
head = compress_fullwidth_punctuations(head)
discourage_char_widow(head, nodeslide(head))
head = no_ruby_at_margin(head)
+ head = reorderTM(head)
return head
end, 'luatexko.pre_linebreak_filter')
@@ -1585,20 +1611,39 @@ end, 'luatexko.pre_linebreak_filter')
local function after_linebreak_dotemph (head)
for curr in traverse(head) do
if curr.id == hlistnode then -- hlist may be nested!!!
- after_linebreak_dotemph(curr.head)
+ curr.head = after_linebreak_dotemph(curr.head)
elseif curr.id == glyphnode then
local attr = has_attribute(curr,dotemphattr)
if attr and attr > 0 then
- local d = copy_node(dotemphnode[attr])
- local dot = d.head
- d.head = get_kernnode(-curr.width/2-d.width/2)
- d.head.next = dot
- d.width = 0
- insert_after(head,curr,d)
+ local cc = get_cjk_class(get_unicode_char(curr))
+ if cc and (cc == 0 or cc == 7 or cc == 8) then
+ local basewd = curr.width or 0
+ if cc == 8 then -- check next char for old hangul jung/jongseong
+ local nn = curr.next
+ while nn do
+ if nn.id ~= glyphnode then break end
+ local uni = get_unicode_char(nn)
+ local nc = get_cjk_class(uni)
+ if nc and nc == 9 and uni ~= 0x302E and uni ~= 0x302F then
+ basewd = basewd + (nn.width or 0)
+ else
+ break
+ end
+ nn = nn.next
+ end
+ end
+ local d = copy_node(dotemphnode[attr])
+ local dot = d.head
+ d.head = get_kernnode(basewd/2-d.width/2)
+ d.head.next = dot
+ d.width = 0
+ head = insert_before(head,curr,d)
+ end
unset_attribute(curr,dotemphattr)
end
end
end
+ return head
end
-------------------------------
@@ -1649,9 +1694,10 @@ local function draw_underline(head,curr,width,ulinenum,ulstart)
and nd.subtype == whatsitspecial
and nd.data
and stringfind(nd.data,"luako:uline") then
- remove_node(head,nd)
+ head = remove_node(head,nd)
end
end
+ return head
end
local function after_linebreak_underline(head,glueorder,glueset,gluesign,ulinenum)
@@ -1659,7 +1705,7 @@ local function after_linebreak_underline(head,glueorder,glueset,gluesign,ulinenu
if ulstart and ulstart.id == gluenode then ulstart = ulstart.next end
for curr in traverse(head) do
if curr.id == hlistnode then
- ulinenum = after_linebreak_underline(curr.head,curr.glue_order,curr.glue_set,curr.glue_sign,ulinenum)
+ curr.head,ulinenum = after_linebreak_underline(curr.head,curr.glue_order,curr.glue_set,curr.glue_sign,ulinenum)
elseif curr.id == whatsitnode and curr.subtype == whatsitspecial
and curr.data then
if stringfind(curr.data,"luako:ulinebegin=") then
@@ -1668,33 +1714,33 @@ local function after_linebreak_underline(head,glueorder,glueset,gluesign,ulinenu
elseif ulstart and ulinenum
and stringfind(curr.data,'luako:ulineend') then
local wd = nodedimensions(glueset,gluesign,glueorder,ulstart,curr)
- draw_underline(head,curr,wd,ulinenum,ulstart)
+ head = draw_underline(head,curr,wd,ulinenum,ulstart)
ulinebox[ulinenum] = nil
ulinenum = nil
end
end
if ulstart and ulinenum and curr == nodetail(head) then
local wd = nodedimensions(glueset,gluesign,glueorder,ulstart,curr)
- draw_underline(head,curr,wd,ulinenum,ulstart)
+ head = draw_underline(head,curr,wd,ulinenum,ulstart)
end
end
- return ulinenum
+ return head, ulinenum
end
-----------------------------------
-- add to callback : post-linebreak
-----------------------------------
add_to_callback('vpack_filter', function(head)
- after_linebreak_dotemph(head)
+ head = after_linebreak_dotemph(head)
after_linebreak_ruby(head)
- after_linebreak_underline(head)
- return true
+ head = after_linebreak_underline(head)
+ return head
end, 'luatexko.vpack_filter')
add_to_callback("post_linebreak_filter", function(head)
- after_linebreak_dotemph(head)
+ head = after_linebreak_dotemph(head)
after_linebreak_ruby(head)
- after_linebreak_underline(head)
- return true
+ head = after_linebreak_underline(head)
+ return head
end, 'luatexko.post_linebreak_filter')
diff --git a/Master/texmf-dist/tex/luatex/luatexko/luatexko.sty b/Master/texmf-dist/tex/luatex/luatexko/luatexko.sty
index f00c5356cce..f419146c580 100644
--- a/Master/texmf-dist/tex/luatex/luatexko/luatexko.sty
+++ b/Master/texmf-dist/tex/luatex/luatexko/luatexko.sty
@@ -22,7 +22,7 @@
\expandafter\endinput
\fi
-\ProvidesPackage{luatexko}[2013/05/19 v1.1 Typesetting Korean with LuaLaTeX]
+\ProvidesPackage{luatexko}[2013/07/03 v1.2 Typesetting Korean with LuaLaTeX]
\RequirePackage{fontspec}
\RequirePackage{luatexko-core}
@@ -113,7 +113,7 @@
\protected\def\addhangulfontfeature#1{%
\begingroup
\check@hangul@family
- \hangul@font\addfontfeature{#1}\global
+ \ifdefined\hangul@font\hangul@font\fi\addfontfeature{#1}\global
\let\luatexko@fontspec@temp\f@family
\endgroup
\def\hangul@font{\fontfamily\luatexko@fontspec@temp
@@ -122,7 +122,7 @@
\protected\def\addhanjafontfeature#1{%
\begingroup
\check@hanja@family
- \hanja@font\addfontfeature{#1}\global
+ \ifdefined\hanja@font\hanja@font\fi\addfontfeature{#1}\global
\let\luatexko@fontspec@temp\f@family
\endgroup
\def\hanja@font{\fontfamily\luatexko@fontspec@temp
@@ -163,26 +163,6 @@
\edef\verbatim@font{\unexpanded\expandafter{\verbatim@font
\unsetluatexattribute\finemathattr}}
-%% hangul in math --- latex
-\protected\def\setmathhangulfont{%
- \@ifnextchar[{\setmathhangul@font@}{\setmathhangul@font@[]}}
-\def\setmathhangul@font@[#1]#2{%
- \zf@fontspec{#1}{#2}\xdef\luatexko@math@hangul@family{\zf@family}}
-\AtBeginDocument{%
- \begingroup
- \unless\ifdefined\luatexko@math@hangul@family
- \check@hangul@family
- \ifdefined\hangul@font \hangul@font \fi
- \xdef\luatexko@math@hangul@family{\f@family}%
- \fi
- \endgroup
- \DeclareSymbolFont{mathhangul}\zf@enc\luatexko@math@hangul@family\mddefault\updefault
- \ifcsname\zf@enc/\luatexko@math@hangul@family/\bfdefault/\updefault\endcsname
- \SetSymbolFont{mathhangul}{bold}\zf@enc\luatexko@math@hangul@family\bfdefault\updefault
- \fi
- \setmathhangulblock{AC00}{D7A3}
-}
-
%% package options
\newif\if@hangul
\newif\if@hanja
@@ -218,10 +198,11 @@
]{UnDotum}
\fi
-\AtBeginDocument{% [unfonts] 없는 경우 에러 방지
-\unless\ifdefined\serifhangul@font\let\serifhangul@font\relax\fi
+\AtBeginDocument{
+\unless\ifdefined\serifhangul@font\let\serifhangul@font\sanshangul@font\fi
\unless\ifdefined\sanshangul@font \let\sanshangul@font\serifhangul@font\fi
-\unless\ifdefined\monohangul@font \let\monohangul@font\sanshangul@font\fi
+\unless\ifdefined\monohangul@font \let\monohangul@font\sanshangul@font \fi
+\luatexko@hangul@selectfont
% for hyperref
\@ifpackageloaded{hyperref}{\pdfstringdefDisableCommands{%
\let\dotemph\@firstofone
@@ -247,9 +228,29 @@
}}{}
}
+%% hangul in math --- latex
+\protected\def\setmathhangulfont{%
+ \@ifnextchar[{\setmathhangul@font@}{\setmathhangul@font@[]}}
+\def\setmathhangul@font@[#1]#2{%
+ \zf@fontspec{#1}{#2}\xdef\luatexko@math@hangul@family{\zf@family}}
+\AtBeginDocument{%
+ \begingroup
+ \unless\ifdefined\luatexko@math@hangul@family
+ \check@hangul@family
+ \ifdefined\hangul@font \hangul@font \fi
+ \xdef\luatexko@math@hangul@family{\f@family}%
+ \fi
+ \endgroup
+ \DeclareSymbolFont{mathhangul}\zf@enc\luatexko@math@hangul@family\mddefault\updefault
+ \ifcsname\zf@enc/\luatexko@math@hangul@family/\bfdefault/\updefault\endcsname
+ \SetSymbolFont{mathhangul}{bold}\zf@enc\luatexko@math@hangul@family\bfdefault\updefault
+ \fi
+ \setmathhangulblock{AC00}{D7A3}
+}
+
\RequirePackage{kolabels-utf}
\if@hangul
- \RequirePackage{konames-utf}
+ \AtBeginDocument{\RequirePackage{konames-utf}}
\linespread{1.3888}
\footnotesep=1.3888\footnotesep
\skip\footins=1.3888\skip\footins plus6pt minus3pt