diff options
-rw-r--r-- | tex/context/base/char-cmp.lua | 3 | ||||
-rw-r--r-- | tex/context/base/char-enc.lua | 2 | ||||
-rw-r--r-- | tex/context/base/char-ini.lua | 303 | ||||
-rw-r--r-- | tex/context/base/char-map.lua | 2 | ||||
-rw-r--r-- | tex/context/base/char-tex.lua | 2 | ||||
-rw-r--r-- | tex/context/base/char-utf.lua | 78 | ||||
-rw-r--r-- | tex/context/base/cldf-ver.lua | 2 | ||||
-rw-r--r-- | tex/context/base/cont-new.tex | 2 | ||||
-rw-r--r-- | tex/context/base/context.tex | 2 | ||||
-rw-r--r-- | tex/context/base/font-map.lua | 103 | ||||
-rw-r--r-- | tex/context/base/font-otf.lua | 2 | ||||
-rw-r--r-- | tex/context/base/font-pat.lua | 6 | ||||
-rw-r--r-- | tex/context/base/font-tfm.lua | 27 | ||||
-rw-r--r-- | tex/context/base/java-fld.tex | 279 | ||||
-rw-r--r-- | tex/context/base/luat-dum.lua | 4 | ||||
-rw-r--r-- | tex/context/base/math-ini.lua | 4 | ||||
-rw-r--r-- | tex/context/base/math-vfu.lua | 60 | ||||
-rw-r--r-- | tex/generic/context/luatex-fonts-merged.lua | 138 |
18 files changed, 461 insertions, 558 deletions
diff --git a/tex/context/base/char-cmp.lua b/tex/context/base/char-cmp.lua index 2cd633370..d972788c9 100644 --- a/tex/context/base/char-cmp.lua +++ b/tex/context/base/char-cmp.lua @@ -6,7 +6,8 @@ if not modules then modules = { } end modules ['char-cmp'] = { license = "see context related readme files" } --- There is some overlap here with shcodes ... +-- There is some overlap here with shcodes ... this file is only used +-- for afm loading. local type = type local utfchar, utfbyte = utf.char, utf.byte diff --git a/tex/context/base/char-enc.lua b/tex/context/base/char-enc.lua index f4d049738..ef6805e54 100644 --- a/tex/context/base/char-enc.lua +++ b/tex/context/base/char-enc.lua @@ -6,7 +6,7 @@ if not modules then modules = { } end modules ['char-syn'] = { license = "see context related readme files" } --- thanks to tex4ht for these mappings +-- Thanks to tex4ht for these mappings. local allocate, setinitializer = utilities.storage.allocate, utilities.storage.setinitializer diff --git a/tex/context/base/char-ini.lua b/tex/context/base/char-ini.lua index 868e25b3f..ae496b4de 100644 --- a/tex/context/base/char-ini.lua +++ b/tex/context/base/char-ini.lua @@ -71,12 +71,35 @@ local pattern = (P("0x") + P("U+")) * ((R("09","AF")^1 * P(-1)) / function(s) re lpeg.patterns.chartonumber = pattern local function chartonumber(k) - return type(k) == "string" and (lpegmatch(pattern,k) or utfbyte(k)) or k + if type(k) == "string" then + local u = lpegmatch(pattern,k) + if u then + return utfbyte(u) + else + return utfbyte(k) or 0 + end + else + return k or 0 + end +end + +local function charfromnumber(k) + if type(k) == "number" then + return utfchar(k) or "" + else + local u = lpegmatch(pattern,k) + if u then + return utfchar(u) + else + return k + end + end end --~ print(chartonumber(97), chartonumber("a"), chartonumber("0x61"), chartonumber("U+61")) -characters.tonumber = chartonumber +characters.tonumber = chartonumber +characters.fromnumber = charfromnumber local private = { description = "PRIVATE SLOT", @@ -284,9 +307,11 @@ characters.blocks = allocate { ["yisyllables"] = { 0x0A000, 0x0A48F, "Yi Syllables" }, } -function characters.getrange(name) - local tag = lower(name) - tag = gsub(name,"[^a-z]", "") +setmetatable(characters.blocks, { __index = function(t,k) + return rawget(t,lower(gsub(k,"[^a-zA-Z]",""))) +end } ) + +function characters.getrange(name) -- used in font fallback definitions (name or range) local range = characters.blocks[tag] if range then return range[1], range[2], range[3] @@ -438,168 +463,89 @@ end function tex.uprint(c,n) if n then + -- texsprint(c,charfromnumber(n)) texsprint(c,utfchar(n)) else + -- texsprint(charfromnumber(c)) texsprint(utfchar(c)) end end -if texsetcatcode then - - -- todo -- define per table and then also register name (for tracing) +function characters.define(tobelettered, tobeactivated) -- catcodetables - function characters.define(tobelettered, tobeactivated) -- catcodetables - - if trace_defining then - report_defining("defining active character commands") - end + if trace_defining then + report_defining("defining active character commands") + end - local activated, a = { }, 0 + local activated, a = { }, 0 - for u, chr in next, data do -- these will be commands - local fallback = chr.fallback - if fallback then - texsprint("{\\catcode",u,"=13\\unexpanded\\gdef ",utfchar(u),"{\\checkedchar{",u,"}{",fallback,"}}}") -- no texprint - a = a + 1 - activated[a] = u - else - local contextname = chr.contextname - if contextname then - local category = chr.category - if is_character[category] then - if chr.unicodeslot < 128 then - texprint(ctxcatcodes,format("\\chardef\\%s=%s",contextname,u)) - else - texprint(ctxcatcodes,format("\\let\\%s=%s",contextname,utfchar(u))) - end - elseif is_command[category] then - texsprint("{\\catcode",u,"=13\\unexpanded\\gdef ",utfchar(u),"{\\"..contextname,"}}") -- no texprint - a = a + 1 - activated[a] = u + for u, chr in next, data do -- these will be commands + local fallback = chr.fallback + if fallback then + texsprint("{\\catcode",u,"=13\\unexpanded\\gdef ",utfchar(u),"{\\checkedchar{",u,"}{",fallback,"}}}") -- no texprint + a = a + 1 + activated[a] = u + else + local contextname = chr.contextname + if contextname then + local category = chr.category + if is_character[category] then + if chr.unicodeslot < 128 then + texprint(ctxcatcodes,format("\\chardef\\%s=%s",contextname,u)) + else + texprint(ctxcatcodes,format("\\let\\%s=%s",contextname,utfchar(u))) end + elseif is_command[category] then + texsprint("{\\catcode",u,"=13\\unexpanded\\gdef ",utfchar(u),"{\\"..contextname,"}}") -- no texprint + a = a + 1 + activated[a] = u end end end + end - if tobelettered then -- shared - local saved = tex.catcodetable - for i=1,#tobelettered do - tex.catcodetable = tobelettered[i] - if trace_defining then - report_defining("defining letters (global, shared)") - end - for u, chr in next, data do - if not chr.fallback and is_letter[chr.category] and u >= 128 and u <= 65536 then - texsetcatcode(u,11) - end - local range = chr.range - if range then - for i=1,range.first,range.last do - texsetcatcode(i,11) - end - end - end - texsetcatcode(0x200C,11) -- non-joiner - texsetcatcode(0x200D,11) -- joiner - end - tex.catcodetable = saved - end - - local nofactivated = #tobeactivated - if tobeactivated and nofactivated > 0 then - for i=1,nofactivated do - local u = activated[i] - report_defining("character 0x%05X is active in sets %s (%s)",u,concat(tobeactivated,","),data[u].description) + if tobelettered then -- shared + local saved = tex.catcodetable + for i=1,#tobelettered do + tex.catcodetable = tobelettered[i] + if trace_defining then + report_defining("defining letters (global, shared)") end - local saved = tex.catcodetable - for i=1,#tobeactivated do - local vector = tobeactivated[i] - if trace_defining then - report_defining("defining %s active characters in vector %s",nofactivated,vector) + for u, chr in next, data do + if not chr.fallback and is_letter[chr.category] and u >= 128 and u <= 65536 then + texsetcatcode(u,11) end - tex.catcodetable = vector - for i=1,nofactivated do - texsetcatcode(activated[i],13) + local range = chr.range + if range then + for i=1,range.first,range.last do + texsetcatcode(i,11) + end end end - tex.catcodetable = saved - end - + texsetcatcode(0x200C,11) -- non-joiner + texsetcatcode(0x200D,11) -- joiner + end + tex.catcodetable = saved end -else -- char-obs - - local template_a = "\\startextendcatcodetable{%s}\\chardef\\l=11\\chardef\\a=13\\let\\c\\catcode%s\\let\\a\\undefined\\let\\l\\undefined\\let\\c\\undefined\\stopextendcatcodetable" - local template_b = "\\chardef\\l=11\\chardef\\a=13\\let\\c\\catcode%s\\let\\a\\undefined\\let\\l\\undefined\\let\\c\\undefined" - - function characters.define(tobelettered, tobeactivated) -- catcodetables - local lettered, activated, l, a = { }, { }, 0, 0 - for u, chr in next, data do - -- we can use a macro instead of direct settings - local fallback = chr.fallback - if fallback then - -- texprint(format("{\\catcode %s=13\\unexpanded\\gdef %s{\\checkedchar{%s}{%s}}}",u,utfchar(u),u,fallback)) - texsprint("{\\catcode",u,"=13\\unexpanded\\gdef ",utfchar(u),"{\\checkedchar{",u,"}{",fallback,"}}}") -- no texprint - a = a + 1 - activated[a] = "\\c"..u.."\\a" - else - local contextname = chr.contextname - local category = chr.category - if contextname then - if is_character[category] then - -- by this time, we're still in normal catcode mode - -- subtle: not "\\",contextname but "\\"..contextname - if chr.unicodeslot < 128 then - texprint(ctxcatcodes,format("\\chardef\\%s=%s",contextname,u)) - else - texprint(ctxcatcodes,format("\\let\\%s=%s",contextname,utfchar(u))) - if is_letter[category] then - l = l + 1 - lettered[l] = "\\c"..u.."\\l" - end - end - elseif is_command[category] then - -- this might change: contextcommand ipv contextname - -- texprint(format("{\\catcode %s=13\\unexpanded\\gdef %s{\\%s}}",u,utfchar(u),contextname)) - texsprint("{\\catcode",u,"=13\\unexpanded\\gdef ",utfchar(u),"{\\"..contextname,"}}") -- no texprint - a = a + 1 - activated[a] = "\\c"..u.."\\a" - end - elseif is_letter[category] then - if u >= 128 and u <= 65536 then -- catch private mess - l = l + 1 - lettered[l] = "\\c"..u.."\\l" - end - end - end - local range = chr.range - if range then - l = l + 1 - lettered[l] = format('\\dofastrecurse{"%05X}{"%05X}{1}{\\c\\fastrecursecounter\\l}',range.first,range.last) - end + local nofactivated = #tobeactivated + if tobeactivated and nofactivated > 0 then + for i=1,nofactivated do + local u = activated[i] + report_defining("character 0x%05X is active in sets %s (%s)",u,concat(tobeactivated,","),data[u].description) end - -- if false then - l = l + 1 - lettered[l] = "\\c"..0x200C.."\\l" -- non-joiner - l = l + 1 - lettered[l] = "\\c"..0x200D.."\\l" -- joiner - -- fi - if tobelettered then - lettered = concat(lettered) - if true then - texsprint(ctxcatcodes,format(template_b,lettered)) -- global - else - for l=1,#tobelettered do - texsprint(ctxcatcodes,format(template_a,tobelettered[l],lettered)) - end + local saved = tex.catcodetable + for i=1,#tobeactivated do + local vector = tobeactivated[i] + if trace_defining then + report_defining("defining %s active characters in vector %s",nofactivated,vector) end - end - if tobeactivated then - activated = concat(activated) - for a=1,#tobeactivated do - texsprint(ctxcatcodes,format(template_a,tobeactivated[a],activated)) + tex.catcodetable = vector + for i=1,nofactivated do + texsetcatcode(activated[i],13) end end + tex.catcodetable = saved end end @@ -620,58 +566,31 @@ end --~ tex.sfcode --~ tex.catcode -if texsetcatcode then - - function characters.setcodes() - if trace_defining then - report_defining("defining lc and uc codes") - end - for code, chr in next, data do - local cc = chr.category - if cc == 'll' or cc == 'lu' or cc == 'lt' then - local lc, uc = chr.lccode, chr.uccode - if not lc then chr.lccode, lc = code, code end - if not uc then chr.uccode, uc = code, code end - texsetcatcode(code,11) -- letter - texsetlccode(code,lc,uc) - if cc == "lu" then - texsetsfcode(code,999) - end - elseif cc == "lo" then - local range = chr.range - if range then - for i=range.first,range.last do - texsetcatcode(i,11) -- letter - texsetlccode(i,i,i) -- self self - end - end - end - end +function characters.setcodes() + if trace_defining then + report_defining("defining lc and uc codes") end - -else -- char-obs - - function characters.setcodes() - for code, chr in next, data do - local cc = chr.category - if cc == 'll' or cc == 'lu' or cc == 'lt' then - local lc, uc = chr.lccode, chr.uccode - if not lc then chr.lccode, lc = code, code end - if not uc then chr.uccode, uc = code, code end - texsprint(ctxcatcodes,format("\\setcclcuc{%i}{%i}{%i}",code,lc,uc)) - end + for code, chr in next, data do + local cc = chr.category + if cc == 'll' or cc == 'lu' or cc == 'lt' then + local lc, uc = chr.lccode, chr.uccode + if not lc then chr.lccode, lc = code, code end + if not uc then chr.uccode, uc = code, code end + texsetcatcode(code,11) -- letter + texsetlccode(code,lc,uc) if cc == "lu" then - texprint(ctxcatcodes,"\\sfcode ",code,"999 ") + texsetsfcode(code,999) end - if cc == "lo" then - local range = chr.range - if range then - texsprint(ctxcatcodes,format('\\dofastrecurse{"%05X}{"%05X}{1}{\\setcclcucself\\fastrecursecounter}',range.first,range.last)) + elseif cc == "lo" then + local range = chr.range + if range then + for i=range.first,range.last do + texsetcatcode(i,11) -- letter + texsetlccode(i,i,i) -- self self end end end end - end --[[ldx-- @@ -796,16 +715,16 @@ setmetatable(specialchars, { __index = function(t,u) local c = data[utfbyte(u)] local s = c and c.specials if s then - local t, tn = { }, 0 + local tt, ttn = { }, 0 for i=2,#s do local si = s[i] local c = data[si] if is_letter[c.category] then - tn = tn + 1 - t[tn] = utfchar(si) + ttn = ttn + 1 + tt[ttn] = utfchar(si) end end - c = concat(t) + c = concat(tt) t[u] = c return c else diff --git a/tex/context/base/char-map.lua b/tex/context/base/char-map.lua index 3f8cc3b3d..376ebf343 100644 --- a/tex/context/base/char-map.lua +++ b/tex/context/base/char-map.lua @@ -6,6 +6,8 @@ if not modules then modules = { } end modules ['char-map'] = { license = "see context related readme files" } +-- not yet used + characters = characters or { } characters.casemap={ diff --git a/tex/context/base/char-tex.lua b/tex/context/base/char-tex.lua index 538915dd3..b8ae0b53f 100644 --- a/tex/context/base/char-tex.lua +++ b/tex/context/base/char-tex.lua @@ -18,7 +18,7 @@ characters = characters or { } local characters = characters characters.tex = characters.tex or { } -local accent_map = allocate { +local accent_map = allocate { -- incomplete ['~'] = "̃" , -- ̃ Ẽ ['"'] = "̈" , -- ̈ Ë ["`"] = "̀" , -- ̀ È diff --git a/tex/context/base/char-utf.lua b/tex/context/base/char-utf.lua index 7384f98c3..87ed861ed 100644 --- a/tex/context/base/char-utf.lua +++ b/tex/context/base/char-utf.lua @@ -24,6 +24,8 @@ local concat, gmatch, gsub = table.concat, string.gmatch, string.gsub local utfcharacters, utfvalues = string.utfcharacters, string.utfvalues local allocate = utilities.storage.allocate +local charfromnumber = characters.fromnumber + -- todo: trackers characters = characters or { } @@ -84,11 +86,10 @@ end -- utffilters.addgrapheme(utfchar(318),'l','\string~') -- utffilters.addgrapheme('c','a','b') -function utffilters.addgrapheme(result,first,second) - local r, f, s = tonumber(result), tonumber(first), tonumber(second) - if r then result = utfchar(r) end - if f then first = utfchar(f) end - if s then second = utfchar(s) end +function utffilters.addgrapheme(result,first,second) -- can be U+ 0x string or utf or number + local result = charfromnumber(result) + local first = charfromnumber(first) + local second = charfromnumber(second) if not graphemes[first] then graphemes[first] = { [second] = result } else @@ -96,33 +97,6 @@ function utffilters.addgrapheme(result,first,second) end end ---~ function utffilters.collapse(str) -- old one ---~ if utffilters.collapsing and str and #str > 1 then ---~ if initialize then -- saves a call ---~ initialize() ---~ end ---~ local tokens, n, first, done = { }, 0, false, false ---~ for second in utfcharacters(str) do ---~ local cgf = graphemes[first] ---~ if cgf and cgf[second] then ---~ first, done = cgf[second], true ---~ elseif first then ---~ n + n + 1 ---~ tokens[n] = first ---~ first = second ---~ else ---~ first = second ---~ end ---~ end ---~ if done then ---~ n + n + 1 ---~ tokens[n] = first ---~ return concat(tokens) ---~ end ---~ end ---~ return str ---~ end - --[[ldx-- <p>In order to deal with 8-bit output, we need to find a way to go from <l n='utf'/> to 8-bit. This is handled in the @@ -278,27 +252,29 @@ end <p>Next we implement some commands that are used in the user interface.</p> --ldx]]-- -commands = commands or { } - ---~ function commands.uchar(first,second) ---~ context(utfchar(first*256+second)) ---~ end +-- commands = commands or { } +-- +-- function commands.uchar(first,second) +-- context(utfchar(first*256+second)) +-- end --[[ldx-- <p>A few helpers (used to be <t>luat-uni<t/>).</p> --ldx]]-- -function utf.split(str) - local t, n = { }, 0 - for snippet in utfcharacters(str) do - n = n + 1 - t[n+1] = snippet - end - return t -end - -function utf.each(str,fnc) - for snippet in utfcharacters(str) do - fnc(snippet) - end -end +-- obsolete: +-- +-- function utf.split(str) +-- local t, n = { }, 0 +-- for snippet in utfcharacters(str) do +-- n = n + 1 +-- t[n+1] = snippet +-- end +-- return t +-- end +-- +-- function utf.each(str,fnc) +-- for snippet in utfcharacters(str) do +-- fnc(snippet) +-- end +-- end diff --git a/tex/context/base/cldf-ver.lua b/tex/context/base/cldf-ver.lua index fbc7670e2..390ffa04e 100644 --- a/tex/context/base/cldf-ver.lua +++ b/tex/context/base/cldf-ver.lua @@ -33,7 +33,7 @@ local function s_tocontext(...) -- we need to catch {\} end local function b_tocontext(b) - string_tocontext(tostring(b)) + s_tocontext(tostring(b)) end table .tocontext = t_tocontext diff --git a/tex/context/base/cont-new.tex b/tex/context/base/cont-new.tex index 5dcd7d962..6903ee474 100644 --- a/tex/context/base/cont-new.tex +++ b/tex/context/base/cont-new.tex @@ -11,7 +11,7 @@ %C therefore copyrighted by \PRAGMA. See mreadme.pdf for %C details. -\newcontextversion{2010.11.01 21:16} +\newcontextversion{2010.11.03 09:12} %D This file is loaded at runtime, thereby providing an %D excellent place for hacks, patches, extensions and new diff --git a/tex/context/base/context.tex b/tex/context/base/context.tex index 6fdd1fe28..cec1133a4 100644 --- a/tex/context/base/context.tex +++ b/tex/context/base/context.tex @@ -20,7 +20,7 @@ %D your styles an modules. \edef\contextformat {\jobname} -\edef\contextversion{2010.11.01 21:16} +\edef\contextversion{2010.11.03 09:12} %D For those who want to use this: diff --git a/tex/context/base/font-map.lua b/tex/context/base/font-map.lua index 569f3df81..b20663273 100644 --- a/tex/context/base/font-map.lua +++ b/tex/context/base/font-map.lua @@ -272,106 +272,3 @@ fonts.map.addtounicode = function(data,filename) report_otf("enhance: %s tounicode entries added (%s ligatures)",nl+ns, ns) end end - --- the following is sort of obsolete --- --- fonts.map.data = fonts.map.data or { } --- fonts.map.encodings = fonts.map.encodings or { } --- fonts.map.loaded = fonts.map.loaded or { } --- fonts.map.line = fonts.map.line or { } --- --- function fonts.map.line.pdftex(e) --- if e.name and e.fontfile then --- local fullname = e.fullname or "" --- if e.slant and e.slant ~= 0 then --- if e.encoding then --- pdf.mapline(format('= %s %s "%g SlantFont" <%s <%s',e.name,fullname,e.slant,e.encoding,e.fontfile))) --- else --- pdf.mapline(format('= %s %s "%g SlantFont" <%s',e.name,fullname,e.slant,e.fontfile))) --- end --- elseif e.extend and e.extend ~= 1 and e.extend ~= 0 then --- if e.encoding then --- pdf.mapline(format('= %s %s "%g ExtendFont" <%s <%s',e.name,fullname,e.extend,e.encoding,e.fontfile))) --- else --- pdf.mapline(format('= %s %s "%g ExtendFont" <%s',e.name,fullname,e.extend,e.fontfile))) --- end --- else --- if e.encoding then --- pdf.mapline(format('= %s %s <%s <%s',e.name,fullname,e.encoding,e.fontfile))) --- else --- pdf.mapline(format('= %s %s <%s',e.name,fullname,e.fontfile))) --- end --- end --- else --- return nil --- end --- end --- --- function fonts.map.flush(backend) -- will also erase the accumulated data --- local flushline = fonts.map.line[backend or "pdftex"] or fonts.map.line.pdftex --- for _, e in next, fonts.map.data do --- flushline(e) --- end --- fonts.map.data = { } --- end --- --- fonts.map.line.dvips = fonts.map.line.pdftex --- fonts.map.line.dvipdfmx = function() end --- --- function fonts.map.convert_entries(filename) --- if not fonts.map.loaded[filename] then --- fonts.map.data, fonts.map.encodings = fonts.map.load_file(filename,fonts.map.data, fonts.map.encodings) --- fonts.map.loaded[filename] = true --- end --- end --- --- function fonts.map.load_file(filename, entries, encodings) --- entries = entries or { } --- encodings = encodings or { } --- local f = io.open(filename) --- if f then --- local data = f:read("*a") --- if data then --- for line in gmatch(data,"(.-)[\n\t]") do --- if find(line,"^[%#%%%s]") then --- -- print(line) --- else --- local extend, slant, name, fullname, fontfile, encoding --- line = gsub(line,'"(.+)"', function(s) --- extend = find(s,'"([^"]+) ExtendFont"') --- slant = find(s,'"([^"]+) SlantFont"') --- return "" --- end) --- if not name then --- -- name fullname encoding fontfile --- name, fullname, encoding, fontfile = match(line,"^(%S+)%s+(%S*)[%s<]+(%S*)[%s<]+(%S*)%s*$") --- end --- if not name then --- -- name fullname (flag) fontfile encoding --- name, fullname, fontfile, encoding = match(line,"^(%S+)%s+(%S*)[%d%s<]+(%S*)[%s<]+(%S*)%s*$") --- end --- if not name then --- -- name fontfile --- name, fontfile = match(line,"^(%S+)%s+[%d%s<]+(%S*)%s*$") --- end --- if name then --- if encoding == "" then encoding = nil end --- entries[name] = { --- name = name, -- handy --- fullname = fullname, --- encoding = encoding, --- fontfile = fontfile, --- slant = tonumber(slant), --- extend = tonumber(extend) --- } --- encodings[name] = encoding --- elseif line ~= "" then --- -- print(line) --- end --- end --- end --- end --- f:close() --- end --- return entries, encodings --- end diff --git a/tex/context/base/font-otf.lua b/tex/context/base/font-otf.lua index 7e068ae70..25bccfa29 100644 --- a/tex/context/base/font-otf.lua +++ b/tex/context/base/font-otf.lua @@ -43,7 +43,7 @@ local otf = fonts.otf local tfm = fonts.tfm local fontdata = fonts.ids -local chardata = characters.data +local chardata = characters and characters.data -- not used otf.features = otf.features or { } otf.features.list = otf.features.list or { } diff --git a/tex/context/base/font-pat.lua b/tex/context/base/font-pat.lua index 20e68489c..c43d283b1 100644 --- a/tex/context/base/font-pat.lua +++ b/tex/context/base/font-pat.lua @@ -78,12 +78,6 @@ local function patch(data,filename) end v.features = { { ---~ scripts = { ---~ { ---~ langs = { "ARA ", "FAR ", "URD ", "dflt" }, ---~ script = "arab", ---~ }, ---~ }, scripts = { arab = { "ARA " = true, "FAR " = true, "URD " = true, "dflt" = true } }, tag = "mkmk" } diff --git a/tex/context/base/font-tfm.lua b/tex/context/base/font-tfm.lua index 7a16b284f..e8b24270b 100644 --- a/tex/context/base/font-tfm.lua +++ b/tex/context/base/font-tfm.lua @@ -128,16 +128,31 @@ end to scale virtual characters.</p> --ldx]]-- +--~ function tfm.getvirtualid(tfmdata) +--~ -- since we don't know the id yet, we use 0 as signal +--~ local tf = tfmdata.fonts +--~ if not tf then +--~ tfmdata.type = "virtual" +--~ tfmdata.fonts = { { id = 0 } } +--~ return 1 +--~ else +--~ local ntf = #tf + 1 +--~ tf[ntf] = { id = 0 } +--~ return ntf +--~ end +--~ end + function tfm.getvirtualid(tfmdata) -- since we don't know the id yet, we use 0 as signal - if not tfmdata.fonts then + local tf = tfmdata.fonts + if not tf then + tf = { } tfmdata.type = "virtual" - tfmdata.fonts = { { id = 0 } } - return 1 - else - tfmdata.fonts[#tfmdata.fonts+1] = { id = 0 } - return #tfmdata.fonts + tfmdata.fonts = tf end + local ntf = #tf + 1 + tf[ntf] = { id = 0 } + return ntf end function tfm.checkvirtualid(tfmdata, id) diff --git a/tex/context/base/java-fld.tex b/tex/context/base/java-fld.tex index 3c24b7e02..93a90dc0a 100644 --- a/tex/context/base/java-fld.tex +++ b/tex/context/base/java-fld.tex @@ -229,54 +229,247 @@ function ForgetChanges () \startJSpreamble FieldStack used later -function Reset_Fields ( FieldSet ) - { var i = 1 ; - while (true) - { v = this.getField(FieldSet+":"+i) ; - if (!v) - { break } - else - { v.value = "Off" } - i++ } } - -function Set_Fields ( FieldSet ) - { var i = 1 ; - while (true) - { v = this.getField(FieldSet+":"+i) ; - if (!v) - { break } - else - { v.value = "On" } - i++ } } - -function Set_Field ( FieldSet, FieldName ) - { Reset_Fields(FieldSet) ; +function Reset_Fields ( FieldSet ) { + var i = 1 ; + while (true) { + v = this.getField(FieldSet+":"+i) ; + if (!v) { + break ; + } else { + v.value = "Off" ; + } + i++ ; + } +} + +function Set_Fields ( FieldSet ) { + var i = 1 ; + while (true) { + v = this.getField(FieldSet+":"+i) ; + if (!v) { + break ; + } else { + v.value = "On" ; + } + i++ ; + } +} + +function Set_Field ( FieldSet, FieldName ) { + Reset_Fields(FieldSet) ; v = this.getField(FieldSet+":"+FieldName) ; - if (v) { v.value = "On" } } + if (v) { + v.value = "On" ; + } +} -function Reset_Field ( FieldSet, FieldName ) - { Set_Fields(FieldSet) ; +function Reset_Field ( FieldSet, FieldName ) { + Set_Fields(FieldSet) ; v = this.getField(FieldSet+":"+FieldName) ; - if (v) { v.value = "Off" } } - -function Walk_Field ( FieldSet ) - { var i = 1 ; - while (true) - { v = this.getField(FieldSet+":"+i) ; - if (v) - { if (v.value=="On") - { v.value = "Off" ; - var ii = i ; ii++ ; + if (v) { + v.value = "Off" ; + } +} + +function Walk_Field ( FieldSet ) { + var i = 1 ; + while (true) { + v = this.getField(FieldSet+":"+i) ; + if (v) { + if (v.value=="On") { + v.value = "Off" ; + var ii = i ; + ii++ ; v = this.getField(FieldSet+":"+ii) ; - if (!v) - { v = this.getField(FieldSet+":"+1) } - if (v) - { v.value = "On" } - break } - i++ } - else - { break } } } + if (!v) { + v = this.getField(FieldSet+":"+1) ; + } + if (v) { + v.value = "On" ; + } + break ; + } + i++ ; + } else { + break ; + } + } +} + +var FieldSets = new Array() ; + +function Do_Get_Check_Walk_Field ( FieldSet ) { + var f = FieldSets[FieldSet] + if (! f) { + f = new Array() ; + f.number = 0 ; + f.delay = 500 ; + f.paused = false ; + f.running = false ; + f.name = FieldSet ; + f.timeout = null ; + FieldSets[FieldSet] = f ; + } + return f +} + +function Do_Next_Auto_Walk_Field ( FieldSet ) { + var fieldset = Do_Get_Check_Walk_Field(FieldSet) ; + if (fieldset) { + var v = this.getField(FieldSet + ":" + fieldset.number) ; + if (v) { + if (v.value == "On") { + v.value = "Off" ; + } + } + fieldset.number++ ; + v = this.getField(FieldSet + ":" + fieldset.number) ; + if (! v) { + fieldset.number = 1 ; + v = this.getField(FieldSet + ":" + fieldset.number) ; + } + if (v) { + v.value = "On" + } + } +} + +function Do_Stop_Auto_Walk_Field ( FieldSet ) { + var fieldset = Do_Get_Check_Walk_Field(FieldSet) ; + if (fieldset) { + try { + app.clearInterval(fieldset.timeout) ; + app.clearTimeOut(fieldset.timeout) ; + } catch (e) { + } + } +} + +function Do_Start_Auto_Walk_Field ( FieldSet ) { + var fieldset = Do_Get_Check_Walk_Field(FieldSet) ; + if (fieldset) { + Do_Stop_Auto_Walk_Field(FieldSet) ; + fieldset.timeout = app.setInterval("Do_Next_Auto_Walk_Field('"+FieldSet+"')", fieldset.delay) ; + } +} + +function Start_Walk_Field ( FieldSet, Delay ) { + var fieldset = Do_Get_Check_Walk_Field(FieldSet) ; + if (fieldset) { + fieldset.number = 0 ; + if (Delay) { + fieldset.delay = Delay ; + } + Reset_Fields(FieldSet) ; + Do_Start_Auto_Walk_Field(FieldSet) ; + fieldset.running = true ; + fieldset.paused = false ; + } +} + +function Pause_Walk_Field ( FieldSet ) { + var fieldset = Do_Get_Check_Walk_Field(FieldSet) ; + if (fieldset) { + if (fieldset.running) { + if (fieldset.paused) { + Do_Start_Auto_Walk_Field(FieldSet) ; + fieldset.paused = false ; + } else { + Do_Stop_Auto_Walk_Field(FieldSet) ; + fieldset.paused = true ; + } + } + } +} + +function Stop_Walk_Field ( FieldSet ) { + var fieldset = Do_Get_Check_Walk_Field(FieldSet) ; + if (fieldset) { + Do_Stop_Auto_Walk_Field(FieldSet) ; + fieldset.running = false ; + fieldset.paused = false ; + } +} + +function Reset_Walk_Field ( FieldSet ) { + var fieldset = Do_Get_Check_Walk_Field(FieldSet) ; + if (fieldset) { + Do_Stop_Auto_Walk_Field(FieldSet) ; + fieldset.number = 0 ; + fieldset.running = false ; + fieldset.paused = false ; + Reset_Fields(FieldSet) ; + } +} + +function Previous_Walk_Field ( FieldSet ) { + var fieldset = Do_Get_Check_Walk_Field(FieldSet) ; + if (fieldset) { + Do_Stop_Auto_Walk_Field(FieldSet) ; + fieldset.running = false ; + fieldset.paused = false ; + if (fieldset.number>0) { + var v = this.getField(FieldSet + ":" + fieldset.number) ; + if (v) { + if (v.value == "On") { + v.value = "Off" ; + } + } + fieldset.number-- ; + v = this.getField(FieldSet + ":" + fieldset.number) ; + if (v) { + v.value = "On" ; + } + } + } +} + +function Next_Walk_Field ( FieldSet ) { + var fieldset = Do_Get_Check_Walk_Field(FieldSet) ; + if (fieldset) { + Do_Stop_Auto_Walk_Field(FieldSet) ; + fieldset.running = false ; + fieldset.paused = false ; + var f = fieldset.number + 1 ; + var v = this.getField(FieldSet + ":" + f) ; + if (v) { + var v = this.getField(FieldSet + ":" + fieldset.number) ; + if (v) { + if (v.value == "On") { + v.value = "Off" ; + } + } + fieldset.number++ ; + v = this.getField(FieldSet + ":" + fieldset.number) ; + if (v) { + v.value = "On" ; + } + } + } +} + +function Set_Walk_Field_Delay ( FieldSet, Delay ) { + var fieldset = Do_Get_Check_Walk_Field(FieldSet) ; + if (fieldset) { + if (Delay) { + fieldset.delay = Delay ; + if (fieldset.running) { + Do_Stop_Auto_Walk_Field(FieldSet) ; + Do_Start_Auto_Walk_Field(FieldSet) ; + } + } + } +} \stopJSpreamble +\definereference[Walk] [JS(Walk_Field)] +\definereference[StartWalk] [JS(Start_Walk_Field)] +\definereference[StopWalk] [JS(Stop_Walk_Field)] +\definereference[PauseWalk] [JS(Pause_Walk_Field)] +\definereference[ResetWalk] [JS(Reset_Walk_Field)] +\definereference[PreviousWalk][JS(Previous_Walk_Field)] +\definereference[NextWalk] [JS(Next_Walk_Field)] +\definereference[SetWalkDelay][JS(Set_Walk_Field_Delay)] + \endinput diff --git a/tex/context/base/luat-dum.lua b/tex/context/base/luat-dum.lua index bb3454fa3..d8d236df2 100644 --- a/tex/context/base/luat-dum.lua +++ b/tex/context/base/luat-dum.lua @@ -48,6 +48,10 @@ utilities = { }, } +characters = characters or { + data = { } +} + -- we need to cheat a bit here texconfig.kpse_init = true diff --git a/tex/context/base/math-ini.lua b/tex/context/base/math-ini.lua index ad4eea5f7..b4f7556c6 100644 --- a/tex/context/base/math-ini.lua +++ b/tex/context/base/math-ini.lua @@ -310,12 +310,12 @@ end function mathematics.utfmathcommand(chr, default) local cd = characters.data[utfbyte(chr)] local cmd = cd and cd.mathname - tex.sprint(cmd or default or "") + texsprint(cmd or default or "") end function mathematics.utfmathfiller(chr, default) local cd = characters.data[utfbyte(chr)] local cmd = cd and (cd.mathfiller or cd.mathname) - tex.sprint(cmd or default or "") + texsprint(cmd or default or "") end -- xml diff --git a/tex/context/base/math-vfu.lua b/tex/context/base/math-vfu.lua index e1a664ef9..e222c6002 100644 --- a/tex/context/base/math-vfu.lua +++ b/tex/context/base/math-vfu.lua @@ -455,12 +455,12 @@ function fonts.vf.math.define(specification,set) if mm and fp and mp then if ss.extension then mm.math_x_height = fp.x_height or 0 -- math_x_height height of x - mm.default_rule_thickness = fp[ 8] or 0 -- default_rule_thickness thickness of \over bars - mm.big_op_spacing1 = fp[ 9] or 0 -- big_op_spacing1 minimum clearance above a displayed op - mm.big_op_spacing2 = fp[10] or 0 -- big_op_spacing2 minimum clearance below a displayed op - mm.big_op_spacing3 = fp[11] or 0 -- big_op_spacing3 minimum baselineskip above displayed op - mm.big_op_spacing4 = fp[12] or 0 -- big_op_spacing4 minimum baselineskip below displayed op - mm.big_op_spacing5 = fp[13] or 0 -- big_op_spacing5 padding above and below displayed limits + mm.default_rule_thickness = fp[ 8] or 0 -- default_rule_thickness thickness of \over bars + mm.big_op_spacing1 = fp[ 9] or 0 -- big_op_spacing1 minimum clearance above a displayed op + mm.big_op_spacing2 = fp[10] or 0 -- big_op_spacing2 minimum clearance below a displayed op + mm.big_op_spacing3 = fp[11] or 0 -- big_op_spacing3 minimum baselineskip above displayed op + mm.big_op_spacing4 = fp[12] or 0 -- big_op_spacing4 minimum baselineskip below displayed op + mm.big_op_spacing5 = fp[13] or 0 -- big_op_spacing5 padding above and below displayed limits -- report_virtual("loading and virtualizing font %s at size %s, setting ex parameters",name,size) elseif ss.parameters then mp.x_height = fp.x_height or mp.x_height @@ -518,13 +518,17 @@ function fonts.vf.math.define(specification,set) si[index] = ref end local kerns = fci.kerns + local width = fci.width + local italic = fci.italic + if italic then + width = width + italic + end if kerns then - local width = fci.width local krn = { } - for k=1,#kerns do + for k, v in next, kerns do -- kerns is sparse local rk = rotcev[k] if rk then - krn[rk] = kerns[k] + krn[rk] = v -- kerns[k] end end if not next(krn) then @@ -534,7 +538,7 @@ function fonts.vf.math.define(specification,set) width = width, height = fci.height, depth = fci.depth, - italic = fci.italic, + italic = italic, kerns = krn, commands = ref, } @@ -547,10 +551,10 @@ function fonts.vf.math.define(specification,set) characters[unicode] = t else characters[unicode] = { - width = fci.width, + width = width, height = fci.height, depth = fci.depth, - italic = fci.italic, + italic = italic, commands = ref, } end @@ -612,31 +616,10 @@ function fonts.vf.math.define(specification,set) local cu = characters[unicode] if cu then cu.next = offset + index - --~ local n, c, d = unicode, cu, { } - --~ print("START", unicode) - --~ while n do - --~ n = c.next - --~ if n then - --~ print("NEXT", n) - --~ c = characters[n] - --~ if not c then - --~ print("EXIT") - --~ elseif d[n] then - --~ print("LOOP") - --~ break - --~ end - --~ d[n] = true - --~ end - --~ end else local fci = fc[index] if not fci then ---~ characters[unicode] = { ---~ width = 0, ---~ height = 0, ---~ depth = 0, ---~ index = 0, ---~ } + -- do nothing else local ref = si[index] if not ref then @@ -646,8 +629,11 @@ function fonts.vf.math.define(specification,set) local kerns = fci.kerns if kerns then local krn = { } - for k=1,#kerns do - krn[offset + k] = kerns[k] +--~ for k=1,#kerns do +--~ krn[offset + k] = kerns[k] +--~ end + for k, v in next, kerns do -- is kerns sparse? + krn[offset + k] = v end characters[unicode] = { width = fci.width, @@ -689,7 +675,7 @@ function fonts.vf.math.define(specification,set) mathematics.scaleparameters(main,main,1) main.nomath = false --~ print(table.serialize(characters[0x222B])) ---~ print(main.fontname,table.serialize(main.MathConstants)) +--~ table.print(main.MathConstants) return main end diff --git a/tex/generic/context/luatex-fonts-merged.lua b/tex/generic/context/luatex-fonts-merged.lua index a8ad77afd..6aa7e5aa0 100644 --- a/tex/generic/context/luatex-fonts-merged.lua +++ b/tex/generic/context/luatex-fonts-merged.lua @@ -1,6 +1,6 @@ -- merged file : luatex-fonts-merged.lua -- parent file : luatex-fonts.lua --- merge date : 11/01/10 21:16:51 +-- merge date : 11/03/10 09:12:20 do -- begin closure to overcome local limits and interference @@ -2380,6 +2380,10 @@ utilities = { }, } +characters = characters or { + data = { } +} + -- we need to cheat a bit here texconfig.kpse_init = true @@ -3512,16 +3516,31 @@ end to scale virtual characters.</p> --ldx]]-- +--~ function tfm.getvirtualid(tfmdata) +--~ -- since we don't know the id yet, we use 0 as signal +--~ local tf = tfmdata.fonts +--~ if not tf then +--~ tfmdata.type = "virtual" +--~ tfmdata.fonts = { { id = 0 } } +--~ return 1 +--~ else +--~ local ntf = #tf + 1 +--~ tf[ntf] = { id = 0 } +--~ return ntf +--~ end +--~ end + function tfm.getvirtualid(tfmdata) -- since we don't know the id yet, we use 0 as signal - if not tfmdata.fonts then + local tf = tfmdata.fonts + if not tf then + tf = { } tfmdata.type = "virtual" - tfmdata.fonts = { { id = 0 } } - return 1 - else - tfmdata.fonts[#tfmdata.fonts+1] = { id = 0 } - return #tfmdata.fonts + tfmdata.fonts = tf end + local ntf = #tf + 1 + tf[ntf] = { id = 0 } + return ntf end function tfm.checkvirtualid(tfmdata, id) @@ -5535,109 +5554,6 @@ fonts.map.addtounicode = function(data,filename) end end --- the following is sort of obsolete --- --- fonts.map.data = fonts.map.data or { } --- fonts.map.encodings = fonts.map.encodings or { } --- fonts.map.loaded = fonts.map.loaded or { } --- fonts.map.line = fonts.map.line or { } --- --- function fonts.map.line.pdftex(e) --- if e.name and e.fontfile then --- local fullname = e.fullname or "" --- if e.slant and e.slant ~= 0 then --- if e.encoding then --- pdf.mapline(format('= %s %s "%g SlantFont" <%s <%s',e.name,fullname,e.slant,e.encoding,e.fontfile))) --- else --- pdf.mapline(format('= %s %s "%g SlantFont" <%s',e.name,fullname,e.slant,e.fontfile))) --- end --- elseif e.extend and e.extend ~= 1 and e.extend ~= 0 then --- if e.encoding then --- pdf.mapline(format('= %s %s "%g ExtendFont" <%s <%s',e.name,fullname,e.extend,e.encoding,e.fontfile))) --- else --- pdf.mapline(format('= %s %s "%g ExtendFont" <%s',e.name,fullname,e.extend,e.fontfile))) --- end --- else --- if e.encoding then --- pdf.mapline(format('= %s %s <%s <%s',e.name,fullname,e.encoding,e.fontfile))) --- else --- pdf.mapline(format('= %s %s <%s',e.name,fullname,e.fontfile))) --- end --- end --- else --- return nil --- end --- end --- --- function fonts.map.flush(backend) -- will also erase the accumulated data --- local flushline = fonts.map.line[backend or "pdftex"] or fonts.map.line.pdftex --- for _, e in next, fonts.map.data do --- flushline(e) --- end --- fonts.map.data = { } --- end --- --- fonts.map.line.dvips = fonts.map.line.pdftex --- fonts.map.line.dvipdfmx = function() end --- --- function fonts.map.convert_entries(filename) --- if not fonts.map.loaded[filename] then --- fonts.map.data, fonts.map.encodings = fonts.map.load_file(filename,fonts.map.data, fonts.map.encodings) --- fonts.map.loaded[filename] = true --- end --- end --- --- function fonts.map.load_file(filename, entries, encodings) --- entries = entries or { } --- encodings = encodings or { } --- local f = io.open(filename) --- if f then --- local data = f:read("*a") --- if data then --- for line in gmatch(data,"(.-)[\n\t]") do --- if find(line,"^[%#%%%s]") then --- -- print(line) --- else --- local extend, slant, name, fullname, fontfile, encoding --- line = gsub(line,'"(.+)"', function(s) --- extend = find(s,'"([^"]+) ExtendFont"') --- slant = find(s,'"([^"]+) SlantFont"') --- return "" --- end) --- if not name then --- -- name fullname encoding fontfile --- name, fullname, encoding, fontfile = match(line,"^(%S+)%s+(%S*)[%s<]+(%S*)[%s<]+(%S*)%s*$") --- end --- if not name then --- -- name fullname (flag) fontfile encoding --- name, fullname, fontfile, encoding = match(line,"^(%S+)%s+(%S*)[%d%s<]+(%S*)[%s<]+(%S*)%s*$") --- end --- if not name then --- -- name fontfile --- name, fontfile = match(line,"^(%S+)%s+[%d%s<]+(%S*)%s*$") --- end --- if name then --- if encoding == "" then encoding = nil end --- entries[name] = { --- name = name, -- handy --- fullname = fullname, --- encoding = encoding, --- fontfile = fontfile, --- slant = tonumber(slant), --- extend = tonumber(extend) --- } --- encodings[name] = encoding --- elseif line ~= "" then --- -- print(line) --- end --- end --- end --- end --- f:close() --- end --- return entries, encodings --- end - end -- closure do -- begin closure to overcome local limits and interference @@ -5687,7 +5603,7 @@ local otf = fonts.otf local tfm = fonts.tfm local fontdata = fonts.ids -local chardata = characters.data +local chardata = characters and characters.data -- not used otf.features = otf.features or { } otf.features.list = otf.features.list or { } |