summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/luatex
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2016-04-26 22:05:58 +0000
committerKarl Berry <karl@freefriends.org>2016-04-26 22:05:58 +0000
commit60ba296e029b568481ab2ad00c7a003485ffbe4b (patch)
treeb1201a84a9c53a5090f80a74d6fc4f6fa0f1c69a /Master/texmf-dist/tex/luatex
parent4280e8cda1c6ec8813b64aceffb11e9d32567ca9 (diff)
luatexko (26apr16)
git-svn-id: svn://tug.org/texlive/trunk@40775 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/luatex')
-rw-r--r--Master/texmf-dist/tex/luatex/luatexko/luatexko-core.sty2
-rw-r--r--Master/texmf-dist/tex/luatex/luatexko/luatexko-normalize.lua4
-rw-r--r--Master/texmf-dist/tex/luatex/luatexko/luatexko-uhc2utf8.lua4
-rw-r--r--Master/texmf-dist/tex/luatex/luatexko/luatexko.lua183
-rw-r--r--Master/texmf-dist/tex/luatex/luatexko/luatexko.sty2
5 files changed, 139 insertions, 56 deletions
diff --git a/Master/texmf-dist/tex/luatex/luatexko/luatexko-core.sty b/Master/texmf-dist/tex/luatex/luatexko/luatexko-core.sty
index 12ba335eee1..e34a222ef35 100644
--- a/Master/texmf-dist/tex/luatex/luatexko/luatexko-core.sty
+++ b/Master/texmf-dist/tex/luatex/luatexko/luatexko-core.sty
@@ -17,7 +17,7 @@
\ifcsname ifpdf\endcsname\else \input ifpdf.sty \fi
\catcode`@ = 11
\else
- \ProvidesPackage{luatexko-core}[2016/04/22 v1.12 Typesetting Korean with LuaTeX]
+ \ProvidesPackage{luatexko-core}[2016/04/25 v1.13 Typesetting Korean with LuaTeX]
\RequirePackage{luaotfload}[2016/04/21]
\RequirePackage{ifpdf}
\fi
diff --git a/Master/texmf-dist/tex/luatex/luatexko/luatexko-normalize.lua b/Master/texmf-dist/tex/luatex/luatexko/luatexko-normalize.lua
index 6afb6d6738c..9ed25f4cb09 100644
--- a/Master/texmf-dist/tex/luatex/luatexko/luatexko-normalize.lua
+++ b/Master/texmf-dist/tex/luatex/luatexko/luatexko-normalize.lua
@@ -13,8 +13,8 @@
luatexbase.provides_module({
name = "luatexko-normalize",
- version = "1.12",
- date = "2016/04/22",
+ version = "1.13",
+ date = "2016/04/25",
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 bea568bd27a..721d647aa9a 100644
--- a/Master/texmf-dist/tex/luatex/luatexko/luatexko-uhc2utf8.lua
+++ b/Master/texmf-dist/tex/luatex/luatexko/luatexko-uhc2utf8.lua
@@ -13,8 +13,8 @@
luatexbase.provides_module({
name = "luatexko-uhc2utf8",
- version = "1.12",
- date = "2016/04/22",
+ version = "1.13",
+ date = "2016/04/25",
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 fa16225f023..a9ad5ab6229 100644
--- a/Master/texmf-dist/tex/luatex/luatexko/luatexko.lua
+++ b/Master/texmf-dist/tex/luatex/luatexko/luatexko.lua
@@ -13,8 +13,8 @@
luatexbase.provides_module {
name = 'luatexko',
- date = '2016/04/22',
- version = '1.12',
+ date = '2016/04/25',
+ version = '1.13',
description = 'Korean linebreaking and font-switching',
author = 'Dohyun Kim, Soojin Nam',
license = 'LPPL v1.3+',
@@ -1892,38 +1892,129 @@ end, 'luatexko.post_linebreak_filter')
------------------------------------
-- vertical typesetting: EXPERIMENTAL
------------------------------------
-local tsbtable, mytime, currtime, cachedir, fontloader, lfs, lfsattributes, lfstouch
-
-local function get_vwidth_tsb_table (filename,fontname)
- if tsbtable[fontname] then return tsbtable[fontname] end
- local cachefile = stringformat("%s/luatexko_vertical_metrics_%s.lua",
- cachedir,fontname:gsub("%W","_"))
- local cattr = lfs.isfile(cachefile) and lfsattributes(cachefile)
- local fonttime = lfsattributes(filename,"modification")
- if cattr and cattr.access > mytime and cattr.modification == fonttime then
- tsbtable[fontname] = dofile(cachefile)
- return tsbtable[fontname]
- end
- local fnt = fontloader.open(filename,fontname)
- if fnt then
- local fnt_t = fontloader.to_table(fnt) -- for tsidebearing
- fontloader.close(fnt)
- local glyph_t = {}
- local subfonts = fnt_t.subfonts or {fnt_t}
- for _,subfont in ipairs(subfonts) do
- local glyphs = subfont.glyphs or {}
- for i, gl in pairs(glyphs) do
- glyph_t[i] = { ht = gl.vwidth, tsb = gl.tsidebearing }
+local streamreader = utilities.files
+local openfile = streamreader.open
+local closefile = streamreader.close
+local readstring = streamreader.readstring
+local readulong = streamreader.readcardinal4
+local readushort = streamreader.readcardinal2
+local readfixed = streamreader.readfixed4
+local readshort = streamreader.readinteger2
+local setpos = streamreader.setposition
+
+local function getotftables (f, subfont)
+ if f then
+ local sfntversion = readstring(f,4)
+ if sfntversion == "ttcf" then
+ local ttcversion = readfixed(f)
+ local numfonts = readulong(f)
+ if subfont >= 1 and subfont <= numfonts then
+ local offsets = {}
+ for i = 1, numfonts do
+ offsets[i] = readulong(f)
+ end
+ setpos(f, offsets[subfont])
+ sfntversion = readstring(f,4)
end
end
- if lfstouch then
- table.tofile(cachefile,glyph_t,"return")
- if not lfstouch(cachefile,currtime,fonttime) then
- warn("Writing cache file '%s' failed!",cachefile)
+ if sfntversion == "OTTO" or sfntversion == "true" or sfntversion == "\0\1\0\0" then
+ local numtables = readushort(f)
+ local searchrange = readushort(f)
+ local entryselector = readushort(f)
+ local rangeshift = readushort(f)
+ local tables = {}
+ for i= 1, numtables do
+ local tag = readstring(f,4)
+ tables[tag] = {
+ checksum = readulong(f),
+ offset = readulong(f),
+ length = readulong(f),
+ }
end
+ return tables
+ end
+ end
+end
+
+local function readmaxp (f, t)
+ if f and t then
+ setpos(f, t.offset)
+ return {
+ version = readfixed(f),
+ numglyphs = readushort(f),
+ }
+ end
+end
+
+local function readvhea (f, t)
+ if f and t then
+ setpos(f, t.offset)
+ return {
+ version = readfixed(f),
+ ascent = readshort(f),
+ descent = readshort(f),
+ lineGap = readshort(f),
+ advanceheightmax = readshort(f),
+ mintopsidebearing = readshort(f),
+ minbottomsidebrearing = readshort(f),
+ ymaxextent = readshort(f),
+ caretsloperise = readshort(f),
+ caretsloperun = readshort(f),
+ caretoffset = readshort(f),
+ reserved1 = readshort(f),
+ reserved2 = readshort(f),
+ reserved3 = readshort(f),
+ reserved4 = readshort(f),
+ metricdataformat = readshort(f),
+ numheights = readushort(f),
+ }
+ end
+end
+
+local function readvmtx (f, t, numofheights, numofglyphs)
+ if f and t and numofheights and numofglyphs then
+ setpos(f, t.offset)
+ local vmtx = {}
+ local height = 0
+ for i = 0, numofheights-1 do
+ height = readushort(f)
+ vmtx[i] = {
+ ht = height,
+ tsb = readshort(f),
+ }
end
- tsbtable[fontname] = glyph_t
- return glyph_t
+ for i = numofheights, numofglyphs-1 do
+ vmtx[i] = {
+ ht = height,
+ tsb = readshort(f),
+ }
+ end
+ return vmtx
+ end
+end
+
+local tsbtable
+
+local function get_tsb_table (filename, subfont)
+ subfont = tonumber(subfont) or 1
+ local key = stringformat("%s::%s", filename, subfont)
+ if tsbtable[key] then
+ return tsbtable[key]
+ end
+ local f = openfile(filename, true) -- true: zero-based
+ if f then
+ local vmtx
+ local tables = getotftables(f, subfont)
+ if tables then
+ local vhea = readvhea(f, tables.vhea)
+ local numofheights = vhea and vhea.numheights
+ local maxp = readmaxp(f, tables.maxp)
+ local numofglyphs = maxp and maxp.numglyphs
+ vmtx = readvmtx(f, tables.vmtx, numofheights, numofglyphs)
+ end
+ closefile(f)
+ tsbtable[key] = vmtx
+ return vmtx
end
end
@@ -1933,8 +2024,12 @@ local function cjk_vertical_font (vf)
if not vf.shared.features["vertical"] then return end
if vf.type == "virtual" then return end
- local tsbtable = get_vwidth_tsb_table(vf.filename,vf.fontname)
- if not tsbtable then return end
+ local subfont = vf.specification and vf.specification.sub
+ local tsbtable = get_tsb_table(vf.filename, subfont)
+ if not tsbtable then
+ warn("%s does not have vertical metric info", vf.fontname)
+ return
+ end
local id = fontdefine(table.copy(vf)) -- fastcopy takes time too long.
@@ -2014,29 +2109,17 @@ local function cjk_vertical_font (vf)
return vf
end
-local function activate_vertical_virtual (tfmdata,value)
- if value and not tsbtable then
- fontloader = require "fontloader"
- lfs = require "lfs"
- lfstouch = lfs.touch
- lfsattributes = lfs.attributes
- tsbtable = {}
- currtime = os.time()
- mytime = kpse_find_file("luatexko.lua")
- mytime = mytime and lfsattributes(mytime,"modification")
- cachedir = caches.getwritablepath("..","luatexko")
- 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,
+ node = function (tfmdata,value)
+ if value and not tsbtable then
+ tsbtable = {}
+ add_to_callback("luaotfload.patch_font",cjk_vertical_font,"luatexko.vertical_virtual_font")
+ end
+ end
}
}
diff --git a/Master/texmf-dist/tex/luatex/luatexko/luatexko.sty b/Master/texmf-dist/tex/luatex/luatexko/luatexko.sty
index 4957ad3a99a..cdedc21db6d 100644
--- a/Master/texmf-dist/tex/luatex/luatexko/luatexko.sty
+++ b/Master/texmf-dist/tex/luatex/luatexko/luatexko.sty
@@ -23,7 +23,7 @@
\expandafter\endinput
\fi
-\ProvidesPackage{luatexko}[2016/04/22 v1.12 Typesetting Korean with LuaLaTeX]
+\ProvidesPackage{luatexko}[2016/04/25 v1.13 Typesetting Korean with LuaLaTeX]
\ifdefined\adjustspacing\else % luatex < 0.87
\let\adjustspacing\pdfadjustspacing