summaryrefslogtreecommitdiff
path: root/tex/context/base/mkiv/char-tex.lua
diff options
context:
space:
mode:
Diffstat (limited to 'tex/context/base/mkiv/char-tex.lua')
-rw-r--r--tex/context/base/mkiv/char-tex.lua161
1 files changed, 84 insertions, 77 deletions
diff --git a/tex/context/base/mkiv/char-tex.lua b/tex/context/base/mkiv/char-tex.lua
index b361a9a07..1e86ca171 100644
--- a/tex/context/base/mkiv/char-tex.lua
+++ b/tex/context/base/mkiv/char-tex.lua
@@ -573,88 +573,68 @@ if not csletters then
local traditional = sfstate == "traditional"
for u, chr in next, data do -- will move up
- local fallback = chr.fallback
- if fallback then
- contextsprint("{\\catcode",u,"=13\\unexpanded\\gdef ",utfchar(u),"{\\checkedchar{",u,"}{",fallback,"}}}")
- activated[#activated+1] = u
- else
- local contextname = chr.contextname
- local category = chr.category
- local isletter = is_letter[category]
- if contextname then
- if is_character[category] then
- if chr.unicodeslot < 128 then
- if isletter then
- local c = utfchar(u)
- texsetmacro(contextname,c)
- csletters[c] = u
- else
- texsetchar(contextname,u)
- end
- else
- local c = utfchar(u)
- texsetmacro(contextname,c)
- if isletter and u >= 32 and u <= 65536 then
- csletters[c] = u
- end
- end
- --
+ local contextname = chr.contextname
+ local category = chr.category
+ local isletter = is_letter[category]
+ if contextname then
+ if is_character[category] then
+ if chr.unicodeslot < 128 then
if isletter then
- local lc = chr.lccode
- local uc = chr.uccode
- if not lc then
- chr.lccode = u
- lc = u
- elseif type(lc) == "table" then
- lc = u
- end
- if not uc then
- chr.uccode = u
- uc = u
- elseif type(uc) == "table" then
- uc = u
- end
- texsetlccode(u,lc,uc)
- if traditional and category == "lu" then
- texsetsfcode(code,999)
- end
+ local c = utfchar(u)
+ csletters[c] = u
end
- --
- elseif is_command[category] and not forbidden[u] then
- -- contextsprint("{\\catcode",u,"=13\\unexpanded\\gdef ",utfchar(u),"{\\",contextname,"}}")
- -- activated[#activated+1] = u
+ else
local c = utfchar(u)
- texsetmacro(contextname,c)
- elseif is_mark[category] then
- texsetlccode(u,u,u) -- for hyphenation
- end
- -- elseif isletter and u >= 32 and u <= 65536 then
- elseif isletter then
- csletters[utfchar(u)] = u
- --
- local lc, uc = chr.lccode, chr.uccode
- if not lc then
- chr.lccode = u
- lc = u
- elseif type(lc) == "table" then
- lc = u
- end
- if not uc then
- chr.uccode = u
- uc = u
- elseif type(uc) == "table" then
- uc = u
+ if isletter and u >= 32 and u <= 65536 then
+ csletters[c] = u
+ end
end
- texsetlccode(u,lc,uc)
- if traditional and category == "lu" then
- texsetsfcode(code,999)
+ if isletter then
+ local lc = chr.lccode
+ local uc = chr.uccode
+ if not lc then
+ chr.lccode = u
+ lc = u
+ elseif type(lc) == "table" then
+ lc = u
+ end
+ if not uc then
+ chr.uccode = u
+ uc = u
+ elseif type(uc) == "table" then
+ uc = u
+ end
+ texsetlccode(u,lc,uc)
+ if traditional and category == "lu" then
+ texsetsfcode(code,999)
+ end
end
- --
+ elseif is_command[category] and not forbidden[u] then
+ -- skip
elseif is_mark[category] then
- --
texsetlccode(u,u,u) -- for hyphenation
- --
end
+ elseif isletter then
+ csletters[utfchar(u)] = u
+ local lc, uc = chr.lccode, chr.uccode
+ if not lc then
+ chr.lccode = u
+ lc = u
+ elseif type(lc) == "table" then
+ lc = u
+ end
+ if not uc then
+ chr.uccode = u
+ uc = u
+ elseif type(uc) == "table" then
+ uc = u
+ end
+ texsetlccode(u,lc,uc)
+ if traditional and category == "lu" then
+ texsetsfcode(code,999)
+ end
+ elseif is_mark[category] then
+ texsetlccode(u,u,u) -- for hyphenation
end
end
@@ -690,6 +670,29 @@ if not csletters then
storage.register("characters/csletters", csletters, "characters.csletters")
end
+ function characters.setcharacternames(ctt)
+ for u, chr in next, data do -- will move up
+ local contextname = chr.contextname
+ local category = chr.category
+ local isletter = is_letter[category]
+ if contextname then
+ if is_character[category] then
+ if chr.unicodeslot < 128 then
+ if isletter then
+ texsetmacro(contextname,utfchar(u),"permanent")
+ else
+ texsetchar(contextname,u)
+ end
+ else
+ texsetmacro(contextname,utfchar(u),"permanent")
+ end
+ elseif is_command[category] and not forbidden[u] then
+ texsetmacro(contextname,utfchar(u),"permanent")
+ end
+ end
+ end
+ end
+
else
mark(csletters)
end
@@ -826,9 +829,13 @@ end
-- entities.gt = utfchar(characters.activeoffset + utfbyte(">"))
-- end
-implement { name = "setlettercatcodes", scope = "private", actions = characters.setlettercatcodes, arguments = "integer" }
-implement { name = "setactivecatcodes", scope = "private", actions = characters.setactivecatcodes, arguments = "integer" }
---------- { name = "setcharactercodes", scope = "private", actions = characters.setcodes }
+if characters.setcharacternames then -- only in ini mode
+
+ implement { name = "setlettercatcodes", scope = "private", actions = characters.setlettercatcodes, arguments = "integer" }
+ implement { name = "setactivecatcodes", scope = "private", actions = characters.setactivecatcodes, arguments = "integer" }
+ implement { name = "setcharacternames", scope = "private", actions = characters.setcharacternames, arguments = "integer" }
+
+end
-- experiment (some can move to char-ini.lua)