diff options
author | Karl Berry <karl@freefriends.org> | 2017-02-08 22:19:36 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2017-02-08 22:19:36 +0000 |
commit | c19658b290f5817349b25ac63fa6d2b9172a045b (patch) | |
tree | 6311f7e5cefd488a0d7179bc06e5a929c431b854 /Master/texmf-dist/tex/luatex | |
parent | 3396e1d4f500a6070e5de215d8b1a55713bb93fe (diff) |
luatexko (8feb17)
git-svn-id: svn://tug.org/texlive/trunk@43172 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/luatex')
5 files changed, 342 insertions, 358 deletions
diff --git a/Master/texmf-dist/tex/luatex/luatexko/luatexko-core.sty b/Master/texmf-dist/tex/luatex/luatexko/luatexko-core.sty index 06e7e1e65a0..c7eb2e15973 100644 --- a/Master/texmf-dist/tex/luatex/luatexko/luatexko-core.sty +++ b/Master/texmf-dist/tex/luatex/luatexko/luatexko-core.sty @@ -1,6 +1,6 @@ % luatexko-core.sty % -% Copyright (c) 2013-2016 Dohyun Kim <nomos at ktug org> +% Copyright (c) 2013-2017 Dohyun Kim <nomos at ktug org> % Soojin Nam <jsunam at gmail com> % % This work may be distributed and/or modified under the @@ -17,7 +17,7 @@ \ifcsname ifpdf\endcsname\else \input ifpdf.sty \fi \catcode`@ = 11 \else - \ProvidesPackage{luatexko-core}[2016/05/14 v1.15 Typesetting Korean with LuaTeX] + \ProvidesPackage{luatexko-core}[2017/02/06 v1.16 Typesetting Korean with LuaTeX] \RequirePackage{luaotfload}[2016/04/21] \RequirePackage{ifpdf} \fi @@ -32,7 +32,11 @@ \let\luaescapestring\luatexluaescapestring \fi \ifdefined\pdffontsize\else % luatex 0.87 - \def\pdffontsize{\pdffeedback fontsize} + \ifpdf + \def\pdffontsize{\pdffeedback fontsize} + \else + \def\pdffontsize{\the\fontdimen6 } + \fi \protected\def\pdfliteral{\pdfextension literal} \fi @@ -282,24 +286,25 @@ \global\advance\luakoulineboxcnt\@ne \count@\luakoulineboxcnt \leavevmode} -\protected\def\uline#1{% +\protected\def\ulineluatexko#1{% \luako@uline@code@common \luako@nested@ulinedown \dimen@\dimexpr\ulinedown+\ulinewidth\relax \dimen@ii-\dimexpr\ulinedown\relax \setbox\z@\hbox{\vrule width\z@ height\dimen@ii depth\dimen@}% \directlua{ luatexko.uline_boundary(\the\count@,tex.box[0].head) }% - #1% + #1\relax \directlua{ luatexko.uline_boundary(\the\count@) }% \endgroup} -\protected\def\sout#1{{\def\ulinedown{-0.5ex-\ulinewidth/2}\uline{#1}}} -\protected\def\uuline#1{\uline{\uline{#1}}} +\let\uline\ulineluatexko +\protected\def\sout#1{{\def\ulinedown{-0.5ex-\ulinewidth/2}\ulineluatexko{#1}}} +\protected\def\uuline#1{\ulineluatexko{\ulineluatexko{#1}}} % ulem with arbitray box \protected\def\markoverwith#1#2{% \luako@uline@code@common \setbox\z@\hbox{#1}% \directlua{ luatexko.uline_boundary(\the\count@,tex.box[0]) }% - #2% + #2\relax \directlua{ luatexko.uline_boundary(\the\count@) }% \endgroup} \protected\def\uwave{\ifx\ltxko@sixly\undefined \font\ltxko@sixly=lasy6 \fi diff --git a/Master/texmf-dist/tex/luatex/luatexko/luatexko-normalize.lua b/Master/texmf-dist/tex/luatex/luatexko/luatexko-normalize.lua index 9ed25f4cb09..3018b6e081b 100644 --- a/Master/texmf-dist/tex/luatex/luatexko/luatexko-normalize.lua +++ b/Master/texmf-dist/tex/luatex/luatexko/luatexko-normalize.lua @@ -1,6 +1,6 @@ -- luatexko-normalize.lua -- --- Copyright (c) 2013-2016 Dohyun Kim <nomos at ktug org> +-- Copyright (c) 2013-2017 Dohyun Kim <nomos at ktug org> -- Soojin Nam <jsunam at gmail com> -- -- This work may be distributed and/or modified under the @@ -13,8 +13,8 @@ luatexbase.provides_module({ name = "luatexko-normalize", - version = "1.13", - date = "2016/04/25", + version = "1.16", + date = "2017/02/06", author = "Dohyun Kim, Soojin Nam", description = "Hangul normalization", license = "LPPL v1.3+", diff --git a/Master/texmf-dist/tex/luatex/luatexko/luatexko-uhc2utf8.lua b/Master/texmf-dist/tex/luatex/luatexko/luatexko-uhc2utf8.lua index 721d647aa9a..9d73b622ea0 100644 --- a/Master/texmf-dist/tex/luatex/luatexko/luatexko-uhc2utf8.lua +++ b/Master/texmf-dist/tex/luatex/luatexko/luatexko-uhc2utf8.lua @@ -1,6 +1,6 @@ -- luatexko-uhc2utf8.lua -- --- Copyright (c) 2013-2016 Dohyun Kim <nomos at ktug org> +-- Copyright (c) 2013-2017 Dohyun Kim <nomos at ktug org> -- Soojin Nam <jsunam at gmail com> -- -- This work may be distributed and/or modified under the @@ -13,8 +13,8 @@ luatexbase.provides_module({ name = "luatexko-uhc2utf8", - version = "1.13", - date = "2016/04/25", + version = "1.16", + date = "2017/02/06", author = "Dohyun Kim, Soojin Nam", description = "UHC (CP949) input encoding", license = "LPPL v1.3+", diff --git a/Master/texmf-dist/tex/luatex/luatexko/luatexko.lua b/Master/texmf-dist/tex/luatex/luatexko/luatexko.lua index 0888aec134a..48d70f5e809 100644 --- a/Master/texmf-dist/tex/luatex/luatexko/luatexko.lua +++ b/Master/texmf-dist/tex/luatex/luatexko/luatexko.lua @@ -1,6 +1,6 @@ -- luatexko.lua -- --- Copyright (c) 2013-2016 Dohyun Kim <nomos at ktug org> +-- Copyright (c) 2013-2017 Dohyun Kim <nomos at ktug org> -- Soojin Nam <jsunam at gmail com> -- -- This work may be distributed and/or modified under the @@ -13,8 +13,8 @@ luatexbase.provides_module { name = 'luatexko', - date = '2016/05/14', - version = '1.15', + date = '2017/02/06', + version = '1.16', description = 'Korean linebreaking and font-switching', author = 'Dohyun Kim, Soojin Nam', license = 'LPPL v1.3+', @@ -129,135 +129,112 @@ local emsize = 655360 local cjkclass = { [0x2018] = 1, -- ‘ [0x201C] = 1, -- “ - [0xFF08] = 1, -- ( - [0xFE35] = 1, -- ( vert - [0x3014] = 1, -- 〔 - [0xFE39] = 1, -- 〔 vert - [0xFF3B] = 1, -- [ - [0xFE47] = 1, -- [ vert - [0xFF5B] = 1, -- { - [0xFE37] = 1, -- { vert + [0x2329] = 1, -- 〈 [0x3008] = 1, -- 〈 - [0xFE3F] = 1, -- 〈 vert [0x300A] = 1, -- 《 - [0xFE3D] = 1, -- 《 vert [0x300C] = 1, -- 「 - [0xFE41] = 1, -- 「 vert [0x300E] = 1, -- 『 - [0xFE43] = 1, -- 『 vert [0x3010] = 1, -- 【 - [0xFE3B] = 1, -- 【 vert - [0x3001] = 2, -- 、 - [0xFE11] = 2, -- 、 vert - [0xFF0C] = 2, -- , - [0xFE10] = 2, -- , vert + [0x3014] = 1, -- 〔 + [0x3016] = 1, -- 〖 + [0x3018] = 1, -- 〘 + [0x301A] = 1, -- 〚 + [0x301D] = 1, -- 〝 + [0xFE17] = 1, -- ︗ + [0xFE35] = 1, -- ︵ + [0xFE37] = 1, -- ︷ + [0xFE39] = 1, -- ︹ + [0xFE3B] = 1, -- ︻ + [0xFE3D] = 1, -- ︽ + [0xFE3F] = 1, -- ︿ + [0xFE41] = 1, -- ﹁ + [0xFE43] = 1, -- ﹃ + [0xFE47] = 1, -- ﹇ + [0xFF08] = 1, -- ( + [0xFF3B] = 1, -- [ + [0xFF5B] = 1, -- { + [0xFF5F] = 1, -- ⦅ + [0xFF62] = 1, -- 「 half [0x2019] = 2, -- ’ [0x201D] = 2, -- ” - [0xFF09] = 2, -- ) - [0xFE36] = 2, -- ) vert - [0x3015] = 2, -- 〕 - [0xFE3A] = 2, -- 〕 vert - [0xFF3D] = 2, -- ] - [0xFE48] = 2, -- ] vert - [0xFF5D] = 2, -- } - [0xFE38] = 2, -- } vert + [0x232A] = 2, -- 〉 + [0x3001] = 2, -- 、 [0x3009] = 2, -- 〉 - [0xFE40] = 2, -- 〉 vert [0x300B] = 2, -- 》 - [0xFE3E] = 2, -- 》 vert [0x300D] = 2, -- 」 - [0xFE42] = 2, -- 」 vert [0x300F] = 2, -- 』 - [0xFE44] = 2, -- 』 vert [0x3011] = 2, -- 】 - [0xFE3C] = 2, -- 】 vert + [0x3015] = 2, -- 〕 + [0x3017] = 2, -- 〗 + [0x3019] = 2, -- 〙 + [0x301B] = 2, -- 〛 + [0x301E] = 2, -- 〞 + [0x301F] = 2, -- 〟 + [0xFE10] = 2, -- ︐ + [0xFE11] = 2, -- ︑ + [0xFE18] = 2, -- ︘ + [0xFE36] = 2, -- ︶ + [0xFE38] = 2, -- ︸ + [0xFE3A] = 2, -- ︺ + [0xFE3C] = 2, -- ︼ + [0xFE3E] = 2, -- ︾ + [0xFE40] = 2, -- ﹀ + [0xFE42] = 2, -- ﹂ + [0xFE44] = 2, -- ﹄ + [0xFE48] = 2, -- ﹈ + [0xFF09] = 2, -- ) + [0xFF0C] = 2, -- , + [0xFF3D] = 2, -- ] + [0xFF5D] = 2, -- } + [0xFF60] = 2, -- ⦆ + [0xFF63] = 2, -- 」 half + [0xFF64] = 2, -- 、 half [0x00B7] = 3, -- · [0x30FB] = 3, -- ・ [0xFF1A] = 3, -- : --- [0xFE13] = 3, -- : vert [0xFF1B] = 3, -- ; --- [0xFE14] = 3, -- ; vert + [0xFF65] = 3, -- ・ half [0x3002] = 4, -- 。 - [0xFE12] = 4, -- 。 vert + [0xFE12] = 4, -- ︒ [0xFF0E] = 4, -- . - [0x2015] = 5, -- ― - [0x2026] = 5, -- … - [0xFE19] = 5, -- … vert + [0xFF61] = 4, -- 。 half + [0x2015] = 5, -- ― [0x2025] = 5, -- ‥ - [0xFE30] = 5, -- ‥ vert - [0xFE31] = 5, -- ︱ vert - [0xFF1F] = 6, -- ? + [0x2026] = 5, -- … + [0xFE19] = 5, -- ︙ + [0xFE30] = 5, -- ︰ + [0xFE31] = 5, -- ︱ + [0xFE15] = 6, -- ︕ + [0xFE16] = 6, -- ︖ [0xFF01] = 6, -- ! - [0xFE16] = 6, -- ︖ vert - [0xFE15] = 6, -- ︕ vert + [0xFF1F] = 6, -- ? } -local inhibitxspcode = { +local inhibitxspcode = setmetatable({ [0x002D] = 0, -- - hyphen minus [0x003C] = 0, -- < [0x003E] = 1, -- > - [0x00B0] = 1, - [0x2015] = 0, - [0x2018] = 2, - [0x2019] = 1, - [0x201C] = 2, - [0x201D] = 1, - [0x2026] = 0, - [0xFE19] = 0, - [0x2032] = 1, - [0x2033] = 1, - [0x3001] = 1, - [0xFE11] = 1, - [0x3002] = 1, - [0xFE12] = 1, - [0x3008] = 2, - [0xFE3F] = 2, - [0x3009] = 1, - [0xFE40] = 1, - [0x300A] = 2, - [0xFE3D] = 2, - [0x300B] = 1, - [0xFE3E] = 1, - [0x300C] = 2, - [0xFE41] = 2, - [0x300D] = 1, - [0xFE42] = 1, - [0x300E] = 2, - [0xFE43] = 2, - [0x300F] = 1, - [0xFE44] = 1, - [0x3010] = 2, - [0xFE3B] = 2, - [0x3011] = 1, - [0xFE3C] = 1, + [0x00B0] = 1, -- ° + [0x2032] = 1, -- ′ + [0x2033] = 1, -- ″ [0x3012] = 2, -- 〒 - [0x3014] = 2, - [0xFE39] = 2, - [0x3015] = 1, - [0xFE3A] = 1, - [0x301C] = 0, - [0xFF08] = 2, - [0xFE35] = 2, - [0xFF09] = 1, - [0xFE36] = 1, - [0xFF0C] = 1, - [0xFE10] = 1, - [0xFF0E] = 1, - [0xFF1B] = 1, - [0xFE14] = 1, - [0xFF1F] = 1, - [0xFF3B] = 2, - [0xFE47] = 2, - [0xFF3D] = 1, - [0xFE48] = 1, - [0xFF5B] = 2, - [0xFE37] = 2, - [0xFF5D] = 1, - [0xFE38] = 1, - [0xFFE5] = 0, -} + [0x301C] = 0, -- 〜 + [0xFE14] = 1, -- ︔ + [0xFF1B] = 1, -- ; + [0xFFE5] = 0, -- ¥ +},{ + __index = function (_,c) + if cjkclass[c] == 1 then + return 2 + elseif cjkclass[c] == 2 or cjkclass[c] == 4 or cjkclass[c] == 6 then + return 1 + elseif cjkclass[c] == 5 then + return 0 + end + end +}) -local postbreakpenalty = { +local postbreakpenalty = setmetatable({ [0x0023] = 500, [0x0024] = 500, [0x0025] = 500, @@ -266,37 +243,24 @@ local postbreakpenalty = { [0x003C] = 10000, -- < [0x005B] = 10000, [0x0060] = 10000, + [0x007B] = 10000, -- { + [0x00AB] = 10000, -- « [0x2013] = 50, -- en-dash [0x2014] = 50, -- em-dash - [0x2018] = 10000, - [0x201C] = 10000, - [0x3008] = 10000, - [0xFE3F] = 10000, - [0x300A] = 10000, - [0xFE3D] = 10000, - [0x300C] = 10000, - [0xFE41] = 10000, - [0x300E] = 10000, - [0xFE43] = 10000, - [0x3010] = 10000, - [0xFE3B] = 10000, - [0x3014] = 10000, - [0xFE39] = 10000, [0xFF03] = 200, [0xFF04] = 200, [0xFF05] = 200, [0xFF06] = 200, - [0xFF08] = 10000, - [0xFE35] = 10000, - [0xFF3B] = 10000, - [0xFE47] = 10000, - [0xFF40] = 10000, - [0xFF5B] = 10000, - [0xFE37] = 10000, - [0xFF62] = 10000, -- 「 -} + [0xFF40] = 10000, -- ` +},{ + __index = function (_,c) + if cjkclass[c] == 1 then + return 10000 + end + end +}) -local prebreakpenalty = { +local prebreakpenalty = setmetatable({ [0x0021] = 10000, [0x0022] = 10000, [0x0027] = 10000, @@ -312,35 +276,18 @@ local prebreakpenalty = { [0x003E] = 10000, -- > [0x003F] = 10000, [0x005D] = 10000, - [0x00B4] = 10000, - [0x00B7] = 10000, -- · + [0x007D] = 10000, -- } + [0x00B4] = 10000, -- ´ + [0x00BB] = 10000, -- » [0x2013] = 10000, -- – [0x2014] = 10000, -- — - [0x2015] = 10000, - [0x2019] = 10000, - [0x201D] = 10000, [0x2025] = 5000, -- 250, -- ‥ - [0xFE30] = 5000, -- 250, -- ︰ [0x2026] = 5000, -- 250, -- … - [0xFE19] = 5000, -- 250, -- ︙ [0x2212] = 5000, -- 200, -- − minus sign - [0x3001] = 10000, - [0xFE11] = 10000, - [0x3002] = 10000, - [0xFE12] = 10000, - [0x3005] = 10000, - [0x3009] = 10000, - [0xFE40] = 10000, - [0x300B] = 10000, - [0xFE3E] = 10000, - [0x300D] = 10000, - [0xFE42] = 10000, - [0x300F] = 10000, - [0xFE44] = 10000, - [0x3011] = 10000, - [0xFE3C] = 10000, - [0x3015] = 10000, - [0xFE3A] = 10000, + [0x3005] = 10000, -- 々 + [0x301C] = 10000, -- 〜 + [0x3035] = 10000, -- 〵 + [0x303B] = 10000, -- 〻 [0x3041] = 150, [0x3043] = 150, [0x3045] = 150, @@ -351,8 +298,13 @@ local prebreakpenalty = { [0x3085] = 150, [0x3087] = 150, [0x308E] = 150, - [0x309B] = 10000, - [0x309C] = 10000, + [0x3095] = 150, + [0x3096] = 150, + [0x309B] = 10000, -- ゛ + [0x309C] = 10000, -- ゜ + [0x309D] = 10000, -- ゝ + [0x309E] = 10000, -- ゞ + [0x30A0] = 10000, -- ゠ [0x30A1] = 150, [0x30A3] = 150, [0x30A5] = 150, @@ -365,27 +317,25 @@ local prebreakpenalty = { [0x30EE] = 150, [0x30F5] = 150, [0x30F6] = 150, - [0x30FB] = 10000, - [0x30FC] = 10000, - [0xFF01] = 10000, - [0xFF09] = 10000, - [0xFE36] = 10000, + [0x30FC] = 10000, -- ー + [0x30FD] = 10000, -- ヽ + [0x30FE] = 10000, -- ヾ + [0xFE13] = 10000, -- ︓ + [0xFE14] = 10000, -- ︔ + [0xFE19] = 5000, -- 250, -- ︙ + [0xFE30] = 5000, -- 250, -- ︰ + [0xFE32] = 10000, -- ︲ [0xFF0B] = 5000, -- 200, -- + - [0xFF0C] = 10000, - [0xFE10] = 10000, - [0xFF0E] = 10000, - [0xFF1A] = 10000, - [0xFE13] = 10000, - [0xFF1B] = 10000, - [0xFE14] = 10000, [0xFF1D] = 5000, -- 200, -- = - [0xFF1F] = 10000, - [0xFF3D] = 10000, - [0xFE48] = 10000, - [0xFF5D] = 10000, - [0xFE38] = 10000, - [0xFF63] = 10000, -- 」 -} + [0xFF9E] = 10000, -- ゙ + [0xFF9F] = 10000, -- ゚ +},{ + __index = function (_,c) + if cjkclass[c] and cjkclass[c] > 1 then + return 10000 + end + end +}) local xspcode = { [0x0027] = 2, @@ -593,10 +543,14 @@ local function get_cjk_class (ch, cjtype) end end +local type1fonts = {} + local function get_font_table (fid) if fid then if fontdata[fid] then return fontdata[fid] + elseif type1fonts[fid] then + return type1fonts[fid] else return font.fonts[fid] end @@ -1479,11 +1433,37 @@ local function hangulspaceskip (engfont, hfontid, glue) esh = esh and tex_round(esh) if esp == gsp and est == gst and esh == gsh then else return end local hf = get_font_table(hfontid) - if hf and hf.encodingbytes == 2 then else return end +-- if hf and hf.encodingbytes == 2 then else return end return gsp, hf end -local type1fonts = {} -- due to too verbose log +local function virtual_unifont (prefix,size) + local data = { + name = prefix.."vf", + type = "virtual", + fonts = {}, + characters = {}, + } + local fonts = data.fonts + local chars = data.characters + for index = 0, 255 do + local name = string.format(prefix.."%02x", index) + if kpse_find_file(name,"tfm") then + local tfm = font.read_tfm(name, size) + data.parameters = data.parameters or tfm.parameters + fonts[#fonts+1] = { name=name, size=size } + local fid = #fonts + local zro = 256 * index + for i,v in pairs(tfm.characters) do + local slot = zro + i + chars[slot] = v + chars[slot].commands = { { "slot", fid, i } } + end + end + end + return data +end + local function nanumtype1font(curr) local currchar, currfont = d_getchar(curr), d_getfont(curr) if currchar > 0xFFFF then return end @@ -1500,38 +1480,21 @@ local function nanumtype1font(curr) series = fnt_t.name:find("^cmb") and "b" or "m" end local shape = fnt_t.parameters.slant > 0 and "o" or "" - local subfnt = stringformat("%s%s%s%02x",family,series,shape,currchar/256) + local prefix = stringformat("%s%s%s",family,series,shape) local fsize = fnt_t.size or 655360 - local fspec = stringformat("%s@%d",subfnt,fsize) - local newfnt = type1fonts[fspec] - if newfnt == false then return end - local newchr = currchar % 256 - local function ital_corr (curr,chr_t) - if shape ~= "o" then return end - local nxt = d_getnext(curr) - if nxt and d_getid(nxt) == kernnode and d_getsubtype(nxt) == kern_type_itlc and d_getfield(nxt,"kern") == 0 then - d_setfield(nxt,"kern", chr_t.italic or 0) - end - end - if newfnt then - local fntchr = get_font_char(newfnt,newchr) - if fntchr then - d_setfield(curr,"font", newfnt) - d_setchar(curr, newchr) - ital_corr(curr,fntchr) - end - elseif kpse_find_file(subfnt,"tfm") then - local ft, id = fonts.constructors.readanddefine(subfnt,fsize) - local fntchr = ft and ft.characters[newchr] - if id and fntchr then - type1fonts[fspec] = id - d_setfield(curr,"font", id) - d_setchar(curr, newchr) - ital_corr(curr,fntchr) + local fspec = stringformat("%s@%d",prefix,fsize) + local fontid = type1fonts[fspec] + if fontid == nil then -- bypass false + local fontdata = virtual_unifont(prefix, fsize) + fontid = fontdata and fontdefine(fontdata) + if fontid then + type1fonts[fspec] = fontid + type1fonts[fontid] = fontdata + else + type1fonts[fspec] = false end - else - type1fonts[fspec] = false end + return fontid end local function font_substitute(head) @@ -1569,58 +1532,60 @@ local function font_substitute(head) uni = uni and get_cjk_class(uni) if uni and uni < 7 then ftable = {hanja, hangul, fallback} end end + local fid for i = 1,3 do - local fid = ftable[i] + fid = ftable[i] myfontchar = fid and get_font_char(fid, currchar) - if myfontchar then - d_setfield(curr,"font",fid) - --- charraise option charraise - local charraise = get_font_feature(fid, "charraise") - if charraise then - charraise = tex_sp(charraise) - local curryoffset = d_getfield(curr,"yoffset") or 0 - d_setfield(curr,"yoffset", charraise + curryoffset) - end - --- - local nxt = d_getnext(curr) - local nxtid = nxt and d_getid(nxt) - if nxtid == glyphnode and is_unicode_vs(d_getchar(nxt)) then - nxt = d_getnext(nxt) - nxtid = nxt and d_getid(nxt) - end - if eng and nxtid then - local nxtsubtype = d_getsubtype(nxt) - -- adjust next glue by hangul font space - if nxtid == gluenode and nxtsubtype == glue_type_space and get_font_char(fid,32) then - local oldwd, ft = hangulspaceskip(eng, fid, nxt) - if oldwd and ft then - local newwd = ft.space_char_width - if not newwd then - local newsp = d_tonode(d_copy_node(curr)) - newsp.char = 32 - newsp = nodes.simple_font_handler(newsp) - newwd = newsp and newsp.width - ft.space_char_width = newwd - node.free(newsp) - end - if newwd and oldwd ~= newwd then - d_setglue(nxt, newwd, newwd/2, newwd/3) - end + if myfontchar then break end + end + if not myfontchar and not hangulpunctuations[currchar] then + fid = nanumtype1font(curr) + myfontchar = fid and get_font_char(fid, currchar) + end + if myfontchar then + d_setfield(curr,"font",fid) + --- charraise option charraise + local charraise = get_font_feature(fid, "charraise") + if charraise then + charraise = tex_sp(charraise) + local curryoffset = d_getfield(curr,"yoffset") or 0 + d_setfield(curr,"yoffset", charraise + curryoffset) + end + --- + local nxt = d_getnext(curr) + local nxtid = nxt and d_getid(nxt) + if nxtid == glyphnode and is_unicode_vs(d_getchar(nxt)) then + nxt = d_getnext(nxt) + nxtid = nxt and d_getid(nxt) + end + if eng and nxtid then + local nxtsubtype = d_getsubtype(nxt) + -- adjust next glue by hangul font space + if nxtid == gluenode and nxtsubtype == glue_type_space and get_font_char(fid,32) then + local oldwd, ft = hangulspaceskip(eng, fid, nxt) + if oldwd and ft then + local newwd = ft.space_char_width + if not newwd then + local newsp = d_tonode(d_copy_node(curr)) + newsp.char = 32 + newsp = nodes.simple_font_handler(newsp) + newwd = newsp and newsp.width + ft.space_char_width = newwd + node.free(newsp) end - -- adjust next italic correction kern - elseif nxtid == kernnode and nxtsubtype == kern_type_itlc and d_getfield(nxt,"kern") == 0 then - local ksl = get_font_table(fid).parameters.slant - if ksl and ksl > 0 then - d_setfield(nxt,"kern", myfontchar.italic or 0) + if newwd and oldwd ~= newwd then + d_setglue(nxt, newwd, newwd/2, newwd/3) end end + -- adjust next italic correction kern + elseif nxtid == kernnode and nxtsubtype == kern_type_itlc and d_getfield(nxt,"kern") == 0 then + local ksl = get_font_table(fid).parameters.slant + if ksl and ksl > 0 then + d_setfield(nxt,"kern", myfontchar.italic or 0) + end end - break end end - if not myfontchar then - nanumtype1font(curr) - end end end end @@ -1824,9 +1789,22 @@ local function uline_boundary (num, list) end luatexko.uline_boundary = uline_boundary +local skippable = { + [gluenode ] = true, + [penaltynode] = true, + [kernnode ] = true, + [whatsitnode] = true, +} local function draw_underline(head,curr,glueset,gluesign,glueorder,ubox,start) - if not start then - start = d_getid(head) == gluenode and d_getsubtype(head) < 100 and d_getnext(head) or head + start = start or head + while start do + if not skippable[d_getid(start)] then break end + start = d_getnext(start) + end + while curr do + local p = d_getprev(curr) + if not skippable[d_getid(p)] then break end + curr = p end local width = d_nodedimensions(glueset,gluesign,glueorder,start,curr) if width and width > 0 then @@ -2085,7 +2063,7 @@ local function cjk_vertical_font (vf) --- vertical gpos local res = vf.resources or {} if res.verticalgposhack then - return vf -- avoid multiple running + return -- avoid multiple running end local fea = shared.features or {} fea.kern = nil -- only for horizontal typesetting @@ -2120,7 +2098,6 @@ local function cjk_vertical_font (vf) end end res.verticalgposhack = true - return vf end local otffeatures = fonts.constructors.newfeatures("otf") @@ -2159,11 +2136,6 @@ otffeatures.register { -- italic correction for fake-slant font ------------------------------------ local function fakeslant_itlc (tfmdata) - --[[ should be removed - if tfmdata.format == "unknown" then - tfmdata.name = tfmdata.name:gsub("^\"(.-)\"$","%1") - end - --]] local slfactor = tfmdata.parameters.slantfactor if slfactor and slfactor > 0 then else return end tfmdata.parameters.slant = slfactor * 65536 diff --git a/Master/texmf-dist/tex/luatex/luatexko/luatexko.sty b/Master/texmf-dist/tex/luatex/luatexko/luatexko.sty index d6a3a0dbe8f..0b95e19cd62 100644 --- a/Master/texmf-dist/tex/luatex/luatexko/luatexko.sty +++ b/Master/texmf-dist/tex/luatex/luatexko/luatexko.sty @@ -1,6 +1,6 @@ % luatexko.sty % -% Copyright (c) 2013-2016 Dohyun Kim <nomos at ktug org> +% Copyright (c) 2013-2017 Dohyun Kim <nomos at ktug org> % Soojin Nam <jsunam at gmail com> % % This work may be distributed and/or modified under the @@ -23,7 +23,7 @@ \expandafter\endinput \fi -\ProvidesPackage{luatexko}[2016/05/14 v1.15 Typesetting Korean with LuaLaTeX] +\ProvidesPackage{luatexko}[2017/02/06 v1.16 Typesetting Korean with LuaLaTeX] \ifdefined\adjustspacing\else % luatex < 0.87 \let\adjustspacing\pdfadjustspacing @@ -87,19 +87,9 @@ ] {Ligatures=TeX} %% macros for Korean fonts - \cs_new:Nn \__luako_pass_args:nnn + \DeclareDocumentCommand \setmainhangulfont { O{} m O{} } { - \IfNoValueTF {#2} - { \__luako_post_args:w {#1} {#3} } - { #1 {#2} {#3} } - } - \NewDocumentCommand \__luako_post_args:w { m m O{} } - { #1 {#3} {#2} } - \DeclareDocumentCommand \setmainhangulfont { o m } - { \__luako_pass_args:nnn \__luako_setmainhangulfont:nn {#1} {#2} } - \cs_new:Nn \__luako_setmainhangulfont:nn - { - \newfontfamily \serifhangul@font [#1] {#2} + \newfontfamily \serifhangul@font [#1,#3] {#2} \str_if_eq_x:nnT \familydefault \rmdefault { \cs_set_eq:NN \hangul@font \serifhangul@font @@ -107,11 +97,9 @@ } \ignorespaces } - \DeclareDocumentCommand \setmainhanjafont { o m } - { \__luako_pass_args:nnn \__luako_setmainhanjafont:nn {#1} {#2} } - \cs_new:Nn \__luako_setmainhanjafont:nn + \DeclareDocumentCommand \setmainhanjafont { O{} m O{} } { - \newfontfamily \serifhanja@font [#1] {#2} + \newfontfamily \serifhanja@font [#1,#3] {#2} \str_if_eq_x:nnT \familydefault \rmdefault { \cs_set_eq:NN \hanja@font \serifhanja@font @@ -119,11 +107,9 @@ } \ignorespaces } - \DeclareDocumentCommand \setmainfallbackfont { o m } - { \__luako_pass_args:nnn \__luako_setmainfallbackfont:nn {#1} {#2} } - \cs_new:Nn \__luako_setmainfallbackfont:nn + \DeclareDocumentCommand \setmainfallbackfont { O{} m O{} } { - \newfontfamily \seriffallback@font [#1] {#2} + \newfontfamily \seriffallback@font [#1,#3] {#2} \str_if_eq_x:nnT \familydefault \rmdefault { \cs_set_eq:NN \fallback@font \seriffallback@font @@ -131,11 +117,9 @@ } \ignorespaces } - \DeclareDocumentCommand \setsanshangulfont { o m } - { \__luako_pass_args:nnn \__luako_setsanshangulfont:nn {#1} {#2} } - \cs_new:Nn \__luako_setsanshangulfont:nn + \DeclareDocumentCommand \setsanshangulfont { O{} m O{} } { - \newfontfamily \sanshangul@font [#1] {#2} + \newfontfamily \sanshangul@font [#1,#3] {#2} \str_if_eq_x:nnT \familydefault \sfdefault { \cs_set_eq:NN \hangul@font \sanshangul@font @@ -143,11 +127,9 @@ } \ignorespaces } - \DeclareDocumentCommand \setsanshanjafont { o m } - { \__luako_pass_args:nnn \__luako_setsanshanjafont:nn {#1} {#2} } - \cs_new:Nn \__luako_setsanshanjafont:nn + \DeclareDocumentCommand \setsanshanjafont { O{} m O{} } { - \newfontfamily \sanshanja@font [#1] {#2} + \newfontfamily \sanshanja@font [#1,#3] {#2} \str_if_eq_x:nnT \familydefault \sfdefault { \cs_set_eq:NN \hanja@font \sanshanja@font @@ -155,11 +137,9 @@ } \ignorespaces } - \DeclareDocumentCommand \setsansfallbackfont { o m } - { \__luako_pass_args:nnn \__luako_setsansfallbackfont:nn {#1} {#2} } - \cs_new:Nn \__luako_setsansfallbackfont:nn + \DeclareDocumentCommand \setsansfallbackfont { O{} m O{} } { - \newfontfamily \sansfallback@font [#1] {#2} + \newfontfamily \sansfallback@font [#1,#3] {#2} \str_if_eq_x:nnT \familydefault \sfdefault { \cs_set_eq:NN \fallback@font \sansfallback@font @@ -167,11 +147,9 @@ } \ignorespaces } - \DeclareDocumentCommand \setmonohangulfont { o m } - { \__luako_pass_args:nnn \__luako_setmonohangulfont:nn {#1} {#2} } - \cs_new:Nn \__luako_setmonohangulfont:nn + \DeclareDocumentCommand \setmonohangulfont { O{} m O{} } { - \newfontfamily \monohangul@font [#1] {#2} + \newfontfamily \monohangul@font [#1,#3] {#2} \str_if_eq_x:nnT \familydefault \ttdefault { \cs_set_eq:NN \hangul@font \monohangul@font @@ -179,11 +157,9 @@ } \ignorespaces } - \DeclareDocumentCommand \setmonohanjafont { o m } - { \__luako_pass_args:nnn \__luako_setmonohanjafont:nn {#1} {#2} } - \cs_new:Nn \__luako_setmonohanjafont:nn + \DeclareDocumentCommand \setmonohanjafont { O{} m O{} } { - \newfontfamily \monohanja@font [#1] {#2} + \newfontfamily \monohanja@font [#1,#3] {#2} \str_if_eq_x:nnT \familydefault \ttdefault { \cs_set_eq:NN \hanja@font \monohanja@font @@ -191,11 +167,9 @@ } \ignorespaces } - \DeclareDocumentCommand \setmonofallbackfont { o m } - { \__luako_pass_args:nnn \__luako_setmonofallbackfont:nn {#1} {#2} } - \cs_new:Nn \__luako_setmonofallbackfont:nn + \DeclareDocumentCommand \setmonofallbackfont { O{} m O{} } { - \newfontfamily \monofallback@font [#1] {#2} + \newfontfamily \monofallback@font [#1,#3] {#2} \str_if_eq_x:nnT \familydefault \ttdefault { \cs_set_eq:NN \fallback@font \monofallback@font @@ -203,95 +177,77 @@ } \ignorespaces } - \DeclareDocumentCommand \newhangulfontfamily { m o m } - { \__luako_pass_args:nnn { \__luako_newhangulfontfamily:Nnn #1 } {#2} {#3} } - \cs_new:Nn \__luako_newhangulfontfamily:Nnn + \DeclareDocumentCommand \newhangulfontfamily { m O{} m O{} } { - \exp_args:Nc \newfontfamily { luatexkofont@ \token_to_str:N #1 } [#2] {#3} + \exp_args:Nc \newfontfamily { luatexkofont@ \token_to_str:N #1 } [#2,#4] {#3} \DeclareRobustCommand #1 { \cs_set_eq:Nc \hangul@font { luatexkofont@ \token_to_str:N #1 } \luatexko@hangul@selectfont } } - \DeclareDocumentCommand \newhanjafontfamily { m o m } - { \__luako_pass_args:nnn { \__luako_newhanjafontfamily:Nnn #1 } {#2} {#3} } - \cs_new:Nn \__luako_newhanjafontfamily:Nnn + \DeclareDocumentCommand \newhanjafontfamily { m O{} m O{} } { - \exp_args:Nc \newfontfamily { luatexkofont@ \token_to_str:N #1 } [#2] {#3} + \exp_args:Nc \newfontfamily { luatexkofont@ \token_to_str:N #1 } [#2,#4] {#3} \DeclareRobustCommand #1 { \cs_set_eq:Nc \hanja@font { luatexkofont@ \token_to_str:N #1 } \luatexko@hanja@selectfont } } - \DeclareDocumentCommand \newfallbackfontfamily { m o m } - { \__luako_pass_args:nnn { \__luako_newfallbackfontfamily:Nnn #1 } {#2} {#3} } - \cs_new:Nn \__luako_newfallbackfontfamily:Nnn + \DeclareDocumentCommand \newfallbackfontfamily { m O{} m O{} } { - \exp_args:Nc \newfontfamily { luatexkofont@ \token_to_str:N #1 } [#2] {#3} + \exp_args:Nc \newfontfamily { luatexkofont@ \token_to_str:N #1 } [#2,#4] {#3} \DeclareRobustCommand #1 { \cs_set_eq:Nc \fallback@font { luatexkofont@ \token_to_str:N #1 } \luatexko@fallback@selectfont } } - \DeclareDocumentCommand \newhangulfontface { m o m } - { \__luako_pass_args:nnn { \__luako_newhangulfontface:Nnn #1 } {#2} {#3} } - \cs_new:Nn \__luako_newhangulfontface:Nnn + \DeclareDocumentCommand \newhangulfontface { m O{} m O{} } { - \exp_args:Nc \newfontface { luatexkofont@ \token_to_str:N #1 } [#2] {#3} + \exp_args:Nc \newfontface { luatexkofont@ \token_to_str:N #1 } [#2,#4] {#3} \DeclareRobustCommand #1 { \cs_set_eq:Nc \hangul@font { luatexkofont@ \token_to_str:N #1 } \luatexko@hangul@selectfont } } - \DeclareDocumentCommand \newhanjafontface { m o m } - { \__luako_pass_args:nnn { \__luako_newhanjafontface:Nnn #1 } {#2} {#3} } - \cs_new:Nn \__luako_newhanjafontface:Nnn + \DeclareDocumentCommand \newhanjafontface { m O{} m O{} } { - \exp_args:Nc \newfontface { luatexkofont@ \token_to_str:N #1 } [#2] {#3} + \exp_args:Nc \newfontface { luatexkofont@ \token_to_str:N #1 } [#2,#4] {#3} \DeclareRobustCommand #1 { \cs_set_eq:Nc \hanja@font { luatexkofont@ \token_to_str:N #1 } \luatexko@hanja@selectfont } } - \DeclareDocumentCommand \newfallbackfontface { m o m } - { \__luako_pass_args:nnn { \__luako_newfallbackfontface:Nnn #1 } {#2} {#3} } - \cs_new:Nn \__luako_newfallbackfontface:Nnn + \DeclareDocumentCommand \newfallbackfontface { m O{} m O{} } { - \exp_args:Nc \newfontface { luatexkofont@ \token_to_str:N #1 } [#2] {#3} + \exp_args:Nc \newfontface { luatexkofont@ \token_to_str:N #1 } [#2,#4] {#3} \DeclareRobustCommand #1 { \cs_set_eq:Nc \fallback@font { luatexkofont@ \token_to_str:N #1 } \luatexko@fallback@selectfont } } - \DeclareDocumentCommand \hangulfontspec { o m } - { \__luako_pass_args:nnn \__luako_hangulfontspec:nn {#1} {#2} } - \cs_new:Nn \__luako_hangulfontspec:nn + \DeclareDocumentCommand \hangulfontspec { O{} m O{} } { - \newfontfamily \hangul@font [#1] {#2} + \newfontfamily \hangul@font [#1,#3] {#2} \luatexko@hangul@selectfont \ignorespaces } \cs_set_eq:NN \adhochangulfont \hangulfontspec - \DeclareDocumentCommand \hanjafontspec { o m } - { \__luako_pass_args:nnn \__luako_hanjafontspec:nn {#1} {#2} } - \cs_new:Nn \__luako_hanjafontspec:nn + \DeclareDocumentCommand \hanjafontspec { O{} m O{} } { - \newfontfamily \hanja@font [#1] {#2} + \newfontfamily \hanja@font [#1,#3] {#2} \luatexko@hanja@selectfont \ignorespaces } \cs_set_eq:NN \adhochanjafont \hanjafontspec - \DeclareDocumentCommand \fallbackfontspec { o m } - { \__luako_pass_args:nnn \__luako_fallbackfontspec:nn {#1} {#2} } - \cs_new:Nn \__luako_fallbackfontspec:nn + \DeclareDocumentCommand \fallbackfontspec { O{} m O{} } { - \newfontfamily \fallback@font [#1] {#2} + \newfontfamily \fallback@font [#1,#3] {#2} \luatexko@fallback@selectfont \ignorespaces } @@ -348,12 +304,63 @@ } \cs_set_eq:NN \addfallbackfontfeatures \addfallbackfontfeature % hangul math font command - \DeclareDocumentCommand \setmathhangulfont { o m } - { \__luako_pass_args:nnn \__luako_setmathhangulfont:nn {#1} {#2} } - \cs_new:Nn \__luako_setmathhangulfont:nn + \DeclareDocumentCommand \setmathhangulfont { O{} m O{} } { - \fontspec_set_family:Nnn \luatexko@math@hangul@family {#1} {#2} + \fontspec_set_family:Nnn \luatexko@math@hangul@family {#1,#3} {#2} } +% fontspec 2017 +\RenewDocumentCommand \setmainfont { O{} m O{} } + { + \fontspec_set_family:Nnn \g__fontspec_rmfamily_family {#1,#3} {#2} + \tl_set_eq:NN \rmdefault \g__fontspec_rmfamily_family + \use:x { \exp_not:n { \DeclareRobustCommand \rmfamily } + { + \exp_not:N \luatexko@serif@fonts + \exp_not:N \fontencoding { \l__fontspec_nfss_enc_tl } + \exp_not:N \fontfamily { \g__fontspec_rmfamily_family } + \exp_not:N \selectfont + } + } + \str_if_eq_x:nnT {\familydefault} {\rmdefault} + { \tl_set_eq:NN \encodingdefault \l__fontspec_nfss_enc_tl } + \normalfont + \ignorespaces + } +\RenewDocumentCommand \setsansfont { O{} m O{} } + { + \fontspec_set_family:Nnn \g__fontspec_sffamily_family {#1,#3} {#2} + \tl_set_eq:NN \sfdefault \g__fontspec_sffamily_family + \use:x { \exp_not:n { \DeclareRobustCommand \sffamily } + { + \exp_not:N \luatexko@sans@fonts + \exp_not:N \fontencoding { \l__fontspec_nfss_enc_tl } + \exp_not:N \fontfamily { \g__fontspec_sffamily_family } + \exp_not:N \selectfont + } + } + \str_if_eq_x:nnT {\familydefault} {\sfdefault} + { \tl_set_eq:NN \encodingdefault \l__fontspec_nfss_enc_tl } + \normalfont + \ignorespaces + } +\RenewDocumentCommand \setmonofont { O{} m O{} } + { + \fontspec_set_family:Nnn \g__fontspec_ttfamily_family {#1,#3} {#2} + \tl_set_eq:NN \ttdefault \g__fontspec_ttfamily_family + \use:x { \exp_not:n { \DeclareRobustCommand \ttfamily } + { + \exp_not:N \luatexko@mono@fonts + \exp_not:N \fontencoding { \l__fontspec_nfss_enc_tl } + \exp_not:N \fontfamily { \g__fontspec_ttfamily_family } + \exp_not:N \selectfont + } + } + \str_if_eq_x:nnT {\familydefault} {\ttdefault} + { \tl_set_eq:NN \encodingdefault \l__fontspec_nfss_enc_tl } + \normalfont + \ignorespaces + } +\cs_set_eq:NN \setromanfont \setmainfont \ExplSyntaxOff \fi |