diff options
-rw-r--r-- | Master/texmf-dist/doc/luatex/luatexko/ChangeLog | 8 | ||||
-rw-r--r-- | Master/texmf-dist/doc/luatex/luatexko/README | 2 | ||||
-rw-r--r-- | Master/texmf-dist/doc/luatex/luatexko/luatexko-doc.pdf | bin | 320920 -> 277366 bytes | |||
-rw-r--r-- | Master/texmf-dist/doc/luatex/luatexko/luatexko-doc.tex | 47 | ||||
-rw-r--r-- | Master/texmf-dist/tex/luatex/luatexko/luatexko-core.sty | 19 | ||||
-rw-r--r-- | Master/texmf-dist/tex/luatex/luatexko/luatexko.lua | 455 | ||||
-rw-r--r-- | Master/texmf-dist/tex/luatex/luatexko/luatexko.sty | 33 |
7 files changed, 321 insertions, 243 deletions
diff --git a/Master/texmf-dist/doc/luatex/luatexko/ChangeLog b/Master/texmf-dist/doc/luatex/luatexko/ChangeLog index fe80c4f1fdb..d856feed9a1 100644 --- a/Master/texmf-dist/doc/luatex/luatexko/ChangeLog +++ b/Master/texmf-dist/doc/luatex/luatexko/ChangeLog @@ -1,3 +1,11 @@ +2014-01-16 Dohyun Kim <nomos at ktug org> + + Version 1.4 + + * luatexko.lua: italic correction of fakeslant font + * luatexko.sty: use everysel.sty to redefine selectfont. This fixes + a bug reported by Hoze Yi & Juho Lee. + 2013-12-06 Dohyun Kim <nomos at ktug org> Version 1.3 diff --git a/Master/texmf-dist/doc/luatex/luatexko/README b/Master/texmf-dist/doc/luatex/luatexko/README index bd8328f52a5..e4ead2d69f9 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.3 (2013/12/06) +LuaTeX-ko Package version 1.4 (2014/01/16) ========================================== This is a Lua(La)TeX macro package that supports typesetting Korean diff --git a/Master/texmf-dist/doc/luatex/luatexko/luatexko-doc.pdf b/Master/texmf-dist/doc/luatex/luatexko/luatexko-doc.pdf Binary files differindex 4e89bcd6f87..699b12603dc 100644 --- a/Master/texmf-dist/doc/luatex/luatexko/luatexko-doc.pdf +++ b/Master/texmf-dist/doc/luatex/luatexko/luatexko-doc.pdf diff --git a/Master/texmf-dist/doc/luatex/luatexko/luatexko-doc.tex b/Master/texmf-dist/doc/luatex/luatexko/luatexko-doc.tex index 513d9217e10..766da7feb6b 100644 --- a/Master/texmf-dist/doc/luatex/luatexko/luatexko-doc.tex +++ b/Master/texmf-dist/doc/luatex/luatexko/luatexko-doc.tex @@ -33,7 +33,7 @@ \edef\verbatim{\unexpanded\expandafter{\verbatim \linespread{1.1}\selectfont\color{MidnightBlue}}} \edef\itemize{\unexpanded\expandafter{\itemize\small}} -\catcode`|=13 \def|{\verb|\color{MidnightBlue}} %| +\catcode`|=13 \def|{\verb|\color{MidnightBlue}\let\\=\textbackslash} %| \def\logoko{\textsf{k}\kern-.0625em\textit{o}} \def\luatexko{\luatex-\logoko} \def\texlive{\TeX\ Live} @@ -45,7 +45,7 @@ \title{\luatexko\ 간단 매뉴얼} \author{Dohyun Kim \normalsize |<nomos at ktug org>| \and \normalsize |<http://github.com/dohyunkim/luatexko>|} -\date{Version 1.3\quad\today} +\date{Version 1.4\quad\today} \maketitle \begin{quote}\small @@ -145,8 +145,8 @@ fontspec의 글꼴 옵션 외에 \luatexko가 따로 제공하는 것들이 \begin{figure} \fboxsep=1em \fbox{\vbox{\hsize\dimexpr\linewidth-2.1em\relax - \fontspec[Script=Hangul]{malgungothic} - \centering + \fontspec[Script=Hangul,Ligatures=Required]{HCR Dotum LVT} + \leftskip3cm 뎨 가ᄂᆞᆫ 뎌 각시 본 듯도 ᄒᆞᆫ뎌이고.\\ 天텬上상白ᄇᆡᆨ玉옥京경을 엇디ᄒᆞ야 離니別별ᄒᆞ고\\ ᄒᆡ 다 져믄 날의 눌을 보라 가시ᄂᆞᆫ고 @@ -158,7 +158,7 @@ fontspec의 글꼴 옵션 외에 \luatexko가 따로 제공하는 것들이 엇딘디 날 보시고 네로다 녀기실ᄉᆡ\\ 나도 님을 미더 군 ᄠᅥ디 전혀 업서\\ 이ᄅᆡ야 교ᄐᆡ야 어ᄌᆞ러이 구돗ᄯᅥᆫ디\\ -반기시ᄂᆞᆫ ᄂᆞᆺ비치 녜와 엇디 다ᄅᆞ신고.\\ +반기시ᄂᆞᆫ ᄂᆞᆺ비치 녜와 엇디 다ᄅᆞ신고.%\\ %누어 ᄉᆡᆼ각ᄒᆞ고 니러 안자 혜여ᄒᆞ니\\ %내 몸의 지은 죄 뫼ᄀᆞ티 ᄡᅡ혀시니\\ %하ᄂᆞᆯ히라 원망ᄒᆞ고 사ᄅᆞᆷ이라 허믈ᄒᆞ랴\\ @@ -254,8 +254,8 @@ fontspec의 글꼴 옵션 외에 \luatexko가 따로 제공하는 것들이 \section{} %\begin{figure} -%\hfil\framebox[\linewidth]{\begin{vertical}{16em} -%\fontspec[Vertical=RotatedGlyphs]{Adobe Myungjo Std Medium} +%\framebox[\linewidth]{\begin{vertical}{16em} +%\fontspec[Vertical=RotatedGlyphs,RawFeature=+vhal]{Adobe Myungjo Std} %\parindent-1em\leftskip1em \linespread{1.5}\selectfont %\noindent 님의 침묵{\small(The Silent Beloved)} %\smallbreak @@ -278,26 +278,18 @@ fontspec의 글꼴 옵션 외에 \luatexko가 따로 제공하는 것들이 \luatex 에서는 아직 \hemph{세로쓰기를 지원하지 않는다}.% \footnote{굳이 세로쓰기를 실험해보고자 한다면 |ttx -t vmtx <폰트>.ttf| 명령의 결과물인 |<폰트>.ttx| 파일을 현재 디렉토리에 두어야 한다. 그런 다음 - |\string\begin\string{vertical\string}\string{<dimen>\string}...\string\end\string{vertical\string}| 환경을 이용하라. ttx에 대해선 + |\\begin\{vertical\}\{<dimen>\}...\\end\{vertical\}| + 환경을 이용하라. ttx에 대해선 \url{http://sourceforge.net/projects/fonttools/} 참조. 문서 전체에 대해 세로쓰기를 하려면 이 환경을 쓰는 대신 - |\string\verticaltypesetting| 명령을 전처리부에 선언한다.} + |\\verticaltypesetting| 명령을 전처리부에 선언한다.} \section{} 전처리부에서 |\usepackage{luamplib}|을 선언하면 \MP\ 코드를 문서 중간에 삽입할 수 있다. 한글이나 수식은 |btex| $\ldots$ |etex| 안에 넣어야 한다. 그림~\ref{fig:mplib} 참조. \begin{figure} -\setbox0\hbox{% -\begin{mplibcode} -beginfig(1); - draw fullcircle scaled 2cm; - dotlabel.bot(btex\TeX etex, origin); - dotlabel.rt(btex 루아 etex, dir 45*1cm); -endfig; -\end{mplibcode} -}% -\setbox2\vbox{\bigskip +\setbox0\vbox{% \begin{verbatim} \usepackage{luamplib} ... @@ -308,8 +300,18 @@ endfig; dotlabel.rt(btex 루아 etex, dir 45*1cm); endfig; \end{mplibcode} -\end{verbatim}}\wd2=.7\linewidth -\framebox[\linewidth]{\box2 \raise.8cm\box0 } +\end{verbatim} +\vskip-5\baselineskip +\begin{mplibcode} +verbatimtex \moveright95mm etex; +beginfig(1); + draw fullcircle scaled 2cm; + dotlabel.bot(btex\TeX etex, origin); + dotlabel.rt(btex 루아 etex, dir 45*1cm); +endfig; +\end{mplibcode} +\vskip\baselineskip} +\framebox[\linewidth]{\box0 } \caption{mplib 용례}\label{fig:mplib} \end{figure} @@ -393,9 +395,6 @@ ulem 패키지가 \luatexko와 궁합이 잘 맞지 않아{\small (줄바꿈에 사용한다. \section{} -hyperref 패키지는 |[unicode]| 옵션을 주어야 한다. - -\section{} |\luatexhangulnormalize=1|이라 지시하면 첫가끝 자모를 완성형 음절로, |2|라면 완성형 음절을 첫가끝 자모로 인코딩 변환한다. |0|이 할당되면 인코딩 변환 기능이 꺼진다. \XeTeX의 |\XeTeXinputnormalization| 명령과 diff --git a/Master/texmf-dist/tex/luatex/luatexko/luatexko-core.sty b/Master/texmf-dist/tex/luatex/luatexko/luatexko-core.sty index 871a4a29cab..22cf34ffdfa 100644 --- a/Master/texmf-dist/tex/luatex/luatexko/luatexko-core.sty +++ b/Master/texmf-dist/tex/luatex/luatexko/luatexko-core.sty @@ -14,7 +14,7 @@ \input luaotfload.sty \catcode`@ = 11 \else - \ProvidesPackage{luatexko-core}[2013/12/06 v1.3 Typesetting Korean with LuaTeX] + \ProvidesPackage{luatexko-core}[2014/01/04 v1.4 Typesetting Korean with LuaTeX] \RequirePackage{luaotfload}[2013/05/23] \fi @@ -33,12 +33,9 @@ \RequireLuaModule{luatexko} %% japanese/chinese/pre-modern -\protected\def\japanese{\frenchspacing\cjtypesetattr\@ne - \luatexkolatinspaceskip\parindent1em } -\protected\def\Schinese{\frenchspacing\cjtypesetattr\tw@ - \luatexkolatinspaceskip\parindent2em } -\protected\def\Tchinese{\frenchspacing\cjtypesetattr\thr@@ - \luatexkolatinspaceskip\parindent2em } +\protected\def\japanese{\frenchspacing\cjtypesetattr\@ne \parindent1em } +\protected\def\Schinese{\frenchspacing\cjtypesetattr\tw@ \parindent2em } +\protected\def\Tchinese{\frenchspacing\cjtypesetattr\thr@@\parindent2em } \let\chinese\Schinese % korean in japanese/chinese env. \protected\def\korean{\unsetluatexattribute\cjtypesetattr} @@ -46,9 +43,6 @@ % inhibitglue \protected\def\inhibitglue{{\unsetluatexattribute\cjtypesetattr\hskip\z@skip}} -\def\luatexkolatinspaceskip{\spaceskip\fontdimen\tw@\the\font - plus \fontdimen\thr@@\the\font minus \fontdimen4\the\font} - %% auto josa \def\josaignoreparens{\afterassignment\josa@ignore@parens\count@} \def\josa@ignore@parens{% @@ -245,7 +239,6 @@ \expandafter\expandafter\expandafter \endgroup \expandafter\hanjfntattr\luatexfontid\font\relax -% \ifnum\cjtypesetattr>\z@\luatexkolatinspaceskip\fi } \def\luatexko@fallback@selectfont{% \begingroup @@ -257,7 +250,6 @@ \expandafter\expandafter\expandafter \endgroup \expandafter\fallbackfntattr\luatexfontid\font\relax -% \ifnum\cjtypesetattr>\z@\luatexkolatinspaceskip\fi } \let\check@hangul@family\relax \let\check@hanja@family \relax @@ -364,9 +356,6 @@ \fi\fi } -%% frenchspacing is default -\frenchspacing - %% 말줄임표 \def\hellipsis{^^^^2026^^^^2026} diff --git a/Master/texmf-dist/tex/luatex/luatexko/luatexko.lua b/Master/texmf-dist/tex/luatex/luatexko/luatexko.lua index 3d24259379d..8ef25e1f439 100644 --- a/Master/texmf-dist/tex/luatex/luatexko/luatexko.lua +++ b/Master/texmf-dist/tex/luatex/luatexko/luatexko.lua @@ -12,8 +12,8 @@ local err,warn,info,log = luatexbase.provides_module({ name = 'luatexko', - date = '2013/12/06', - version = 1.3, + date = '2014/01/06', + version = 1.4, description = 'Korean linebreaking and font-switching', author = 'Dohyun Kim', license = 'LPPL v1.3+', @@ -528,6 +528,11 @@ local function is_jungjongsong (c) or c == 0x302E or c == 0x302F -- tone marks end +local function is_unicode_vs (c) + return (c >= 0xFE00 and c <= 0xFE0F ) + or (c >= 0xE0100 and c <= 0xE01EF) +end + local function get_cjk_class (ch, cjtype) if ch then if is_hangul(ch) then return 7 end -- hangul = 7 @@ -890,60 +895,63 @@ end ---------------------------------- local function compress_fullwidth_punctuations (head) for curr in traverse_id(glyphnode,head) do - local uni = get_unicode_char(curr) - local class = uni and get_cjk_class(uni, has_attribute(curr, cjtypesetattr)) - local chr = get_font_char(curr.font, curr.char) - if chr and class and class >= 1 and class <= 4 then - local width = curr.width or 655360 - emsize = get_font_emsize(curr.font) - local ensize = emsize/2 - local oneoften = emsize/10 - local bbox = get_char_boundingbox(curr.font, curr.char) - if not bbox then return head end -- - if class == 2 or class == 4 then - local wd - if get_font_feature(curr.font,'vertical') then - wd = ensize<width and ensize-width or 0 - else - wd = (bbox[3] < ensize) and ensize-width or bbox[3]-width+oneoften - end - if chr.right_protruding then - -- kern is a breakpoint if followed by a glue - insert_after(head, curr, get_kernnode(wd)) - else - insert_after(head, curr, get_rulenode(wd)) - end - elseif class == 1 then - local wd - if get_font_feature(curr.font,'vertical') then - wd = ensize<width and ensize-width or 0 - else - wd = (width-bbox[1] < ensize) and ensize-width or -bbox[1]+oneoften - end - if chr.left_protruding then - head = insert_before(head, curr, get_kernnode(wd)) - else - head = insert_before(head, curr, get_rulenode(wd)) - end - elseif class == 3 then - local lwd, rwd - local quarter, thirdquarter, halfwd = ensize/2, ensize*1.5, width/2 - if get_font_feature(curr.font,'vertical') then - rwd = quarter<halfwd and quarter-halfwd or 0 - lwd = rwd - else - rwd = (bbox[3] < thirdquarter) and quarter-halfwd or bbox[3]-width - lwd = (width-bbox[1] < thirdquarter) and quarter-halfwd or -bbox[1] - end - if chr.left_protruding then - head = insert_before(head, curr, get_kernnode(lwd)) - else - head = insert_before(head, curr, get_rulenode(lwd)) - end - if chr.right_protruding then - insert_after (head, curr, get_kernnode(rwd)) - else - insert_after (head, curr, get_rulenode(rwd)) + if get_font_feature(curr.font,'halt') or get_font_feature(curr.font,'vhal') then + else + local uni = get_unicode_char(curr) + local class = uni and get_cjk_class(uni, has_attribute(curr, cjtypesetattr)) + local chr = get_font_char(curr.font, curr.char) + if chr and class and class >= 1 and class <= 4 then + local width = curr.width or 655360 + emsize = get_font_emsize(curr.font) + local ensize = emsize/2 + local oneoften = emsize/10 + local bbox = get_char_boundingbox(curr.font, curr.char) + if not bbox then return head end -- + if class == 2 or class == 4 then + local wd + if get_font_feature(curr.font,'vertical') then + wd = ensize<width and ensize-width or 0 + else + wd = (bbox[3] < ensize) and ensize-width or bbox[3]-width+oneoften + end + if chr.right_protruding then + -- kern is a breakpoint if followed by a glue + insert_after(head, curr, get_kernnode(wd)) + else + insert_after(head, curr, get_rulenode(wd)) + end + elseif class == 1 then + local wd + if get_font_feature(curr.font,'vertical') then + wd = ensize<width and ensize-width or 0 + else + wd = (width-bbox[1] < ensize) and ensize-width or -bbox[1]+oneoften + end + if chr.left_protruding then + head = insert_before(head, curr, get_kernnode(wd)) + else + head = insert_before(head, curr, get_rulenode(wd)) + end + elseif class == 3 then + local lwd, rwd + local quarter, thirdquarter, halfwd = ensize/2, ensize*1.5, width/2 + if get_font_feature(curr.font,'vertical') then + rwd = quarter<halfwd and quarter-halfwd or 0 + lwd = rwd + else + rwd = (bbox[3] < thirdquarter) and quarter-halfwd or bbox[3]-width + lwd = (width-bbox[1] < thirdquarter) and quarter-halfwd or -bbox[1] + end + if chr.left_protruding then + head = insert_before(head, curr, get_kernnode(lwd)) + else + head = insert_before(head, curr, get_rulenode(lwd)) + end + if chr.right_protruding then + insert_after (head, curr, get_kernnode(rwd)) + else + insert_after (head, curr, get_rulenode(rwd)) + end end end end @@ -1408,7 +1416,7 @@ local function font_substitute(head) end end end - if not korid then + if not korid and not is_unicode_vs(curr.char) then warn("!Missing character: %s U+%04X", utf8char(curr.char),curr.char) end end @@ -1427,136 +1435,9 @@ local function assign_unicode_codevalue (head) return head end - ------------------------------------- --- vertical typesetting: EXPERIMENTAL -- don't use this ------------------------------------- ----[[no vwidth in luaotfload v2 -local tsbtable = {} - -local function read_tsb_table(filename)-- for ttx-generated vmtx table - if tsbtable[filename] then - return tsbtable[filename] - end - local filepath = kpse.find_file(filename) - if not filepath then return end - local file = io.open(filepath, "r") - if not file then return end - local tsbtb = {} - local patt = 'name="(.-)" height="(.-)" tsb="(.-)"' - while true do - local l = file:read("*line") - if not l then break end - for name, height, tsb in stringgmatch(l,patt) do - tsbtb[name] = {} - tsbtb[name].height = height - tsbtb[name].tsb = tsb - end - end - file:close() - tsbtable[filename] = tsbtb - return tsbtb -end - -local function cjk_vertical_font (vf) - if not vf.shared then return end - if not vf.shared.features then return end - if not vf.shared.features["vertical"] then return end - if vf.type == "virtual" then return end - - --- for read-ttx - local filename = vf.filename - filename = stringgsub(filename,".*/","") - filename = stringgsub(filename,"[tToO][tT][fF]$","ttx") - local tsbtable = read_tsb_table(filename) - if not tsbtable then - warn("Cannot read %s. Aborting vertical typesetting.",filename) - return - end - --- - - local tmp = table.copy(vf) -- fastcopy takes time too long. - local id = fontdefine(tmp) - - local hash = vf.properties and vf.properties.hash and vf.properties.hash..' @ vertical' - hash = hash or (vf.name and vf.size and vf.name..' @ '..vf.size..' @ vertical') - - vf.properties = vf.properties or {} - vf.properties.hash = vf.properties.hash or "" - vf.properties.hash = hash - vf.type = 'virtual' - vf.fonts = {{ id = id }} - local quad = vf.parameters and vf.parameters.quad or 655360 - local descriptions = vf.shared and vf.shared.rawdata and vf.shared.rawdata.descriptions - local ascender = vf.parameters and vf.parameters.ascender - local factor = vf.parameters and vf.parameters.factor - local halfxht = (vf.parameters and vf.parameters.x_height and vf.parameters.x_height/2) or quad/4 - for i,v in pairs(vf.characters) do - local dsc = descriptions[i] - local gname = dsc.name - -- local vw = dsc and dsc.vwidth - --- for read-ttx - local vw = tsbtable and tsbtable[gname] and tsbtable[gname].height - local tsb = tsbtable and tsbtable[gname] and tsbtable[gname].tsb - if not vw and dsc.index then - local cid = stringformat("cid%05d", dsc.index) - vw = tsbtable and tsbtable[cid] and tsbtable[cid].height - tsb = tsbtable and tsbtable[cid] and tsbtable[cid].tsb - end - tsb = tsb and factor and tsb*factor - --- - vw = vw and factor and vw * factor - vw = vw or quad - local vh = dsc and dsc.boundingbox and dsc.boundingbox[3] - vh = vh and factor and vh * factor - vh = vh and vh - quad/2 or quad/2 - vh = vh + halfxht - vh = vh > 0 and vh or nil - local vd = dsc and dsc.boundingbox and dsc.boundingbox[1] - vd = vd and factor and vd * factor - vd = vd and quad/2 - vd or quad/2 - vd = vd - halfxht - vd = vd > 0 and vd or nil - local bb4 = dsc and dsc.boundingbox and dsc.boundingbox[4] - bb4 = bb4 and factor and bb4*factor - local asc = bb4 and tsb and bb4 + tsb - asc = asc or ascender - v.commands = { - {'right', asc}, -- bbox4 + top_side_bearing! But, tsb not available! - {'down', halfxht}, - {'special', 'pdf: q 0 1 -1 0 0 0 cm'}, - {'push'}, - {'char', i}, - {'pop'}, - {'special', 'pdf: Q'}, - } - v.width = vw - v.height = vh - v.depth = vd - end - return vf -end - -local function activate_vertical_virtual (tfmdata,value) - 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.vertical_virtual_font") - end -end - -local otffeatures = fonts.constructors.newfeatures("otf") -otffeatures.register { - name = "vertical", - description = "vertical typesetting", - initializers = { - node = activate_vertical_virtual, - } -} ---no vwidth in luaotfload v2]] - +----------------------------- +-- reorder hangul tone marks +----------------------------- local function reorderTM (head) for curr in traverse_id(glyphnode, head) do if curr.width > 0 then -- old hangul vertical typesetting is broken? @@ -1579,6 +1460,29 @@ local function reorderTM (head) return head end +----------------------------- +-- ideographic variation selector +----------------------------- +local function hanja_vs_support (head) + for curr in traverse_id(glyphnode, head) do + local cc = curr.char + if is_unicode_vs(cc) then + local prev = curr.prev + if prev and prev.id == glyphnode then + local f = get_font_table(prev.font) + local ivs = f and f.resources and f.resources.variants + ivs = ivs and ivs[cc] and ivs[cc][prev.char] + -- !!! ARRRG! the font table doesn't have variants for non-BMP chars. + if ivs then + prev.char = ivs + head = remove_node(head,curr) + end + end + end + end + return head +end + ---------------------------------- -- add to callback : pre-linebreak ---------------------------------- @@ -1587,6 +1491,7 @@ add_to_callback('hpack_filter', function(head) korean_autojosa(head) remove_cj_spaceskip(head) font_substitute(head) + head = hanja_vs_support(head) return head end, 'luatexko.hpack_filter_first',1) @@ -1605,6 +1510,7 @@ add_to_callback('pre_linebreak_filter', function(head) korean_autojosa(head) remove_cj_spaceskip(head) font_substitute(head) + head = hanja_vs_support(head) return head end, 'luatexko.pre_linebreak_filter_first',1) @@ -1669,7 +1575,7 @@ local function after_linebreak_ruby (head) after_linebreak_ruby(curr.head) -- hlist may be nested!!! local attr = has_attribute(curr,luakorubyattr) if attr then - local ruby = rubynode[attr][1] + local ruby = rubynode[attr] and rubynode[attr][1] if ruby then if ruby.width < curr.width then local rubyhead = ruby.head @@ -1759,3 +1665,176 @@ add_to_callback("post_linebreak_filter", function(head) return head end, 'luatexko.post_linebreak_filter') + +------------------------------------ +-- vertical typesetting: EXPERIMENTAL -- don't use this +------------------------------------ +---[[no vwidth in luaotfload v2 +local tsbtable = {} + +local function read_tsb_table(filename)-- for ttx-generated vmtx table + if tsbtable[filename] then + return tsbtable[filename] + end + local filepath = kpse.find_file(filename) + if not filepath then return end + local file = io.open(filepath, "r") + if not file then return end + local tsbtb = {} + local patt = 'name="(.-)" height="(.-)" tsb="(.-)"' + while true do + local l = file:read("*line") + if not l then break end + for name, height, tsb in stringgmatch(l,patt) do + tsbtb[name] = {} + tsbtb[name].height = height + tsbtb[name].tsb = tsb + end + end + file:close() + tsbtable[filename] = tsbtb + return tsbtb +end + +local function cjk_vertical_font (vf) + if not vf.shared then return end + if not vf.shared.features then return end + if not vf.shared.features["vertical"] then return end + if vf.type == "virtual" then return end + + ---[[ for read-ttx + local filename = vf.filename + filename = stringgsub(filename,".*/","") + filename = stringgsub(filename,"[tToO][tT][fF]$","ttx") + local tsbtable = read_tsb_table(filename) + if not tsbtable then + warn("Cannot read %s. Aborting vertical typesetting.",filename) + return + end + --]] + + local tmp = table.copy(vf) -- fastcopy takes time too long. + local id = fontdefine(tmp) + + local hash = vf.properties and vf.properties.hash and vf.properties.hash..' @ vertical' + hash = hash or (vf.name and vf.size and vf.name..' @ '..vf.size..' @ vertical') + + vf.properties = vf.properties or {} + vf.properties.hash = hash + vf.type = 'virtual' + vf.fonts = {{ id = id }} + local quad = vf.parameters and vf.parameters.quad or 655360 + local descriptions = vf.shared and vf.shared.rawdata and vf.shared.rawdata.descriptions + local ascender = vf.parameters and vf.parameters.ascender or quad*0.8 + local factor = vf.parameters and vf.parameters.factor or 655.36 + local xheight = vf.parameters and vf.parameters.x_height or quad/2 + local halfxht = xheight/2 + for i,v in pairs(vf.characters) do + local dsc = descriptions[i] + local gname = dsc.name + -- local vw = dsc and dsc.vwidth + ---[[ for read-ttx + local vw = tsbtable and tsbtable[gname] and tsbtable[gname].height + local tsb = tsbtable and tsbtable[gname] and tsbtable[gname].tsb + if not vw and dsc.index then + local cid = stringformat("cid%05d", dsc.index) + vw = tsbtable and tsbtable[cid] and tsbtable[cid].height + tsb = tsbtable and tsbtable[cid] and tsbtable[cid].tsb + end + tsb = tsb and factor and tsb*factor + --]] + vw = vw and vw * factor or quad + local hw = v.width or quad + local offset = hw/2 - quad/2 + halfxht + local vh = (hw > 0) and hw/2 or nil + local bb4 = dsc and dsc.boundingbox and dsc.boundingbox[4] + bb4 = bb4 and bb4*factor + local asc = bb4 and tsb and (bb4 + tsb) + asc = asc or ascender + v.commands = { + {'right', asc}, -- bbox4 + top_side_bearing! But, tsb not available! + {'down', offset}, + {'special', 'pdf: q 0 1 -1 0 0 0 cm'}, + {'push'}, + {'char', i}, + {'pop'}, + {'special', 'pdf: Q'}, + } + v.width = vw + v.height = vh + v.depth = vh + end + --- vertical gpos + local res = vf.resources or {} + if res.verticalgposhack then + return vf -- avoid multiple running + end + local vposkeys = {} + local seq = res.sequences or {} + for _,v in ipairs(seq) do + if v.type == "gpos_single" and v.subtables then -- todo: gpos_pair... + local feature = v.features or {} + if feature.vhal or feature.vkrn or feature.valt or feature.vpal then + for _,vv in ipairs(v.subtables) do + vposkeys[#vposkeys+1] = vv + end + end + end + end + local lookups = res.lookuphash or {} + for _,v in ipairs(vposkeys) do + local vp = lookups[v] + if vp then + for i,vv in pairs(vp) do + if #vv == 4 then + vp[i] = { -vv[2], vv[1], vv[4], vv[3] } + end + end + end + end + res.verticalgposhack = true + return vf +end + +local function activate_vertical_virtual (tfmdata,value) + 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.vertical_virtual_font") + end +end + +local otffeatures = fonts.constructors.newfeatures("otf") +otffeatures.register { + name = "vertical", + description = "vertical typesetting", + initializers = { + node = activate_vertical_virtual, + } +} +--no vwidth in luaotfload v2]] + +------------------------------------ +-- italic correction for fake-slant font +------------------------------------ +local function fakeslant_itlc (tfmdata) + local slfactor = tfmdata.parameters.slantfactor + if slfactor and slfactor > 0 then else return end + tfmdata.parameters.slant = slfactor * 65536 + local factor = tfmdata.parameters.factor or 655.36 + local itlcoff = (tfmdata.shared.rawdata.metadata.uwidth or 40)/2 * factor + local chrs = tfmdata.characters + for i,v in pairs(chrs) do + local italic = v.height * slfactor - itlcoff + if italic > 0 then + chrs[i].italic = italic + end + end +end + +add_to_callback("luaotfload.patch_font", + fakeslant_itlc, + "luatexko.fakeslant_itlc") + diff --git a/Master/texmf-dist/tex/luatex/luatexko/luatexko.sty b/Master/texmf-dist/tex/luatex/luatexko/luatexko.sty index 454fd857e1c..5d6d6d69fa8 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/11/22 v1.3 Typesetting Korean with LuaLaTeX] +\ProvidesPackage{luatexko}[2014/01/15 v1.4 Typesetting Korean with LuaLaTeX] \RequirePackage{fontspec} \RequirePackage{luatexko-core} @@ -131,29 +131,29 @@ \protected\def\addhangulfontfeature#1{% \begingroup \check@hangul@family - \ifdefined\hangul@font\hangul@font\fi\addfontfeature{#1}\global - \let\luatexko@fontspec@temp\f@family + \ifdefined\hangul@font\hangul@font\fi\addfontfeature{#1}% + \global\let\luatexko@fontspec@temp\f@family \endgroup - \def\hangul@font{\fontfamily\luatexko@fontspec@temp - \luatexko@orig@selectfont}\luatexko@hangul@selectfont \ignorespaces} + \def\hangul@font{\fontfamily\luatexko@fontspec@temp\selectfont}% + \luatexko@hangul@selectfont \ignorespaces} \let\addhangulfontfeatures\addhangulfontfeature \protected\def\addhanjafontfeature#1{% \begingroup \check@hanja@family - \ifdefined\hanja@font\hanja@font\fi\addfontfeature{#1}\global - \let\luatexko@fontspec@temp\f@family + \ifdefined\hanja@font\hanja@font\fi\addfontfeature{#1}% + \global\let\luatexko@fontspec@temp\f@family \endgroup - \def\hanja@font{\fontfamily\luatexko@fontspec@temp - \luatexko@orig@selectfont}\luatexko@hanja@selectfont \ignorespaces} + \def\hanja@font{\fontfamily\luatexko@fontspec@temp\selectfont}% + \luatexko@hanja@selectfont \ignorespaces} \let\addhanjafontfeatures\addhanjafontfeature \protected\def\addfallbackfontfeature#1{% \begingroup \check@fallback@family - \ifdefined\fallback@font\fallback@font\fi\addfontfeature{#1}\global - \let\luatexko@fontspec@temp\f@family + \ifdefined\fallback@font\fallback@font\fi\addfontfeature{#1}% + \global\let\luatexko@fontspec@temp\f@family \endgroup - \def\fallback@font{\fontfamily\luatexko@fontspec@temp - \luatexko@orig@selectfont}\luatexko@fallback@selectfont \ignorespaces} + \def\fallback@font{\fontfamily\luatexko@fontspec@temp\selectfont}% + \luatexko@fallback@selectfont \ignorespaces} \let\addfallbackfontfeatures\addfallbackfontfeature % check hangul/hanja family @@ -179,8 +179,8 @@ \fi\fi\fi } -\let\luatexko@orig@selectfont\selectfont -\protected\def\selectfont{\luatexko@orig@selectfont +\RequirePackage{everysel} +\EverySelectfont{% \luatexko@hangul@selectfont \luatexko@hanja@selectfont \luatexko@fallback@selectfont @@ -245,6 +245,8 @@ \unless\ifdefined\sanshangul@font \let\sanshangul@font\serifhangul@font\fi \unless\ifdefined\monohangul@font \let\monohangul@font\sanshangul@font \fi \luatexko@hangul@selectfont +\luatexko@hanja@selectfont +\luatexko@fallback@selectfont % for hyperref \@ifpackageloaded{hyperref}{\pdfstringdefDisableCommands{% \let\dotemph\@firstofone @@ -297,6 +299,7 @@ \footnotesep=1.3888\footnotesep \skip\footins=1.3888\skip\footins plus6pt minus3pt \hangulpunctuations=1 + \frenchspacing \fi \endinput |