diff options
Diffstat (limited to 'tex/context')
110 files changed, 3678 insertions, 2718 deletions
diff --git a/tex/context/base/context-version.pdf b/tex/context/base/context-version.pdf Binary files differindex 99c955885..e00a93a64 100644 --- a/tex/context/base/context-version.pdf +++ b/tex/context/base/context-version.pdf diff --git a/tex/context/base/mkii/colo-xwi.mkii b/tex/context/base/mkii/colo-xwi.mkii index 13d04759e..48ffe234e 100644 --- a/tex/context/base/mkii/colo-xwi.mkii +++ b/tex/context/base/mkii/colo-xwi.mkii @@ -128,7 +128,7 @@ \definecolor [snow] [r=1.00,g=0.98,b=0.98] \definecolor [springgreen] [r=0.00,g=1.00,b=0.50] \definecolor [steelblue] [r=0.27,g=0.51,b=0.71] -\definecolor [tan ] [r=0.82,g=0.71,b=0.55] +\definecolor [tancolor] [r=0.82,g=0.71,b=0.55] % we don't want it to clash \definecolor [thistle] [r=0.85,g=0.75,b=0.85] \definecolor [tomato] [r=1.00,g=0.39,b=0.28] \definecolor [turquoise] [r=0.25,g=0.88,b=0.82] diff --git a/tex/context/base/mkii/mult-de.mkii b/tex/context/base/mkii/mult-de.mkii index b85a88918..e0099f4e7 100644 --- a/tex/context/base/mkii/mult-de.mkii +++ b/tex/context/base/mkii/mult-de.mkii @@ -1084,6 +1084,7 @@ \setinterfaceconstant{resources}{resources} \setinterfaceconstant{reverse}{reverse} \setinterfaceconstant{right}{rechts} +\setinterfaceconstant{rightchars}{rightchars} \setinterfaceconstant{rightcolor}{rechterfarbe} \setinterfaceconstant{rightcompoundhyphen}{rightcompoundhyphen} \setinterfaceconstant{rightedge}{rechtekante} diff --git a/tex/context/base/mkii/mult-en.mkii b/tex/context/base/mkii/mult-en.mkii index 969b9c475..116868cc9 100644 --- a/tex/context/base/mkii/mult-en.mkii +++ b/tex/context/base/mkii/mult-en.mkii @@ -1084,6 +1084,7 @@ \setinterfaceconstant{resources}{resources} \setinterfaceconstant{reverse}{reverse} \setinterfaceconstant{right}{right} +\setinterfaceconstant{rightchars}{rightchars} \setinterfaceconstant{rightcolor}{rightcolor} \setinterfaceconstant{rightcompoundhyphen}{rightcompoundhyphen} \setinterfaceconstant{rightedge}{rightedge} diff --git a/tex/context/base/mkii/mult-fr.mkii b/tex/context/base/mkii/mult-fr.mkii index fd848c789..44251d727 100644 --- a/tex/context/base/mkii/mult-fr.mkii +++ b/tex/context/base/mkii/mult-fr.mkii @@ -1084,6 +1084,7 @@ \setinterfaceconstant{resources}{resources} \setinterfaceconstant{reverse}{inverse} \setinterfaceconstant{right}{droite} +\setinterfaceconstant{rightchars}{rightchars} \setinterfaceconstant{rightcolor}{couleurdroite} \setinterfaceconstant{rightcompoundhyphen}{rightcompoundhyphen} \setinterfaceconstant{rightedge}{borddroit} diff --git a/tex/context/base/mkii/mult-it.mkii b/tex/context/base/mkii/mult-it.mkii index 7fa59db62..e6de935e6 100644 --- a/tex/context/base/mkii/mult-it.mkii +++ b/tex/context/base/mkii/mult-it.mkii @@ -1084,6 +1084,7 @@ \setinterfaceconstant{resources}{resources} \setinterfaceconstant{reverse}{invertito} \setinterfaceconstant{right}{destra} +\setinterfaceconstant{rightchars}{rightchars} \setinterfaceconstant{rightcolor}{coloredestra} \setinterfaceconstant{rightcompoundhyphen}{rightcompoundhyphen} \setinterfaceconstant{rightedge}{bordodestro} diff --git a/tex/context/base/mkii/mult-nl.mkii b/tex/context/base/mkii/mult-nl.mkii index 375bbe835..8c2063ea8 100644 --- a/tex/context/base/mkii/mult-nl.mkii +++ b/tex/context/base/mkii/mult-nl.mkii @@ -1084,6 +1084,7 @@ \setinterfaceconstant{resources}{resources} \setinterfaceconstant{reverse}{omgekeerd} \setinterfaceconstant{right}{rechts} +\setinterfaceconstant{rightchars}{rightchars} \setinterfaceconstant{rightcolor}{rechterkleur} \setinterfaceconstant{rightcompoundhyphen}{rechterkoppelteken} \setinterfaceconstant{rightedge}{rechterrand} diff --git a/tex/context/base/mkii/mult-pe.mkii b/tex/context/base/mkii/mult-pe.mkii index f889726a8..a058f9ad3 100644 --- a/tex/context/base/mkii/mult-pe.mkii +++ b/tex/context/base/mkii/mult-pe.mkii @@ -1084,6 +1084,7 @@ \setinterfaceconstant{resources}{resources} \setinterfaceconstant{reverse}{برعکس} \setinterfaceconstant{right}{راست} +\setinterfaceconstant{rightchars}{rightchars} \setinterfaceconstant{rightcolor}{رنگراست} \setinterfaceconstant{rightcompoundhyphen}{rightcompoundhyphen} \setinterfaceconstant{rightedge}{لبهراست} diff --git a/tex/context/base/mkii/mult-ro.mkii b/tex/context/base/mkii/mult-ro.mkii index d8d731a05..062230226 100644 --- a/tex/context/base/mkii/mult-ro.mkii +++ b/tex/context/base/mkii/mult-ro.mkii @@ -1084,6 +1084,7 @@ \setinterfaceconstant{resources}{resources} \setinterfaceconstant{reverse}{reverse} \setinterfaceconstant{right}{dreapta} +\setinterfaceconstant{rightchars}{rightchars} \setinterfaceconstant{rightcolor}{culoaredreapta} \setinterfaceconstant{rightcompoundhyphen}{rightcompoundhyphen} \setinterfaceconstant{rightedge}{borduradreapta} diff --git a/tex/context/base/mkiv/back-exp.lua b/tex/context/base/mkiv/back-exp.lua index 5390911bb..681996d48 100644 --- a/tex/context/base/mkiv/back-exp.lua +++ b/tex/context/base/mkiv/back-exp.lua @@ -116,13 +116,13 @@ local tonut = nuts.tonut local getnext = nuts.getnext local getsubtype = nuts.getsubtype local getfont = nuts.getfont -local getchar = nuts.getchar +local getdisc = nuts.getdisc local getlist = nuts.getlist local getid = nuts.getid local getfield = nuts.getfield local getattr = nuts.getattr - local setattr = nuts.setattr +local isglyph = nuts.isglyph local traverse_id = nuts.traverse_id local traverse_nodes = nuts.traverse @@ -2535,8 +2535,8 @@ end local function collectresults(head,list,pat,pap) -- is last used (we also have currentattribute) local p for n in traverse_nodes(head) do - local id = getid(n) -- 14: image, 8: literal (mp) - if id == glyph_code then + local c, id = isglyph(n) -- 14: image, 8: literal (mp) + if c then local at = getattr(n,a_tagged) or pat if not at then -- we need to tag the pagebody stuff as being valid skippable @@ -2545,7 +2545,6 @@ local function collectresults(head,list,pat,pap) -- is last used (we also have c else -- we could add tonunicodes for ligatures (todo) local components = getfield(n,"components") - local c = getchar(n) if components and (not characterdata[c] or overloads[c]) then -- we loose data collectresults(components,nil,at) -- this assumes that components have the same attribute as the glyph ... we should be more tolerant (see math) else @@ -2640,14 +2639,13 @@ local function collectresults(head,list,pat,pap) -- is last used (we also have c end end elseif id == disc_code then -- probably too late + local pre, post, replace = getdisc(n) if keephyphens then - local pre = getfield(n,"pre") - if pre and not getnext(pre) and getid(pre) == glyph_code and getchar(pre) == hyphencode then + if pre and not getnext(pre) and isglyph(pre) == hyphencode then nofcurrentcontent = nofcurrentcontent + 1 currentcontent[nofcurrentcontent] = hyphen end end - local replace = getfield(n,"replace") if replace then collectresults(replace,nil) end diff --git a/tex/context/base/mkiv/back-exp.mkiv b/tex/context/base/mkiv/back-exp.mkiv index 6a8177faf..48f4d3c48 100644 --- a/tex/context/base/mkiv/back-exp.mkiv +++ b/tex/context/base/mkiv/back-exp.mkiv @@ -89,14 +89,14 @@ \fi}% % brrr, we need to tag empty cells (unless we start numbering) \unexpanded\def\dotagTABLEsignal - {\char\zerocount}% + {\signalcharacter}% \to \everyenableelements \appendtoks \unexpanded\def\dotagtabulatecell {\iftrialtypesetting\else\clf_settagtabulatecell\c_tabl_tabulate_align\fi}% \unexpanded\def\dotagtabulatesignal - {\dontleavehmode\char\zerocount\ignorespaces}% + {\dontleavehmode\signalcharacter\ignorespaces}% \to \everyenableelements \appendtoks diff --git a/tex/context/base/mkiv/blob-ini.lua b/tex/context/base/mkiv/blob-ini.lua index b837250ce..106c10f4f 100644 --- a/tex/context/base/mkiv/blob-ini.lua +++ b/tex/context/base/mkiv/blob-ini.lua @@ -6,16 +6,10 @@ if not modules then modules = { } end modules ['blob-ini'] = { license = "see context related readme files" } --- Experimental ... names and functionality will change ... just a --- place to collect code, so: --- --- DON'T USE THESE FUNCTIONS AS THEY WILL CHANGE! --- --- This module is just a playground. Occasionally we need to typeset --- at the lua and and this is one method. In principle we can construct --- pages this way too which sometimes makes sense in dumb cases. Actually, --- if one only needs this, one does not really need tex, okay maybe the --- parbuilder but that one can be simplified as well then. +-- This module is just a playground. Occasionally we need to typeset at the lua and and +-- this is one method. In principle we can construct pages this way too which sometimes +-- makes sense in dumb cases. Actually, if one only needs this, one does not really need +-- tex, okay maybe the parbuilder but that one can be simplified as well then. -- set fonts, attributes -- rest already done in packers etc @@ -41,21 +35,18 @@ local write_node = node.write local typesetters = nodes.typesetters local tonodes = typesetters.tonodes local tohpack = typesetters.tohpack -local tohpackfast = typesetters.tohpackfast local tovpack = typesetters.tovpack -local tovpackfast = typesetters.tovpackfast local implement = interfaces.implement -blobs = blobs or { } - -- provide copies here (nicer for manuals) +blobs = blobs or { } +local blobs = blobs + blobs.tonodes = tonodes blobs.tohpack = tohpack -blobs.tohpackfast = tohpackfast blobs.tovpack = tovpack -blobs.tovpackfast = tovpackfast -- end of helpers @@ -146,21 +137,21 @@ end -- blob.paragraph -- blob.page ---~ local lineblob = { ---~ type = "line", ---~ head = false, ---~ tail = false, ---~ pack = false, ---~ properties = { }, ---~ end - ---~ local parblob = { ---~ type = "line", ---~ head = false, ---~ tail = false, ---~ pack = false, ---~ properties = { }, ---~ end +-- local lineblob = { +-- type = "line", +-- head = false, +-- tail = false, +-- pack = false, +-- properties = { }, +-- end + +-- local parblob = { +-- type = "line", +-- head = false, +-- tail = false, +-- pack = false, +-- properties = { }, +-- end -- for the moment here: diff --git a/tex/context/base/mkiv/colo-imp-crayola.mkiv b/tex/context/base/mkiv/colo-imp-crayola.mkiv new file mode 100644 index 000000000..dbae02d5a --- /dev/null +++ b/tex/context/base/mkiv/colo-imp-crayola.mkiv @@ -0,0 +1,254 @@ +%D \module +%D [ file=colo-imp-crayola +%D version=2016.03.21, +%D title=\CONTEXT\ Color Macros, +%D subtitle=Crayola, +%D author=Alan Braslau] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA, See mreadme.pdf for +%C details. + +%D Crayola (Binney & Smith) crayon colors. + +\startprotectedcolors + +\definecolor [Red] [h=ED0A3F] % produced 1903–present +\definecolor [Maroon] [h=C32148] % produced 1949–present, known as "dark red", 1949–1958. +\definecolor [Scarlet] [h=FD0E35] % produced 1998–present, known as "torch red", 1998. +\definecolor [BrickRed] [h=C62D42] % produced 1958–present +\definecolor [EnglishVermilion] [h=CC474B] % also spelled "vermillion", produced 1903–1935. +\definecolor [MadderLake] [h=CC3336] % produced 1903–1935 +\definecolor [PermanentGeraniumLake] [h=E12C2C] % produced 1903–circa 1910 +\definecolor [MaximumRed] [h=D92121] % part of the munsell line, 1926–1944 +\definecolor [IndianRed] [h=B94E48] % produced 1903–present, known as "chestnut" since 1999. +\definecolor [OrangeRed] [h=FF5349] % produced 1958–1990 +\definecolor [SunsetOrange] [h=FE4C40] % produced 1997–present +\definecolor [Bittersweet] [h=FE6F5E] % produced 1958–present +\definecolor [DarkVenetianRed] [h=B33B24] % "venetian red, dark" on labels, produced 1903–circa 1910. +\definecolor [VenetianRed] [h=CC553D] % produced 1903–1944 +\definecolor [LightVenetianRed] [h=E6735C] % "venetian red, light" on labels, produced 1903–circa 1910. +\definecolor [VividTangerine] [h=FF9980] % produced 1990–present +\definecolor [MiddleRed] [h=E58E73] % part of the munsell line, 1926–1944. +\definecolor [BurntOrange] [h=FF7F49] % produced 1958–present +\definecolor [RedOrange] [h=FF681F] % produced 1930–present +\definecolor [Orange] [h=FF8833] % produced 1903–present +\definecolor [MacaroniandCheese] [h=FFB97B] % produced 1993–present, also found as "macaroni & cheese" and "macaroni-n-cheese". +\definecolor [MiddleYellowRed] [h=ECB176] % part of the munsell line, 1926–1944, same color as "medium orange" (1949–1958). +\definecolor [MangoTango] [h=E77200] % produced 2003–present +\definecolor [YellowOrange] [h=FFAE42] % produced 1930–present +\definecolor [MaximumYellowRed] [h=F2BA49] % part of the munsell line, 1926–1944. +\definecolor [BananaMania] [h=FBE7B2] % produced 1998–present +\definecolor [Maize] [h=F2C649] % produced 1903–1990, known as "gold ochre", 1903–1958, "golden ochre" on some labels. +\definecolor [OrangeYellow] [h=F8D568] % produced 1958–1990. +\definecolor [Goldenrod] [h=FCD667] % produced 1903–present, known as "medium chrome yellow" (1903–?) and "medium yellow" (1903–1958). +\definecolor [Dandelion] [h=FED85D] % produced 1990–present +\definecolor [Yellow] [h=FBE870] % produced 1903–present +\definecolor [GreenYellow] [h=F1E788] % produced 1958–present +\definecolor [MiddleYellow] [h=FFEB00] % part of the munsell line, 1926–1944. +\definecolor [OliveGreen] [h=B5B35C] % produced 1903–present +\definecolor [SpringGreen] [h=ECEBBD] % produced 1958–present +\definecolor [MaximumYellow] [h=FAFA37] % part of the munsell line, 1926–1944. +\definecolor [Canary] [h=FFFF99] % produced 1998–present +\definecolor [LemonYellow] [h=FFFF9F] % produced 1903–1990, also known as "light chrome yellow" (on labels "chrome yellow, light") or "light yellow", 1903–1958, on labels "chrome yellow, light." +\definecolor [MaximumGreenYellow] [h=D9E650] % part of the munsell line, 1926–1944. +\definecolor [MiddleGreenYellow] [h=ACBF60] % part of the munsell line, 1926–1944. +\definecolor [Inchworm] [h=AFE313] % produced 1993–present +\definecolor [LightChromeGreen] [h=BEE64B] % "chrome green, light" on labels, produced 1903–1935, same color as "light green" (1903–1935). +\definecolor [YellowGreen] [h=C5E17A] % produced 1930–present +\definecolor [MaximumGreen] [h=5E8C31] % part of the munsell line, 1926–1944. +\definecolor [Asparagus] [h=7BA05B] % produced 1993–present +\definecolor [GrannySmithApple] [h=9DE093] % produced 1993–present +\definecolor [Fern] [h=63B76C] % produced 1998–present +\definecolor [MiddleGreen] [h=4D8C57] % part of the munsell line, 1926–1944. +\definecolor [Green] [h=3AA655] % produced 1903–present +\definecolor [MediumChromeGreen] [h=6CA67C] % "chrome green, medium" on labels, produced 1903–1939, same color as "medium green" (1903–1939). +\definecolor [ForestGreen] [h=5FA777] % produced 1949–present, known as "dark green", 1949–1958. +\definecolor [SeaGreen] [h=93DFB8] % produced 1949–present, known as "light green", 1949–1958. +\definecolor [Shamrock] [h=33CC99] % produced 1993–present +\definecolor [MountainMeadow] [h=1AB385] % produced 1998–present +\definecolor [JungleGreen] [h=29AB87] % produced 1990–present +\definecolor [CaribbeanGreen] [h=00CC99] % produced 1997–present +\definecolor [TropicalRainForest] [h=00755E] % produced 1993–present +\definecolor [MiddleBlueGreen] [h=8DD9CC] % part of the munsell line, 1926–1944. +\definecolor [PineGreen] [h=01786F] % produced 1903–1949, 1958–present, known as "dark chrome green" ("chrome green, dark" on labels) or "dark green", 1903–1949. +\definecolor [MaximumBlueGreen] [h=30BFBF] % part of the munsell line, 1926–1944. +\definecolor [RobinsEggBlue] [h=00CCCC] % produced 1993–present +\definecolor [TealBlue] [h=008080] % produced 1990–2003. +\definecolor [LightBlue] [h=8FD8D8] % produced only in 1958. +\definecolor [Aquamarine] [h=95E0E8] % produced 1949–present, known as "light turquoise blue", 1949–1958. +\definecolor [TurquoiseBlue] [h=6CDAE7] % produced 1935–present, available only in bulk, 1935–1949. +\definecolor [OuterSpace] [h=2D383A] % produced 1998–present +\definecolor [SkyBlue] [h=76D7EA] % produced 1958–present +\definecolor [MiddleBlue] [h=7ED4E6] % part of the munsell line, 1926–1944. +\definecolor [BlueGreen] [h=0095B7] % produced 1949–present, known as "middle blue-green", 1949–1958. +\definecolor [PacificBlue] [h=009DC4] % produced 1993–present +\definecolor [Cerulean] [h=02A4D3] % produced 1990–present +\definecolor [MaximumBlue] [h=47ABCC] % produced 1926–1958, part of the munsell line, 1926–1944, also known as "blue-green", 1930–1958. +\definecolor [BlueI] [h=4997D0] % produced 1903–1958, known as "celestial blue", 1935–1949, and "azure blue", 1949–1958. +\definecolor [CeruleanBlue] [h=339ACC] % produced 1949–1958. +\definecolor [Cornflower] [h=93CCEA] % produced 1958–present +\definecolor [GreenBlue] [h=2887C8] % produced 1958–1990. +\definecolor [MidnightBlue] [h=00468C] % produced 1903–present, known as "prussian blue", 1903–1958. +\definecolor [NavyBlue] [h=0066CC] % produced 1958–present +\definecolor [Denim] [h=1560BD] % produced 1993–present +\definecolor [BlueIII] [h=0066FF] % produced 1949–present +\definecolor [CadetBlue] [h=A9B2C3] % produced 1958–present +\definecolor [Periwinkle] [h=C3CDE6] % produced 1958–present +\definecolor [BlueII] [h=4570E6] % produced 1935–1958, known as "medium blue", 1949–1958. +\definecolor [WildBlueYonder] [h=7A89B8] % produced 2003–present +\definecolor [Indigo] [h=4F69C6] % produced 1999–present +\definecolor [Manatee] [h=8D90A1] % produced 1998–present +\definecolor [CobaltBlue] [h=8C90C8] % produced 1903–1958. +\definecolor [CelestialBlue] [h=7070CC] % produced 1903–circa 1910. +\definecolor [BlueBell] [h=9999CC] % produced 1998–present +\definecolor [MaximumBluePurple] [h=ACACE6] % part of the munsell line, 1926–1944. +\definecolor [VioletBlue] [h=766EC8] % produced 1930–1990, known as blue-violet, 1930–1958. +\definecolor [BlueViolet] [h=6456B7] % produced 1949–present, known as "violet" 1949–1958. +\definecolor [UltramarineBlue] [h=3F26BF] % produced 1903–1944. +\definecolor [MiddleBluePurple] [h=8B72BE] % part of the munsell line, 1926–1944. +\definecolor [PurpleHeart] [h=652DC1] % produced 1998–present +\definecolor [RoyalPurple] [h=6B3FA0] % produced 1990–present +\definecolor [VioletII] [h=8359A3] % produced 1930–1949, 1958–present, on labels "violet (purple)". +\definecolor [MediumViolet] [h=8F47B3] % produced 1949–1958. +\definecolor [Wisteria] [h=C9A0DC] % produced 1993–present +\definecolor [LavenderI] [h=BF8FCC] % produced 1949–1958. +\definecolor [VividViolet] [h=803790] % produced 1997–present +\definecolor [MaximumPurple] [h=733380] % part of the munsell line, 1926–1944. +\definecolor [PurpleMountainsMajesty] [h=D6AEDD] % produced 1993–present, also found as "purple mountain majesty" and "purple mountain's majesty." +\definecolor [Fuchsia] [h=C154C1] % produced 1990–present +\definecolor [PinkFlamingo] [h=FC74FD] % produced 1997–present +\definecolor [VioletI] [h=732E6C] % produced 1903–1930, also known as "purple" (1903–circa 1914). +\definecolor [BrilliantRose] [h=E667CE] % produced 1949–1958. +\definecolor [Orchid] [h=E29CD2] % produced 1949–present, known as "medium red-violet", 1949–1958. +\definecolor [Plum] [h=8E3179] % produced 1958–present +\definecolor [MediumRose] [h=D96CBE] % produced 1949–1958. +\definecolor [Thistle] [h=EBB0D7] % produced 1949–1999, known as "light magenta", 1949–1958. +\definecolor [Mulberry] [h=C8509B] % produced 1958–2003. +\definecolor [RedViolet] [h=BB3385] % produced 1930–present +\definecolor [MiddlePurple] [h=D982B5] % part of the munsell line, 1926–1944. +\definecolor [MaximumRedPurple] [h=A63A79] % part of the munsell line, 1926–1944. +\definecolor [JazzberryJam] [h=A50B5E] % produced 2003–present +\definecolor [Eggplant] [h=614051] % produced 1998–present +\definecolor [Magenta] [h=F653A6] % produced 1903–present, same color as "permanent magenta" (1903–?). +\definecolor [Cerise] [h=DA3287] % produced 1993–present +\definecolor [WildStrawberry] [h=FF3399] % produced 1990–present +\definecolor [LavenderII] [h=FBAED2] % produced 1958–present +\definecolor [CottonCandy] [h=FFB7D5] % produced 1998–present +\definecolor [CarnationPink] [h=FFA6C9] % produced 1903–present, known as "rose pink" (1903–1958) and "pink" (1903–1917). +\definecolor [VioletRed] [h=F7468A] % produced 1958–present +\definecolor [Razzmatazz] [h=E30B5C] % produced 1993–present +\definecolor [PigPink] [h=FDD7E4] % produced 1998–present, also called "piggy pink." +\definecolor [Carmine] [h=E62E6B] % produced 1935–1958, known as "carmine red", 1949–1958. +\definecolor [Blush] [h=DB5079] % produced 1998–present, known as "cranberry", 1998–2005. +\definecolor [TickleMePink] [h=FC80A5] % produced 1993–present +\definecolor [Mauvelous] [h=F091A9] % produced 1993–present +\definecolor [Salmon] [h=FF91A4] % produced 1949–present +\definecolor [MiddleRedPurple] [h=A55353] % part of the munsell line, 1926–1944. +\definecolor [Mahogany] [h=CA3435] % produced 1949–present +\definecolor [Melon] [h=FEBAAD] % produced 1958–present +\definecolor [PinkSherbert] [h=F7A38E] % produced 1998–present, known as "brink pink", 1998–2005. +\definecolor [BurntSienna] [h=E97451] % produced 1903–present +\definecolor [Brown] [h=AF593E] % produced 1935–present +\definecolor [Sepia] [h=9E5B40] % produced 1935–1944, 1958–present, available only in bulk, 1935–1939. +\definecolor [FuzzyWuzzy] [h=87421F] % produced 1998–present, known as "fuzzy wuzzy brown", 1998–2005. +\definecolor [Beaver] [h=926F5B] % produced 1998–present +\definecolor [Tumbleweed] [h=DEA681] % produced 1993–present +\definecolor [RawSienna] [h=D27D46] % produced 1958–present +\definecolor [VanDykeBrown] [h=664228] % produced 1903–1935, same color as "brown" (1903–1935) +\definecolor [Tan] [h=D99A6C] % produced 1958–present +\definecolor [DesertSand] [h=EDC9AF] % produced 1998–present +\definecolor [Peach] [h=FFCBA4] % produced 1903–present, known as "flesh tint" (1903–1949), "flesh" (1949–1956, 1958–1962), and "pink beige" (1956–1958) +\definecolor [BurntUmber] [h=805533] % produced 1903–1944 +\definecolor [Apricot] [h=FDD5B1] % produced 1958–present +\definecolor [Almond] [h=EED9C4] % produced 1998–present +\definecolor [RawUmber] [h=665233] % produced 1903–1990 +\definecolor [Shadow] [h=837050] % produced 1998–present +\definecolor [RawSiennaI] [h=E6BC5C] % produced 1903–circa 1910 +\definecolor [Timberwolf] [h=D9D6CF] % produced 1993–present +\definecolor [GoldI] [h=92926E] % metallic, swatch represents nominal hue only, produced 1903–1944, available only in bulk after 1915 +\definecolor [GoldII] [h=E6BE8A] % metallic, swatch represents nominal hue only, produced 1953–present, available only in bulk, 1953–1956 +\definecolor [Silver] [h=C9C0BB] % metallic, swatch represents nominal hue only, produced 1903–present, available only in bulk, 1915–1944 +\definecolor [Copper] [h=DA8A67] % metallic, swatch represents nominal hue only, produced 1903–1915, 1958–present +\definecolor [AntiqueBrass] [h=C88A65] % metallic, swatch represents nominal hue only, produced 1998–present +\definecolor [Black] [h=000000] % produced 1903–present +\definecolor [CharcoalGray] [h=736A62] % produced 1903–1910 +\definecolor [Gray] [h=8B8680] % as "middle grey", part of the munsell line, 1926–1944, spelled "grey" on labels, but "gray" on boxes, also called "neutral grey", 1930–1956 +\definecolor [BlueGray] [h=C8C8CD] % produced 1958–1990 +\definecolor [White] [h=FFFFFF] % produced 1903–present +\definecolor [RadicalRed] [h=FF355E] % introduced in 1990 +\definecolor [WildWatermelon] [h=FD5B78] % same color as "ultra red" (1972–1990) +\definecolor [OutrageousOrange] [h=FF6037] % same color as "ultra orange" (1972–1990) +\definecolor [AtomicTangerine] [h=FF9966] % same color as "ultra yellow" (1972–1990) +\definecolor [NeonCarrot] [h=FF9933] % introduced in 1990 +\definecolor [Sunglow] [h=FFCC33] % introduced in 1990 +\definecolor [LaserLemon] [h=FFFF66] % same color as "chartreuse" (1972–1990) +\definecolor [UnmellowYellow] [h=FFFF66] % introduced in 1990 +\definecolor [ElectricLime] [h=CCFF00] % introduced in 1990 +\definecolor [ScreaminGreen] [h=66FF66] % same color as "ultra green" (1972–1990) +\definecolor [MagicMint] [h=AAF0D1] % produced 1990–2003 +\definecolor [BlizzardBlue] [h=50BFE6] % same color as "ultra blue" (1972–1990), discontinued in 2003 +\definecolor [ShockingPink] [h=FF6EFF] % same color as "ultra pink" (1972–1990) +\definecolor [RazzleDazzleRose] [h=EE34D2] % same color as "hot magenta" (1972–1990) +\definecolor [HotMagenta] [h=FF00CC] % introduced in 1990 +\definecolor [PurplePizzazz] [h=FF00CC] % introduced in 1990 +\definecolor [AztecGold] [h=C39953] +\definecolor [BurnishedBrown] [h=A17A74] +\definecolor [CeruleanFrost] [h=6D9BC3] +\definecolor [CinnamonSatin] [h=CD607E] +\definecolor [CopperPenny] [h=AD6F69] +\definecolor [CosmicCobalt] [h=2E2D88] +\definecolor [GlossyGrape] [h=AB92B3] +\definecolor [GraniteGray] [h=676767] +\definecolor [GreenSheen] [h=6EAEA1] +\definecolor [LilacLuster] [h=AE98AA] +\definecolor [MistyMoss] [h=BBB477] +\definecolor [MysticMaroon] [h=AD4379] +\definecolor [PearlyPurple] [h=B768A2] +\definecolor [PewterBlue] [h=8BA8B7] +\definecolor [PolishedPine] [h=5DA493] +\definecolor [QuickSilver] [h=A6A6A6] +\definecolor [RoseDust] [h=9E5E6F] +\definecolor [RustyRed] [h=DA2C43] +\definecolor [ShadowBlue] [h=778BA5] +\definecolor [ShinyShamrock] [h=5FA778] +\definecolor [SteelTeal] [h=5F8A8B] +\definecolor [SugarPlum] [h=914E75] +\definecolor [TwilightLavender] [h=8A496B] +\definecolor [WintergreenDream] [h=56887D] +\definecolor [Amethyst] [h=64609A] +\definecolor [Citrine] [h=933709] +\definecolor [Emerald] [h=14A989] +\definecolor [Jade] [h=469A84] +\definecolor [Jasper] [h=D05340] +\definecolor [LapisLazuli] [h=436CB9] +\definecolor [Malachite] [h=469496] +\definecolor [Moonstone] [h=3AA8C1] +\definecolor [Onyx] [h=353839] +\definecolor [Peridot] [h=ABAD48] +\definecolor [PinkPearl] [h=B07080] +\definecolor [RoseQuartz] [h=BD559C] +\definecolor [Ruby] [h=AA4069] +\definecolor [Sapphire] [h=2D5DA1] +\definecolor [SmokeyTopaz] [h=832A0D] +\definecolor [TigersEye] [h=B56917] +\definecolor [AquaPearl] [h=5FBED7] +\definecolor [BlackCoralPearl] [h=54626F] +\definecolor [CaribbeanGreenPearl] [h=6ADA8E] +\definecolor [CulturedPearl] [h=F5F5F5] +\definecolor [KeyLimePearl] [h=E8F48C] +\definecolor [MandarinPearl] [h=F37A48] +\definecolor [MidnightPearl] [h=702670] +\definecolor [MysticPearl] [h=D65282] +\definecolor [OceanBluePearl] [h=4F42B5] +\definecolor [OceanGreenPearl] [h=48BF91] +\definecolor [OrchidPearl] [h=7B4259] +\definecolor [RosePearl] [h=F03865] +\definecolor [SalmonPearl] [h=F1444A] +\definecolor [SunnyPearl] [h=F2F27A] +\definecolor [SunsetPearl] [h=F1CC79] +\definecolor [TurquoisePearl] [h=3BBCD0] + +\stopprotectedcolors + +\endinput diff --git a/tex/context/base/mkiv/colo-imp-dem.mkiv b/tex/context/base/mkiv/colo-imp-dem.mkiv index 5b794c551..7744a216e 100644 --- a/tex/context/base/mkiv/colo-imp-dem.mkiv +++ b/tex/context/base/mkiv/colo-imp-dem.mkiv @@ -11,8 +11,9 @@ %C therefore copyrighted by \PRAGMA. See mreadme.pdf for %C details. -%D Like colors, we first define the english colorgroups. These -%D colorgroups are tuned for distinctive gray scale printing. +%D Like colors, we first define the english colorgroups. These colorgroups are +%D tuned for distinctive gray scale printing. The yellow range is not really +%D all yellow but is at least visible. \definecolorgroup [gray] @@ -200,6 +201,20 @@ \definecolorgroup [giallo*] [yellow*] \stopinterface +\startinterface french + \definecolorgroup [gris] [gray] + \definecolorgroup [rouge] [red] + \definecolorgroup [vert] [green] + \definecolorgroup [bleu] [blue] + \definecolorgroup [cyan] [cyan] + \definecolorgroup [magenta] [magenta] + \definecolorgroup [jaune] [yellow] + \definecolorgroup [rouge*] [red*] + \definecolorgroup [vert*] [green*] + \definecolorgroup [bleu*] [blue*] + \definecolorgroup [jaune*] [yellow*] +\stopinterface + %D The next set of color palets is quite language independant. %D These palets are meant as examples. diff --git a/tex/context/base/mkiv/colo-imp-ema.mkiv b/tex/context/base/mkiv/colo-imp-ema.mkiv index 11d76f342..ff1db60fb 100644 --- a/tex/context/base/mkiv/colo-imp-ema.mkiv +++ b/tex/context/base/mkiv/colo-imp-ema.mkiv @@ -8,7 +8,7 @@ %D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] %C %C This module is part of the \CONTEXT\ macro||package and is -%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for %C details. % author : Peter Rolf <peter.rolf@arcor.de> @@ -17,28 +17,30 @@ % % USAGE: % -% - select emacs menu: Edit -> Text Properties -> Display +% - select emacs menu: Edit -> Text Properties -> Display % Colors, if you don't know what I'm talking about -% - copy this file to your /texmf/tex/context/user directory +% - copy this file to your /texmf/tex/context/user directory % and add "\input colo-emacs" to your tex-file % % IMPORTANT NOTES: % -% - all color names are written as ONE word in lowercase -% letters (no redundancy as in rgb.txt) so if you want to -% use the color "Light Sky Blue"/"light sky blue" it's new +% - all color names are written as ONE word in lowercase +% letters (no redundancy as in rgb.txt) so if you want to +% use the color "Light Sky Blue"/"light sky blue" it's new % name is lightskyblue % - the grayX values [X=0..100] can only be used with \color % [grayX] % - use it at your own risk :) % % HINT: -% -% I only include this file (\showcolor [ema]) until I've -% found the colors I want. Copy and paste the color -% definitions to a seperate file, to decrease compilation -% time (540 color definitions). - +% +% I only include this file (\showcolor [ema]) until I've +% found the colors I want. Copy and paste the color +% definitions to a seperate file, to decrease compilation +% time (540 color definitions). + +\startprotectedcolors + \definecolor [snow] [r=1,g=.980392,b=.980392] \definecolor [ghostwhite] [r=.972549,g=.972549,b=1] \definecolor [whitesmoke] [s=.960784] @@ -481,110 +483,18 @@ \definecolor [thistle2] [r=.933333,g=.823529,b=.933333] \definecolor [thistle3] [r=.803922,g=.709804,b=.803922] \definecolor [thistle4] [r=.545098,g=.482353,b=.545098] -\definecolor [gray0] [black] -\definecolor [gray1] [s=.01] -\definecolor [gray2] [s=.02] -\definecolor [gray3] [s=.03] -\definecolor [gray4] [s=.04] -\definecolor [gray5] [s=.05] -\definecolor [gray6] [s=.06] -\definecolor [gray7] [s=.07] -\definecolor [gray8] [s=.08] -\definecolor [gray9] [s=.09] -\definecolor [gray10] [s=.1] -\definecolor [gray11] [s=.11] -\definecolor [gray12] [s=.12] -\definecolor [gray13] [s=.13] -\definecolor [gray14] [s=.14] -\definecolor [gray15] [s=.15] -\definecolor [gray16] [s=.16] -\definecolor [gray17] [s=.17] -\definecolor [gray18] [s=.18] -\definecolor [gray19] [s=.19] -\definecolor [gray20] [s=.2] -\definecolor [gray21] [s=.21] -\definecolor [gray22] [s=.22] -\definecolor [gray23] [s=.23] -\definecolor [gray24] [s=.24] -\definecolor [gray25] [s=.25] -\definecolor [gray26] [s=.26] -\definecolor [gray27] [s=.27] -\definecolor [gray28] [s=.28] -\definecolor [gray29] [s=.29] -\definecolor [gray30] [s=.3] -\definecolor [gray31] [s=.31] -\definecolor [gray32] [s=.32] -\definecolor [gray33] [s=.33] -\definecolor [gray34] [s=.34] -\definecolor [gray35] [s=.35] -\definecolor [gray36] [s=.36] -\definecolor [gray37] [s=.37] -\definecolor [gray38] [s=.38] -\definecolor [gray39] [s=.39] -\definecolor [gray40] [s=.4] -\definecolor [gray41] [s=.41] -\definecolor [gray42] [s=.42] -\definecolor [gray43] [s=.43] -\definecolor [gray44] [s=.44] -\definecolor [gray45] [s=.45] -\definecolor [gray46] [s=.46] -\definecolor [gray47] [s=.47] -\definecolor [gray48] [s=.48] -\definecolor [gray49] [s=.49] -\definecolor [gray50] [s=.5] -\definecolor [gray51] [s=.51] -\definecolor [gray52] [s=.52] -\definecolor [gray53] [s=.53] -\definecolor [gray54] [s=.54] -\definecolor [gray55] [s=.55] -\definecolor [gray56] [s=.56] -\definecolor [gray57] [s=.57] -\definecolor [gray58] [s=.58] -\definecolor [gray59] [s=.59] -\definecolor [gray60] [s=.6] -\definecolor [gray61] [s=.61] -\definecolor [gray62] [s=.62] -\definecolor [gray63] [s=.63] -\definecolor [gray64] [s=.64] -\definecolor [gray65] [s=.65] -\definecolor [gray66] [s=.66] -\definecolor [gray67] [s=.67] -\definecolor [gray68] [s=.68] -\definecolor [gray69] [s=.69] -\definecolor [gray70] [s=.7] -\definecolor [gray71] [s=.71] -\definecolor [gray72] [s=.72] -\definecolor [gray73] [s=.73] -\definecolor [gray74] [s=.74] -\definecolor [gray75] [s=.75] -\definecolor [gray76] [s=.76] -\definecolor [gray77] [s=.77] -\definecolor [gray78] [s=.78] -\definecolor [gray79] [s=.79] -\definecolor [gray80] [s=.8] -\definecolor [gray81] [s=.81] -\definecolor [gray82] [s=.82] -\definecolor [gray83] [s=.83] -\definecolor [gray84] [s=.84] -\definecolor [gray85] [s=.85] -\definecolor [gray86] [s=.86] -\definecolor [gray87] [s=.87] -\definecolor [gray88] [s=.88] -\definecolor [gray89] [s=.89] -\definecolor [gray90] [s=.9] -\definecolor [gray91] [s=.91] -\definecolor [gray92] [s=.92] -\definecolor [gray93] [s=.93] -\definecolor [gray94] [s=.94] -\definecolor [gray95] [s=.95] -\definecolor [gray96] [s=.96] -\definecolor [gray97] [s=.97] -\definecolor [gray98] [s=.98] -\definecolor [gray99] [s=.99] -\definecolor [gray100] [white] + +\dorecurse{100}{ + \definecolor [gray#1] [s=\cldcontext{#1/100}] +} + \definecolor [darkgray] [s=.662745] \definecolor [darkblue] [b=.545098] \definecolor [darkcyan] [g=.545098,b=.545098] \definecolor [darkmagenta] [r=.545098,b=.545098] \definecolor [darkred] [r=.545098] \definecolor [lightgreen] [r=.564706,g=.933333,b=.564706] + +\stopprotectedcolors + +\endinput diff --git a/tex/context/base/mkiv/colo-imp-rgb.mkiv b/tex/context/base/mkiv/colo-imp-rgb.mkiv index d7b691fcc..58b2ca42c 100644 --- a/tex/context/base/mkiv/colo-imp-rgb.mkiv +++ b/tex/context/base/mkiv/colo-imp-rgb.mkiv @@ -38,6 +38,9 @@ \definecolor [lightred] [r=1, g=0, b=0] \definecolor [lightgreen] [r=0, g=1, b=0] \definecolor [lightblue] [r=0, g=0, b=1] +\definecolor [lightcyan] [r=0, g=1, b=1] +\definecolor [lightmagenta] [r=1, g=0, b=1] +\definecolor [lightyellow] [r=1, g=1, b=0] \definecolor [middlered] [r=.8, g=0, b=0] \definecolor [middlegreen] [r=0, g=.8, b=0] @@ -87,12 +90,15 @@ \definecolor [donkercyaan] [darkcyan] \definecolor [middelcyaan] [middlecyan] + \definecolor [lichtcyaan] [lightcyan] \definecolor [donkermagenta] [darkmagenta] \definecolor [middelmagenta] [middlemagenta] + \definecolor [lichtmagenta] [lightmagenta] \definecolor [donkergeel] [darkyellow] \definecolor [middelgeel] [middleyellow] + \definecolor [lichtgeel] [lightyellow] \definecolor [donkergrijs] [darkgray] \definecolor [middengrijs] [middlegray] @@ -128,12 +134,15 @@ \definecolor [dunkelcyan] [darkcyan] \definecolor [mittelcyan] [middlecyan] + \definecolor [hellcyan] [lightcyan] \definecolor [dunkelmagenta] [darkmagenta] \definecolor [mittelmagenta] [middlemagenta] + \definecolor [hellmagenta] [lightmagenta] \definecolor [dunkelgelb] [darkyellow] \definecolor [mittelgelb] [middleyellow] + \definecolor [hellgelb] [lightyellow] \definecolor [dunkelgrau] [darkgray] \definecolor [mittelgrau] [middlegray] @@ -168,12 +177,15 @@ \definecolor [tmaveazurova] [darkcyan] \definecolor [stredneazurova] [middlecyan] + \definecolor [svelteazurova] [lightcyan] \definecolor [tmavefialova] [darkmagenta] \definecolor [strednefialova] [middlemagenta] + \definecolor [sveltefialova] [lightmagenta] \definecolor [tmavezluta] [darkyellow] \definecolor [strednezluta] [middleyellow] + \definecolor [sveltezluta] [lightyellow] \definecolor [tmaveseda] [darkgray] \definecolor [stredneseda] [middlegray] @@ -210,14 +222,16 @@ \definecolor [bluchiaro] [lightblue] \definecolor [azzurroscuro] [darkcyan] - \definecolor [azzurrochiaro] [middlecyan] + \definecolor [azzurromedio] [middlecyan] + \definecolor [azzurrochiaro] [lightcyan] \definecolor [cremisiscuro] [darkmagenta] - \definecolor [cremisichiaro] [middlemagenta] - + \definecolor [cremisimedio] [middlemagenta] + \definecolor [cremisichiaro] [lightmagenta] \definecolor [gialloscuro] [darkyellow] \definecolor [giallomedio] [middleyellow] + \definecolor [giallochiaro] [lightyellow] \definecolor [grigioscuro] [darkgray] \definecolor [grigiomedio] [middlegray] @@ -225,6 +239,50 @@ \stopinterface +\startinterface french + + \definecolor [rouge] [red] + \definecolor [vert] [green] + \definecolor [bleu] [blue] + + \definecolor [cyan] [cyan] + \definecolor [magenta] [magenta] + \definecolor [jaune] [yellow] + + \definecolor [blanche] [white] + \definecolor [gris] [gray] + \definecolor [noir] [black] + + \definecolor [rougefoncé] [darkred] + \definecolor [rougemoyen] [middlered] + \definecolor [rougeclair] [lightred] + + \definecolor [vertfoncé] [darkgreen] + \definecolor [vertmoyen] [middlegreen] + \definecolor [vertclair] [lightgreen] + + \definecolor [bleufoncé] [darkblue] + \definecolor [bleumoyen] [middleblue] + \definecolor [bleuclair] [lightblue] + + \definecolor [cyanfoncé] [darkcyan] + \definecolor [cyanmoyen] [middlecyan] + \definecolor [cyanclair] [lightcyan] + + \definecolor [magentafoncé] [darkmagenta] + \definecolor [magentamoyen] [middlemagenta] + \definecolor [magentaclair] [lightmagenta] + + \definecolor [jaunefoncé] [darkyellow] + \definecolor [jaunemoyen] [middleyellow] + \definecolor [jauneclair] [lightyellow] + + \definecolor [grisfoncé] [darkgray] + \definecolor [grismoyen] [middlegray] + \definecolor [grisclair] [lightgray] + +\stopinterface + \startinterface romanian \definecolor [rosu] [red] @@ -253,12 +311,15 @@ \definecolor [cianinchis] [darkcyan] \definecolor [cianmediu] [middlecyan] + \definecolor [ciandeschis] [lightcyan] \definecolor [magentainchis] [darkmagenta] \definecolor [magentamediu] [middlemagenta] + \definecolor [magentadeschis] [lightmagenta] \definecolor [galbeninchis] [darkyellow] \definecolor [galbenmediu] [middleyellow] + \definecolor [galbendeschis] [lightyellow] \definecolor [griinchis] [darkgray] \definecolor [grimediu] [middlegray] @@ -269,6 +330,7 @@ %D Bonus (needed for FO test): \definecolor [orange] [r=1, g=.5] +\definecolor [lightorange] [r=1, g=.5] \definecolor [middleorange] [r=.6,g=.3] \definecolor [darkorange] [r=.4,g=.2] diff --git a/tex/context/base/mkiv/colo-imp-x11.mkiv b/tex/context/base/mkiv/colo-imp-x11.mkiv index 45d3aac62..a83466e8d 100644 --- a/tex/context/base/mkiv/colo-imp-x11.mkiv +++ b/tex/context/base/mkiv/colo-imp-x11.mkiv @@ -1,5 +1,5 @@ %D \module -%D [ file=colo-x11, +%D [ file=colo-imp-x11, %D version=2009.11.13, %D title=\CONTEXT\ Color Macros, %D subtitle=X11, @@ -11,9 +11,7 @@ %D Standard X11 rgb colors (from \type {/usr/share/X11/rgb.txt}): -\doifnotmode{mkiv} { - \input colo-hex.mkii -} +\startprotectedcolors \definecolor [snow] [h=fffafa] \definecolor [ghostwhite] [h=f8f8ff] @@ -43,20 +41,14 @@ \definecolor [white] [s=1] \definecolor [black] [s=0] \definecolor [darkslategray] [h=2f4f4f] -\definecolor [darkslategrey] [darkslategray] \definecolor [dimgray] [s=0.41] -\definecolor [dimgrey] [dimgray] \definecolor [slategray] [h=708090] -\definecolor [slategrey] [slategray] \definecolor [lightslategray] [h=778899] -\definecolor [lightslategrey] [lightslategray] \definecolor [gray] [s=0.75] -\definecolor [grey] [gray] \definecolor [lightgrey] [s=0.83] -\definecolor [lightgray] [lightgrey] \definecolor [midnightblue] [h=191970] \definecolor [navy] [h=000080] -\definecolor [navyblue] [navy] +\definecolor [navyblue] [h=000080] \definecolor [cornflowerblue] [h=6495ed] \definecolor [darkslateblue] [h=483d8b] \definecolor [slateblue] [h=6a5acd] @@ -464,214 +456,20 @@ \definecolor [thistle2] [h=eed2ee] \definecolor [thistle3] [h=cdb5cd] \definecolor [thistle4] [h=8b7b8b] -\definecolor [gray0] [s=0.00] -\definecolor [grey0] [gray0] -\definecolor [gray1] [s=0.01] -\definecolor [grey1] [gray1] -\definecolor [gray2] [s=0.02] -\definecolor [grey2] [gray2] -\definecolor [gray3] [s=0.03] -\definecolor [grey3] [gray3] -\definecolor [gray4] [s=0.04] -\definecolor [grey4] [gray4] -\definecolor [gray5] [s=0.05] -\definecolor [grey5] [gray5] -\definecolor [gray6] [s=0.06] -\definecolor [grey6] [gray6] -\definecolor [gray7] [s=0.07] -\definecolor [grey7] [gray7] -\definecolor [gray8] [s=0.08] -\definecolor [grey8] [gray8] -\definecolor [gray9] [s=0.09] -\definecolor [grey9] [gray9] -\definecolor [gray10] [s=0.10] -\definecolor [grey10] [gray10] -\definecolor [gray11] [s=0.11] -\definecolor [grey11] [gray11] -\definecolor [gray12] [s=0.12] -\definecolor [grey12] [gray12] -\definecolor [gray13] [s=0.13] -\definecolor [grey13] [gray13] -\definecolor [gray14] [s=0.14] -\definecolor [grey14] [gray14] -\definecolor [gray15] [s=0.15] -\definecolor [grey15] [gray15] -\definecolor [gray16] [s=0.16] -\definecolor [grey16] [gray16] -\definecolor [gray17] [s=0.17] -\definecolor [grey17] [gray17] -\definecolor [gray18] [s=0.18] -\definecolor [grey18] [gray18] -\definecolor [gray19] [s=0.19] -\definecolor [grey19] [gray19] -\definecolor [gray20] [s=0.20] -\definecolor [grey20] [gray20] -\definecolor [gray21] [s=0.21] -\definecolor [grey21] [gray21] -\definecolor [gray22] [s=0.22] -\definecolor [grey22] [gray22] -\definecolor [gray23] [s=0.23] -\definecolor [grey23] [gray23] -\definecolor [gray24] [s=0.24] -\definecolor [grey24] [gray24] -\definecolor [gray25] [s=0.25] -\definecolor [grey25] [gray25] -\definecolor [gray26] [s=0.26] -\definecolor [grey26] [gray26] -\definecolor [gray27] [s=0.27] -\definecolor [grey27] [gray27] -\definecolor [gray28] [s=0.28] -\definecolor [grey28] [gray28] -\definecolor [gray29] [s=0.29] -\definecolor [grey29] [gray29] -\definecolor [gray30] [s=0.30] -\definecolor [grey30] [gray30] -\definecolor [gray31] [s=0.31] -\definecolor [grey31] [gray31] -\definecolor [gray32] [s=0.32] -\definecolor [grey32] [gray32] -\definecolor [gray33] [s=0.33] -\definecolor [grey33] [gray33] -\definecolor [gray34] [s=0.34] -\definecolor [grey34] [gray34] -\definecolor [gray35] [s=0.35] -\definecolor [grey35] [gray35] -\definecolor [gray36] [s=0.36] -\definecolor [grey36] [gray36] -\definecolor [gray37] [s=0.37] -\definecolor [grey37] [gray37] -\definecolor [gray38] [s=0.38] -\definecolor [grey38] [gray38] -\definecolor [gray39] [s=0.39] -\definecolor [grey39] [gray39] -\definecolor [gray40] [s=0.40] -\definecolor [grey40] [gray40] -\definecolor [gray41] [s=0.41] -\definecolor [grey41] [gray41] -\definecolor [gray42] [s=0.42] -\definecolor [grey42] [gray42] -\definecolor [gray43] [s=0.43] -\definecolor [grey43] [gray43] -\definecolor [gray44] [s=0.44] -\definecolor [grey44] [gray44] -\definecolor [gray45] [s=0.45] -\definecolor [grey45] [gray45] -\definecolor [gray46] [s=0.46] -\definecolor [grey46] [gray46] -\definecolor [gray47] [s=0.47] -\definecolor [grey47] [gray47] -\definecolor [gray48] [s=0.48] -\definecolor [grey48] [gray48] -\definecolor [gray49] [s=0.49] -\definecolor [grey49] [gray49] -\definecolor [gray50] [s=0.50] -\definecolor [grey50] [gray50] -\definecolor [gray51] [s=0.51] -\definecolor [grey51] [gray51] -\definecolor [gray52] [s=0.52] -\definecolor [grey52] [gray52] -\definecolor [gray53] [s=0.53] -\definecolor [grey53] [gray53] -\definecolor [gray54] [s=0.54] -\definecolor [grey54] [gray54] -\definecolor [gray55] [s=0.55] -\definecolor [grey55] [gray55] -\definecolor [gray56] [s=0.56] -\definecolor [grey56] [gray56] -\definecolor [gray57] [s=0.57] -\definecolor [grey57] [gray57] -\definecolor [gray58] [s=0.58] -\definecolor [grey58] [gray58] -\definecolor [gray59] [s=0.59] -\definecolor [grey59] [gray59] -\definecolor [gray60] [s=0.60] -\definecolor [grey60] [gray60] -\definecolor [gray61] [s=0.61] -\definecolor [grey61] [gray61] -\definecolor [gray62] [s=0.62] -\definecolor [grey62] [gray62] -\definecolor [gray63] [s=0.63] -\definecolor [grey63] [gray63] -\definecolor [gray64] [s=0.64] -\definecolor [grey64] [gray64] -\definecolor [gray65] [s=0.65] -\definecolor [grey65] [gray65] -\definecolor [gray66] [s=0.66] -\definecolor [grey66] [gray66] -\definecolor [gray67] [s=0.67] -\definecolor [grey67] [gray67] -\definecolor [gray68] [s=0.68] -\definecolor [grey68] [gray68] -\definecolor [gray69] [s=0.69] -\definecolor [grey69] [gray69] -\definecolor [gray70] [s=0.70] -\definecolor [grey70] [gray70] -\definecolor [gray71] [s=0.71] -\definecolor [grey71] [gray71] -\definecolor [gray72] [s=0.72] -\definecolor [grey72] [gray72] -\definecolor [gray73] [s=0.73] -\definecolor [grey73] [gray73] -\definecolor [gray74] [s=0.74] -\definecolor [grey74] [gray74] -\definecolor [gray75] [s=0.75] -\definecolor [grey75] [gray75] -\definecolor [gray76] [s=0.76] -\definecolor [grey76] [gray76] -\definecolor [gray77] [s=0.77] -\definecolor [grey77] [gray77] -\definecolor [gray78] [s=0.78] -\definecolor [grey78] [gray78] -\definecolor [gray79] [s=0.79] -\definecolor [grey79] [gray79] -\definecolor [gray80] [s=0.80] -\definecolor [grey80] [gray80] -\definecolor [gray81] [s=0.81] -\definecolor [grey81] [gray81] -\definecolor [gray82] [s=0.82] -\definecolor [grey82] [gray82] -\definecolor [gray83] [s=0.83] -\definecolor [grey83] [gray83] -\definecolor [gray84] [s=0.84] -\definecolor [grey84] [gray84] -\definecolor [gray85] [s=0.85] -\definecolor [grey85] [gray85] -\definecolor [gray86] [s=0.86] -\definecolor [grey86] [gray86] -\definecolor [gray87] [s=0.87] -\definecolor [grey87] [gray87] -\definecolor [gray88] [s=0.88] -\definecolor [grey88] [gray88] -\definecolor [gray89] [s=0.89] -\definecolor [grey89] [gray89] -\definecolor [gray90] [s=0.90] -\definecolor [grey90] [gray90] -\definecolor [gray91] [s=0.91] -\definecolor [grey91] [gray91] -\definecolor [gray92] [s=0.92] -\definecolor [grey92] [gray92] -\definecolor [gray93] [s=0.93] -\definecolor [grey93] [gray93] -\definecolor [gray94] [s=0.94] -\definecolor [grey94] [gray94] -\definecolor [gray95] [s=0.95] -\definecolor [grey95] [gray95] -\definecolor [gray96] [s=0.96] -\definecolor [grey96] [gray96] -\definecolor [gray97] [s=0.97] -\definecolor [grey97] [gray97] -\definecolor [gray98] [s=0.98] -\definecolor [grey98] [gray98] -\definecolor [gray99] [s=0.99] -\definecolor [grey99] [gray99] -\definecolor [gray100] [s=1.00] -\definecolor [grey100] [gray100] + +% A lot of useless grays: + +\dorecurse{100}{ + \definecolor [gray#1] [s=\cldcontext{#1/100}] +} + \definecolor [darkgrey] [s=0.66] -\definecolor [darkgray] [darkgrey] \definecolor [darkblue] [h=00008b] \definecolor [darkcyan] [h=008b8b] \definecolor [darkmagenta] [h=8b008b] \definecolor [darkred] [h=8b0000] \definecolor [lightgreen] [h=90ee90] +\stopprotectedcolors + \endinput diff --git a/tex/context/base/mkiv/colo-imp-xwi.mkiv b/tex/context/base/mkiv/colo-imp-xwi.mkiv index 557e9c57c..57fe7965b 100644 --- a/tex/context/base/mkiv/colo-imp-xwi.mkiv +++ b/tex/context/base/mkiv/colo-imp-xwi.mkiv @@ -8,11 +8,13 @@ %D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] %C %C This module is part of the \CONTEXT\ macro||package and is -%C therefore copyrighted by \PRAGMA. See mreadme.pdf for -%C details. +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. %D I've forgotten where I got these definitions from, but maybe -%D they can be of use. +%D they can be of use. + +\startprotectedcolors \definecolor [aliceblue] [r=0.94,g=0.97,b=1.00] \definecolor [antiquewhite] [r=0.98,g=0.92,b=0.84] @@ -127,7 +129,7 @@ \definecolor [snow] [r=1.00,g=0.98,b=0.98] \definecolor [springgreen] [r=0.00,g=1.00,b=0.50] \definecolor [steelblue] [r=0.27,g=0.51,b=0.71] -\definecolor [tan ] [r=0.82,g=0.71,b=0.55] +\definecolor [x11tan] [r=0.82,g=0.71,b=0.55] \definecolor [thistle] [r=0.85,g=0.75,b=0.85] \definecolor [tomato] [r=1.00,g=0.39,b=0.28] \definecolor [turquoise] [r=0.25,g=0.88,b=0.82] @@ -139,4 +141,6 @@ \definecolor [yellow] [r=1.00,g=1.00,b=0.00] \definecolor [yellowgreen] [r=0.60,g=0.80,b=0.20] +\stopprotectedcolors + \endinput diff --git a/tex/context/base/mkiv/colo-ini.lua b/tex/context/base/mkiv/colo-ini.lua index 495a09809..1a055242b 100644 --- a/tex/context/base/mkiv/colo-ini.lua +++ b/tex/context/base/mkiv/colo-ini.lua @@ -362,7 +362,7 @@ local function defineprocesscolor(name,str,global,freeze) -- still inconsistent definecolor(name, register_color(name,'rgb', tonumber(r) or 0, tonumber(g) or 0, tonumber(b) or 0), global) else local c, m, y, k = settings.c, settings.m, settings.y, settings.k - if c or m or y or b then + if c or m or y or k then definecolor(name, register_color(name,'cmyk',tonumber(c) or 0, tonumber(m) or 0, tonumber(y) or 0, tonumber(k) or 0), global) else local h, s, v = settings.h, settings.s, settings.v diff --git a/tex/context/base/mkiv/colo-ini.mkiv b/tex/context/base/mkiv/colo-ini.mkiv index d8267becc..26208edd4 100644 --- a/tex/context/base/mkiv/colo-ini.mkiv +++ b/tex/context/base/mkiv/colo-ini.mkiv @@ -363,26 +363,73 @@ %D This saves us some typing in for instance the modules that %D deal with pretty verbatim typesetting. -\let\m_colo_palets_tmp\empty +\installcorenamespace{paletlist} +\installcorenamespace{paletsize} + +\let\m_colo_palet\relax +\let\c_colo_palet\relax + +\def\colo_palet_allocate#1% + {\expandafter\let \csname\??paletlist#1\endcsname\empty + \expandafter\newcount\csname\??paletsize#1\endcsname} + +\def\colo_palet_prepare#1% + {\edef\colo_palet_name{#1}% + \ifcsname\??paletlist\colo_palet_name\endcsname\else + \colo_palet_allocate\colo_palet_name + \fi + \edef\m_colo_palet{\begincsname\??paletlist\colo_palet_name\endcsname}% + \expandafter\let\expandafter\c_colo_palet\csname\??paletsize\colo_palet_name\endcsname} + +\def\colo_palet_extend#1% + {\addtocommalist{#1}\m_colo_palet + \expandafter\let\csname\??paletlist\colo_palet_name\endcsname\m_colo_palet + \advance\c_colo_palet\plusone} + +\unexpanded\def\doifelsecolorpalet#1% + {\ifcsname\??paletlist#1\endcsname + \expandafter\firstoftwoarguments + \else + \expandafter\secondoftwoarguments + \fi} + +\let\paletlist\empty +\let\paletsize\!!zerocount + +\unexpanded\def\getpaletlist[#1]% + {\edef\paletlist{\begincsname\??paletlist#1\endcsname}} + +\unexpanded\def\getpaletsize[#1]% + {\ifcsname\??paletsize#1\endcsname + \edef\paletsize{\the\lastnamedcs}% + \else + \let\paletsize\!!zerocount + \fi} \unexpanded\def\definepalet - {\dodoubleargument\colo_palets_define} - -\unexpanded\def\colo_palets_define[#1][#2]% todo - {\doifelseassignment{#2} - {%\colo_helpers_show_message\m!colors6{#1}% - \let\m_colo_palets_tmp\empty - \setevalue{\??colorpaletspecification#1}{#2}% - \processcommalist[#2]{\colo_palets_define_one{#1}}% - \letvalue{\??colorpalet#1}\m_colo_palets_tmp - \let\m_colo_palets_tmp\empty} + {\dotripleempty\colo_palets_define} + +\def\colo_palets_define + {\ifthirdargument + \expandafter\colo_palets_define_b + \else + \expandafter\colo_palets_define_a + \fi} + +\unexpanded\def\colo_palets_define_a[#1][#2][#3]% + {\colo_palet_prepare{#1}% + \doifelseassignment{#2} + {\setevalue{\??colorpaletspecification#1}{#2}% + \processcommalist[#2]{\colo_palets_define_one{#1}}} {\ifcsname\??colorpaletspecification#2\endcsname - %\normalexpanded{\colo_palets_define[#1][\csname\??colorpaletspecification#2\endcsname]}% \normalexpanded{\colo_palets_define[#1][\lastnamedcs]}% \fi}} -% \def\colo_palets_define_one#1#2% get rid of { } in #2 -% {\colo_palets_define_two{#1}[#2]}% +\unexpanded\def\colo_palets_define_b[#1][#2][#3]% + {\colo_palet_prepare{#1}% + \setevalue{\??colorpaletspecification#1}{#2}% + \colo_palet_extend{#2}% + \colo_palets_define_assign{#1}{#2}{#3}} \def\colo_palets_define_one#1#2% get rid of { } {\doifelseassignment{#2} % catch empty entries @@ -390,21 +437,14 @@ {\colo_palets_define_three{#1}{#2}}} \def\colo_palets_define_two#1[#2=#3]% - {\edef\m_colo_palets_tmp{\ifx\m_colo_palets_tmp\empty\else\m_colo_palets_tmp,\fi#2}% + {\colo_palet_extend{#2}% \colo_palets_define_set{#1}{#2}{#3}}% \def\colo_palets_define_three#1#2% {\ifcsname\??colorpaletspecification#2\endcsname - %\processcommacommand[\csname\??colorpaletspecification#2\endcsname]{\colo_palets_define_one{#1}}% \processcommacommand[\lastnamedcs]{\colo_palets_define_one{#1}}% \fi} -\let\paletsize\!!zerocount - -\unexpanded\def\getpaletsize[#1]% only works for valid k=v definitions - {\getcommacommandsize[\csname\??colorpaletspecification#1\endcsname]% - \edef\paletsize{\number\commalistsize}} - %D Instead of refering to colors, one can also directly specify %D a color: %D @@ -431,7 +471,7 @@ \ifx\currentcolorpalet\empty % seems to be a reset \let\currentcolorprefix\empty - \else\ifcsname\??colorpalet\currentcolorpalet\endcsname + \else\ifcsname\??paletlist\currentcolorpalet\endcsname \edef\currentcolorprefix{#1:}% \else \colo_helpers_show_message\m!colors7\currentcolorpalet @@ -510,13 +550,11 @@ %D %D These speak for themselves. See \type {colo-ext} for usage. -\def\negatecolorcomponent#1% #1 = \macro +\unexpanded\def\negatecolorcomponent#1% #1 = \macro {\scratchdimen\onepoint\advance\scratchdimen-#1\onepoint \ifdim\scratchdimen<\zeropoint\scratchdimen\zeropoint\fi \edef#1{\withoutpt\the\scratchdimen}} -\let\negatedcolorcomponent\firstofoneargument - \def\negatedcolorcomponent#1% {\ifdim\dimexpr\onepoint-#1\onepoint\relax<\zeropoint \!!zerocount @@ -524,7 +562,7 @@ \expandafter\withoutpt\the\dimexpr\onepoint-#1\onepoint\relax \fi} -\def\negatecolorcomponent#1% #1 = \macro +\unexpanded\def\negatecolorcomponent#1% #1 = \macro {\edef#1{\negatedcolorcomponent{#1}}} %D \macros @@ -989,15 +1027,15 @@ \def\colo_helpers_inherited_direct_ts#1{\ifcsname\??transparencysetter #1\endcsname\lastnamedcs\fi} \def\colo_helpers_inherited_direct_ta#1{\ifcsname\??transparencyattribute#1\endcsname\lastnamedcs\else\!!zerocount\fi} -%def\colo_helpers_inherited_palet_ca#1#2{\csname\??colorattribute \ifcsname\??colorattribute \??colorpalet#1:#2\endcsname\??colorpalet#1:#2\fi\endcsname} -%def\colo_helpers_inherited_palet_cs#1#2{\csname\??colorsetter \ifcsname\??colorsetter \??colorpalet#1:#2\endcsname\??colorpalet#1:#2\fi\endcsname} -%def\colo_helpers_inherited_palet_ta#1#2{\csname\??transparencyattribute\ifcsname\??transparencyattribute\??colorpalet#1:#2\endcsname\??colorpalet#1:#2\fi\endcsname} -%def\colo_helpers_inherited_palet_ts#1#2{\csname\??transparencysetter \ifcsname\??transparencysetter \??colorpalet#1:#2\endcsname\??colorpalet#1:#2\fi\endcsname} - -\def\colo_helpers_inherited_palet_ca#1#2{\ifcsname\??colorattribute \??colorpalet#1:#2\endcsname\lastnamedcs\fi} -\def\colo_helpers_inherited_palet_cs#1#2{\ifcsname\??colorsetter \??colorpalet#1:#2\endcsname\lastnamedcs\else\!!zerocount\fi} -\def\colo_helpers_inherited_palet_ta#1#2{\ifcsname\??transparencyattribute\??colorpalet#1:#2\endcsname\lastnamedcs\fi} -\def\colo_helpers_inherited_palet_ts#1#2{\ifcsname\??transparencysetter \??colorpalet#1:#2\endcsname\lastnamedcs\else\!!zerocount\fi} +% %def\colo_helpers_inherited_palet_cs#1#2{\csname\??colorsetter \ifcsname\??colorsetter \??colorpalet#1:#2\endcsname\??colorpalet#1:#2\fi\endcsname} +% %def\colo_helpers_inherited_palet_ca#1#2{\csname\??colorattribute \ifcsname\??colorattribute \??colorpalet#1:#2\endcsname\??colorpalet#1:#2\fi\endcsname} +% %def\colo_helpers_inherited_palet_ts#1#2{\csname\??transparencysetter \ifcsname\??transparencysetter \??colorpalet#1:#2\endcsname\??colorpalet#1:#2\fi\endcsname} +% %def\colo_helpers_inherited_palet_ta#1#2{\csname\??transparencyattribute\ifcsname\??transparencyattribute\??colorpalet#1:#2\endcsname\??colorpalet#1:#2\fi\endcsname} +% +% \def\colo_helpers_inherited_palet_cs#1#2{\ifcsname\??colorsetter \??colorpalet#1:#2\endcsname\lastnamedcs\fi} +% \def\colo_helpers_inherited_palet_ca#1#2{\ifcsname\??colorattribute \??colorpalet#1:#2\endcsname\lastnamedcs\else\!!zerocount\fi} +% \def\colo_helpers_inherited_palet_ts#1#2{\ifcsname\??transparencysetter \??colorpalet#1:#2\endcsname\lastnamedcs} +% \def\colo_helpers_inherited_palet_ta#1#2{\ifcsname\??transparencyattribute\??colorpalet#1:#2\endcsname\lastnamedcs\else\!!zerocount\fi} \let\colo_helpers_set_value\setvalue @@ -1009,25 +1047,56 @@ \fi \to \everysetupcolors +% \def\colo_palets_define_set#1#2#3% +% {\doifelseassignment{#3}% \definepalet[test][xx={y=.4}] +% {\definecolor[\??colorpalet#1:#2][#3]% +% \colo_helpers_set_value{\??colorsetter #1:#2}{\colo_helpers_inherited_palet_ca{#1}{#2}}% +% \colo_helpers_set_value{\??colorattribute #1:#2}{\colo_helpers_inherited_palet_cs{#1}{#2}}% +% \colo_helpers_set_value{\??transparencysetter #1:#2}{\colo_helpers_inherited_palet_ta{#1}{#2}}% +% \colo_helpers_set_value{\??transparencyattribute#1:#2}{\colo_helpers_inherited_palet_ts{#1}{#2}}} +% {\ifcsname\??colorsetter#3\endcsname % \definepalet[test][xx=green] +% \colo_helpers_set_value{\??colorsetter #1:#2}{\colo_helpers_inherited_direct_cs{#3}}% +% \colo_helpers_set_value{\??colorattribute #1:#2}{\colo_helpers_inherited_direct_ca{#3}}% +% \colo_helpers_set_value{\??transparencysetter #1:#2}{\colo_helpers_inherited_direct_ts{#3}}% +% \colo_helpers_set_value{\??transparencyattribute#1:#2}{\colo_helpers_inherited_direct_ta{#3}}% +% \else +% % not entered when making format +% \localundefine{\??colorsetter #1:#2}% +% \localundefine{\??colorattribute #1:#2}% +% \localundefine{\??transparencysetter #1:#2}% +% \localundefine{\??transparencyattribute#1:#2}% +% \fi}} + \def\colo_palets_define_set#1#2#3% {\doifelseassignment{#3}% \definepalet[test][xx={y=.4}] - {\definecolor[\??colorpalet#1:#2][#3]% - \colo_helpers_set_value{\??colorsetter #1:#2}{\colo_helpers_inherited_palet_ca{#1}{#2}}% - \colo_helpers_set_value{\??colorattribute #1:#2}{\colo_helpers_inherited_palet_cs{#1}{#2}}% - \colo_helpers_set_value{\??transparencysetter #1:#2}{\colo_helpers_inherited_palet_ta{#1}{#2}}% - \colo_helpers_set_value{\??transparencyattribute#1:#2}{\colo_helpers_inherited_palet_ts{#1}{#2}}} - {\ifcsname\??colorsetter#3\endcsname % \definepalet[test][xx=green] - \colo_helpers_set_value{\??colorsetter #1:#2}{\colo_helpers_inherited_direct_cs{#3}}% - \colo_helpers_set_value{\??colorattribute #1:#2}{\colo_helpers_inherited_direct_ca{#3}}% - \colo_helpers_set_value{\??transparencysetter #1:#2}{\colo_helpers_inherited_direct_ts{#3}}% - \colo_helpers_set_value{\??transparencyattribute#1:#2}{\colo_helpers_inherited_direct_ta{#3}}% + {\colo_palets_define_assign}% + {\ifcsname\??colorsetter#3\endcsname + % \definepalet[test][xx=green] + \expandafter\colo_palets_define_inherit \else % not entered when making format - \localundefine{\??colorsetter #1:#2}% - \localundefine{\??colorattribute #1:#2}% - \localundefine{\??transparencysetter #1:#2}% - \localundefine{\??transparencyattribute#1:#2}% - \fi}} + \expandafter\colo_palets_define_undefine + \fi}% + {#1}{#2}{#3}} + +\def\colo_palets_define_inherit#1#2#3% + {\colo_helpers_set_value{\??colorsetter #1:#2}{\colo_helpers_inherited_direct_cs{#3}}% + \colo_helpers_set_value{\??colorattribute #1:#2}{\colo_helpers_inherited_direct_ca{#3}}% + \colo_helpers_set_value{\??transparencysetter #1:#2}{\colo_helpers_inherited_direct_ts{#3}}% + \colo_helpers_set_value{\??transparencyattribute#1:#2}{\colo_helpers_inherited_direct_ta{#3}}} + +\def\colo_palets_define_undefine#1#2#3% + {\localundefine{\??colorsetter #1:#2}% + \localundefine{\??colorattribute #1:#2}% + \localundefine{\??transparencysetter #1:#2}% + \localundefine{\??transparencyattribute#1:#2}} + +\def\colo_palets_define_assign#1#2#3% + {\definecolor[\??colorpalet#1:#2][#3]% + \colo_helpers_set_value{\??colorsetter #1:#2}{\colo_helpers_inherited_direct_cs{\??colorpalet#1:#2}}% + \colo_helpers_set_value{\??colorattribute #1:#2}{\colo_helpers_inherited_direct_ca{\??colorpalet#1:#2}}% + \colo_helpers_set_value{\??transparencysetter #1:#2}{\colo_helpers_inherited_direct_ts{\??colorpalet#1:#2}}% + \colo_helpers_set_value{\??transparencyattribute#1:#2}{\colo_helpers_inherited_direct_ta{\??colorpalet#1:#2}}} \setvalue{\??colorattribute currentcolor}{\the\attribute\colorattribute} % for mpcolor \setvalue{\??transparencyattribute currentcolor}{\the\attribute\transparencyattribute} % for mpcolor diff --git a/tex/context/base/mkiv/colo-run.lua b/tex/context/base/mkiv/colo-run.lua index 27f7c6b12..6368b3307 100644 --- a/tex/context/base/mkiv/colo-run.lua +++ b/tex/context/base/mkiv/colo-run.lua @@ -11,27 +11,31 @@ if not modules then modules = { } end modules ['colo-run'] = { local colors, commands, context, utilities = colors, commands, context, utilities -local colors= attributes.colors +local colors = attributes.colors + +local private = table.tohash { "d_u_m_m_y", "maintextcolor", "themaintextcolor" } function commands.showcolorset(name) local set = colors.setlist(name) context.starttabulate { "|l|l|l|l|l|l|l|" } for i=1,#set do local s = set[i] - local r = { width = "4em", height = "max", depth = "max", color = s } - context.NC() - context.setcolormodel { "gray" } - context.blackrule(r) - context.NC() - context.blackrule(r) - context.NC() - context.grayvalue(s) - context.NC() - context.colorvalue(s) - context.NC() - context(s) - context.NC() - context.NR() + if not private[s] then + local r = { width = "4em", height = "max", depth = "max", color = s } + context.NC() + context.setcolormodel { "gray" } + context.blackrule(r) + context.NC() + context.blackrule(r) + context.NC() + context.grayvalue(s) + context.NC() + context.colorvalue(s) + context.NC() + context(s) + context.NC() + context.NR() + end end context.stoptabulate() end @@ -52,16 +56,18 @@ function commands.showcolorcomponents(list) context.TB() for i=1,#set do local s = set[i] - context.NC() - context.showcolorbar { s } - context.NC() - context(s) - context.NC() - context.transparencycomponents(s) - context.NC() - context.colorcomponents(s) - context.NC() - context.NR() + if not private[s] then + context.NC() + context.showcolorbar { s } + context.NC() + context(s) + context.NC() + context.transparencycomponents(s) + context.NC() + context.colorcomponents(s) + context.NC() + context.NR() + end end context.stoptabulate() end diff --git a/tex/context/base/mkiv/colo-run.mkiv b/tex/context/base/mkiv/colo-run.mkiv index 1b8b87c75..37a9de190 100644 --- a/tex/context/base/mkiv/colo-run.mkiv +++ b/tex/context/base/mkiv/colo-run.mkiv @@ -45,32 +45,33 @@ {\dodoubleargument\colo_show_palet} \gdef\colo_show_palet[#1][#2]% - {\ifcsname\??colorpalet#1\endcsname - \doifelseinset\v!vertical{#2} \colo_palets_show_vertical \colo_palets_show_horizontal [#1][#2]% - \fi} - -\gdef\colo_palets_show_vertical[#1][#2]% - {\vbox - {\forgetall - \setlocalhsize - \hsize\localhsize - \offinterlineskip - \setuppalet[#1] - \tabskip\zeropoint - \def\colo_palets_show_palet##1% - {\doifelseinset\v!number{#2}{##1\hskip.5\emwidth}{}% - \aligntab - \color [##1]{\vrule\s!width3\emwidth\s!height\strutht\s!depth\strutdp}% - \graycolor[##1]{\vrule\s!width3\emwidth\s!height\strutht\s!depth\strutdp}% - \aligntab - \doifinset\v!value{#2}{\hskip.5\emwidth\colorvalue{##1}}% - \crcr} - \halign - {\hss\alignmark\alignmark\aligntab\hss\alignmark\alignmark\hss\aligntab\alignmark\alignmark\cr - \aligntab\doifinset\v!name{#2}{\strut#1}\aligntab\cr - \colo_palets_process[#1]\colo_palets_show_palet\crcr}}} - -\gdef\colo_palets_show_horizontal[#1][#2]% todo: bTABLE etc + {\doifelsecolorpalet{#1} + {\doifelseinset\v!vertical{#2} \colo_palets_show_vertical \colo_palets_show_horizontal {#1}{#2}}% + {}} + +\gdef\colo_palets_show_vertical#1#2% + {\begingroup + \forgetall + \setlocalhsize + \hsize\localhsize + \offinterlineskip + \setuppalet[#1] + \tabskip\zeropoint + \def\colo_palets_show_palet##1% + {\doifelseinset\v!number{#2}{##1\hskip.5\emwidth}{}% + \aligntab + \color [##1]{\vrule\s!width3\emwidth\s!height\strutht\s!depth\strutdp}% + \graycolor[##1]{\vrule\s!width3\emwidth\s!height\strutht\s!depth\strutdp}% + \aligntab + \doifinset\v!value{#2}{\hskip.5\emwidth\colorvalue{##1}}% + \crcr} + \halign + {\hss\alignmark\alignmark\aligntab\hss\alignmark\alignmark\hss\aligntab\alignmark\alignmark\cr + \aligntab\doifinset\v!name{#2}{\strut#1}\aligntab\cr + \colo_palets_process[#1]\colo_palets_show_palet\crcr}% + \endgroup} + +\gdef\colo_palets_show_horizontal#1#2% todo: bTABLE etc {\vbox {\forgetall \setlocalhsize @@ -116,29 +117,31 @@ \crcr}}} \gdef\colo_palets_process[#1]% - {\expanded{\globalprocesscommalist[\getvalue{\??colorpalet#1}]}} + {\getpaletlist[#1]% + \normalexpanded{\globalprocesscommalist[\paletlist]}} \unexpanded\gdef\comparepalet {\dosingleargument\colo_palets_compare} \gdef\colo_palets_compare[#1]% - {\ifcsname\??colorpalet#1\endcsname - \hbox - {\colo_palets_compare_indeed\color[#1]% - \quad - \colo_palets_compare_indeed\graycolor[#1]}% - \fi} - -\gdef\colo_palets_compare_indeed#1[#2]% + {\doifelsecolorpalet{#1}% + {\hbox + {\colo_palets_compare_indeed\color{#1}% + \quad + \colo_palets_compare_indeed\graycolor{#1}}}% + {}} + +\gdef\colo_palets_compare_indeed#1#2% {\vbox {\forgetall \setlocalhsize \hsize\localhsize \offinterlineskip \setuppalet[#2] - \getcommacommandsize[\getvalue{\??colorpalet#2}] + \getpaletsize[#2]% + \getpaletlist[#2]% \scratchwidth2\emwidth\relax - \hsize\commalistsize\scratchwidth + \hsize\paletsize\scratchwidth \def\colo_palets_compare##1% {\hbox {\setbox0\hbox @@ -149,9 +152,9 @@ {\def\colo_palets_compare####1% {\hbox to \scratchwidth {\hss#1[####1]{\vrule\s!width.5\scratchwidth\s!height2.25\exheight\s!depth-.75\exheight}\hss}}% - \processcommacommand[\getvalue{\??colorpalet#2}]\colo_palets_compare}} + \processcommacommand[\paletlist]\colo_palets_compare}} \endgraf} - \processcommacommand[\getvalue{\??colorpalet#2}]\colo_palets_compare}} + \processcommacommand[\paletlist]\colo_palets_compare}} %D Groups diff --git a/tex/context/base/mkiv/cont-new.mkiv b/tex/context/base/mkiv/cont-new.mkiv index 91c8e6d22..33e820ee3 100644 --- a/tex/context/base/mkiv/cont-new.mkiv +++ b/tex/context/base/mkiv/cont-new.mkiv @@ -11,7 +11,7 @@ %C therefore copyrighted by \PRAGMA. See mreadme.pdf for %C details. -\newcontextversion{2016.03.13 23:40} +\newcontextversion{2016.03.26 13:05} %D This file is loaded at runtime, thereby providing an excellent place for %D hacks, patches, extensions and new features. diff --git a/tex/context/base/mkiv/context-performance.tex b/tex/context/base/mkiv/context-performance.tex index c012c992c..dd3768664 100644 --- a/tex/context/base/mkiv/context-performance.tex +++ b/tex/context/base/mkiv/context-performance.tex @@ -4,6 +4,8 @@ \starttext +\subject {About performance} + If you use \PDFTEX, \XETEX\ and \LUATEX\ you will notice a difference in speed. Don't draw conclusions too easily from simple tests like: @@ -30,9 +32,9 @@ So, it's best to compare speeds with a mixed content document: multiple fonts, text and math, images, \METAPOST\ graphics, structural components, tables, etc. On the average \PDFTEX\ is the fastest, but offering less functionality, while -\LUATEX\ with \MKIV\ is faster than \XETEX\ with \MKII. On complex products like -the \METAFUN\ manual or when processing complex \XML\ files a \LUATEX\ is much -faster than a \PDFTEX\ run. +\LUATEX\ with \MKIV\ is often faster than \XETEX\ with \MKII. On complex products +like the \METAFUN\ manual or when processing complex \XML\ files a \LUATEX\ is +much faster than a \PDFTEX\ run. There is some startup time involved which is normally not that much, and initial font loading is also not really a burden, but of course for a few page document @@ -40,7 +42,8 @@ it brings down the number of pages processed per second. Normalizing the input takes a bit but applying \OPENTYPE\ font features takes much more. If you find unacceptable bottlenecks just let me know (but better first check performance in the other engines). Of course inefficient coding of styles (massive font switches -where a simple one could do) are no reason for a complaint. +where a simple one could do) are no reason for a complaint. Keep in mind: +flexibility comes at a price. A lot of time went into making sure that \CONTEXT\ runs efficiently on \LUATEX\ and we keep improving the performance. This is not so much an engine issue but @@ -48,4 +51,16 @@ more one of the macro package. Of course what is true for \CONTEXT\ \MKIV\ can b different for other macro packages but comparing with them makes no sense because the differences in functionality. +There are many features in \CONTEXT\ \MKIV\ that demand analysis of the text +stream and when a spot is found where that feature has to be applied some actions +takes place. Most such features don't have an impact on overall performance (due +to the analysis) unless they are used. Of course font processing has the largest +impact, but they are also the most flexible and extensible feature, especially +when you use dynamic features. And font processing is always enabled. Speed has +been improved over time and we're currently at a point that further speedup makes +not much sense and would only make the code more complex. This is not to say that +we cannot improve performance in the future. + +Hans Hagen \crlf Hasselt NL + \stoptext diff --git a/tex/context/base/mkiv/context-todo.tex b/tex/context/base/mkiv/context-todo.tex new file mode 100644 index 000000000..933b15e6f --- /dev/null +++ b/tex/context/base/mkiv/context-todo.tex @@ -0,0 +1,39 @@ +% language=uk + +\usemodule[art-01,abr-01] + +\starttext + +\subject {On the agenda} + +\subsubject{\LUATEX} + +\startitemize + \startitem + head||tail cleanup in disc nodes (get rid of temp i.e.\ delay till linebreak) + \stopitem + \startitem + optimize some callback resolution (more direct) + \stopitem + \startitem + move glue specs into glue nodes + \stopitem +\stopitemize + +\subsubject{\CONTEXT} + +\startitemize + \startitem + play with par callback and properties + \stopitem + \startitem + play with box attributes + \stopitem + \startitem + redo some of the spacing (adapt to improvements in engine) + \stopitem +\stopitemize + +\vfill {\em Feel free to suggest additions.} + +\stoptext diff --git a/tex/context/base/mkiv/context.mkiv b/tex/context/base/mkiv/context.mkiv index dfc4d0bd1..52c346f62 100644 --- a/tex/context/base/mkiv/context.mkiv +++ b/tex/context/base/mkiv/context.mkiv @@ -39,7 +39,7 @@ %D up and the dependencies are more consistent. \edef\contextformat {\jobname} -\edef\contextversion{2016.03.13 23:40} +\edef\contextversion{2016.03.26 13:05} \edef\contextkind {beta} %D For those who want to use this: @@ -268,8 +268,8 @@ %loadmarkfile{strc-reg} \loadmkvifile{strc-lev} % experiment -\loadmarkfile{spac-ali} \loadmarkfile{spac-hor} +\loadmarkfile{spac-ali} \loadmarkfile{spac-flr} \loadmarkfile{spac-ver} \loadmarkfile{spac-lin} diff --git a/tex/context/base/mkiv/core-con.lua b/tex/context/base/mkiv/core-con.lua index 53f9734dc..bfe5357a6 100644 --- a/tex/context/base/mkiv/core-con.lua +++ b/tex/context/base/mkiv/core-con.lua @@ -28,8 +28,10 @@ local implement = interfaces.implement local settings_to_array = utilities.parsers.settings_to_array local allocate = utilities.storage.allocate +local setmetatableindex = table.setmetatableindex local formatters = string.formatters local variables = interfaces.variables +local constants = interfaces.constants converters = converters or { } local converters = converters @@ -609,12 +611,23 @@ function converters.define(name,set) -- ,language) sequences[name] = settings_to_array(set) end +function converters.max(name) + local s = sequences[name] + return s and #s or 0 +end + implement { name = "defineconversion", actions = converters.define, arguments = { "string", "string" } } +implement { + name = "nofconversions", + actions = { converters.max, context }, + arguments = "string", +} + local function convert(method,n,language) local converter = language and converters[method..":"..language] or converters[method] if converter then @@ -1137,7 +1150,7 @@ local v_WEEKDAY = upper(v_weekday) local convert = converters.convert -local days = { -- not variables.sunday +local days = { -- not variables "sunday", "monday", "tuesday", @@ -1147,7 +1160,7 @@ local days = { -- not variables.sunday "saturday", } -local months = { -- not variables.january +local months = { -- not variables "january", "february", "march", @@ -1162,21 +1175,28 @@ local months = { -- not variables.january "december", } +local monthmnems = { -- not variables + -- virtual table +} + +setmetatableindex(months, function(t,k) return "unknown" end) +setmetatableindex(days, function(t,k) return "unknown" end) +setmetatableindex(monthmnems, function(t,k) return months[k] .. ":mnem" end) + local function dayname(n) - return days[n] or "unknown" + return days[n] end local function weekdayname(day,month,year) - return days[weekday(day,month,year)] or "unknown" + return days[weekday(day,month,year)] end local function monthname(n) - return months[n] or "unknown" + return months[n] end local function monthmnem(n) - local m = months[n] - return m and (m ..":mnem") or "unknown" + return monthmnems[n] end implement { @@ -1252,19 +1272,19 @@ local function currentdate(str,currentlanguage) -- second argument false : no la context("%02i",year % 100) elseif tag == v_month or tag == "m" then if currentlanguage == false then - context(months[month] or "unknown") + context(months[month]) elseif mnemonic then - context.labeltext(monthmnem(month)) + context.labeltext(variables[monthmnems[month]]) else - context.labeltext(monthname(month)) + context.labeltext(variables[months[month]]) end elseif tag == v_MONTH then if currentlanguage == false then - context.WORD(months[month] or "unknown") + context.WORD(variables[months[month]]) elseif mnemonic then - context.LABELTEXT(monthmnem(month)) + context.LABELTEXT(variables[monthmnems[month]]) else - context.LABELTEXT(monthname(month)) + context.LABELTEXT(variables[months[month]]) end elseif tag == "mm" then context("%02i",month) @@ -1272,7 +1292,7 @@ local function currentdate(str,currentlanguage) -- second argument false : no la context(month) elseif tag == v_day or tag == "d" then if currentlanguage == false then - context(days[day] or "unknown") + context(days[day]) else context.convertnumber(v_day,day) -- why not direct end @@ -1286,16 +1306,16 @@ local function currentdate(str,currentlanguage) -- second argument false : no la elseif tag == v_weekday or tag == "w" then local wd = weekday(day,month,year) if currentlanguage == false then - context(days[wd] or "unknown") + context(days[wd]) else - context.labeltext(days[wd] or "unknown") + context.labeltext(variables[days[wd]]) end elseif tag == v_WEEKDAY then local wd = weekday(day,month,year) if currentlanguage == false then - context.WORD(days[wd] or "unknown") + context.WORD(days[wd]) else - context.LABELTEXT(days[wd] or "unknown") + context.LABELTEXT(variables[days[wd]]) end elseif tag == "W" then context(weekday(day,month,year)) diff --git a/tex/context/base/mkiv/core-con.mkiv b/tex/context/base/mkiv/core-con.mkiv index b440672bb..1f6dc54d5 100644 --- a/tex/context/base/mkiv/core-con.mkiv +++ b/tex/context/base/mkiv/core-con.mkiv @@ -296,7 +296,7 @@ %D %D The number of days is available in the macro \type {\numberofdays}. -\def\doifelseleapyear#1% +\def\doifelseleapyear#1% expandable check {\clf_doifelseleapyear\numexpr#1\relax} \let\doifleapyearelse\doifelseleapyear @@ -571,7 +571,7 @@ % if we have definitions that are not matched at the lua end .. eventually we might do % that when more shows up -\def\doifelseconversiondefined#1% +\def\doifelseconversiondefined#1% expandable {\ifcsname\??conversion\currentlanguage#1\endcsname \expandafter\firstoftwoarguments \else\ifcsname\??conversion#1\endcsname @@ -580,11 +580,11 @@ \doubleexpandafter\secondoftwoarguments \fi\fi} -\def\doifelseconversionnumber#1#2% - {\ifcsname\??conversion#1#2\endcsname - \expandafter\firstoftwoarguments - \else +\def\doifelseconversionnumber#1#2% expandable + {\ifnum#2>\numexpr\clf_nofconversions{#1}\relax \expandafter\secondoftwoarguments + \else + \expandafter\firstoftwoarguments \fi} \let\doifconversiondefinedelse\doifelseconversiondefined diff --git a/tex/context/base/mkiv/font-ext.lua b/tex/context/base/mkiv/font-ext.lua index fc161f59a..79144aa70 100644 --- a/tex/context/base/mkiv/font-ext.lua +++ b/tex/context/base/mkiv/font-ext.lua @@ -1037,4 +1037,3 @@ implement { context(getprivatenode(fontdata[currentfont()],name)) end } - diff --git a/tex/context/base/mkiv/font-gbn.lua b/tex/context/base/mkiv/font-gbn.lua new file mode 100644 index 000000000..f81c877f2 --- /dev/null +++ b/tex/context/base/mkiv/font-gbn.lua @@ -0,0 +1,236 @@ +if not modules then modules = { } end modules ['font-gbn'] = { + version = 1.001, + comment = "companion to luatex-*.tex", + author = "Hans Hagen, PRAGMA-ADE, Hasselt NL", + copyright = "PRAGMA ADE / ConTeXt Development Team", + license = "see context related readme files" +} + +-- generic [base|node] mode handler + +if context then + texio.write_nl("fatal error: this module is not for context") + os.exit() +end + +local fonts = fonts +local nodes = nodes + +local nuts = nodes.nuts -- context abstraction of direct nodes + +local traverse_id = nuts.traverse_id +local free_node = nuts.free +local remove_node = nuts.remove + +local glyph_code = nodes.nodecodes.glyph +local disc_code = nodes.nodecodes.disc + +local tonode = nuts.tonode +local tonut = nuts.tonut + +local getfont = nuts.getfont +local getchar = nuts.getchar +local getid = nuts.getid +local getprev = nuts.getprev +local getnext = nuts.getnext +local getdisc = nuts.getdisc +local setchar = nuts.setchar +local setlink = nuts.setlink + +-- from now on we apply ligaturing and kerning here because it might interfere with complex +-- opentype discretionary handling where the base ligature pass expect some weird extra +-- pointers (which then confuse the tail slider that has some checking built in) + +local n_ligaturing = node.ligaturing +local n_kerning = node.kerning + +local ligaturing = nuts.ligaturing +local kerning = nuts.kerning + +local basemodepass = true + +local function l_warning() texio.write_nl("warning: node.ligaturing called directly") l_warning = nil end +local function k_warning() texio.write_nl("warning: node.kerning called directly") k_warning = nil end + +function node.ligaturing(...) + if basemodepass and l_warning then + l_warning() + end + return n_ligaturing(...) +end + +function node.kerning(...) + if basemodepass and k_warning then + k_warning() + end + return n_kerning(...) +end + +function nodes.handlers.setbasemodepass(v) + basemodepass = v +end + +function nodes.handlers.nodepass(head) + local fontdata = fonts.hashes.identifiers + if fontdata then + local nuthead = tonut(head) + local usedfonts = { } + local basefonts = { } + local prevfont = nil + local basefont = nil + local variants = nil + local redundant = nil + for n in traverse_id(glyph_code,nuthead) do + local font = getfont(n) + if font ~= prevfont then + if basefont then + basefont[2] = getprev(n) + end + prevfont = font + local used = usedfonts[font] + if not used then + local tfmdata = fontdata[font] -- + if tfmdata then + local shared = tfmdata.shared -- we need to check shared, only when same features + if shared then + local processors = shared.processes + if processors and #processors > 0 then + usedfonts[font] = processors + elseif basemodepass then + basefont = { n, nil } + basefonts[#basefonts+1] = basefont + end + end + local resources = tfmdata.resources + variants = resources and resources.variants + variants = variants and next(variants) and variants or false + end + else + local tfmdata = fontdata[prevfont] + if tfmdata then + local resources = tfmdata.resources + variants = resources and resources.variants + variants = variants and next(variants) and variants or false + end + end + end + if variants then + local char = getchar(n) + if char >= 0xFE00 and (char <= 0xFE0F or (char >= 0xE0100 and char <= 0xE01EF)) then + local hash = variants[char] + if hash then + local p = getprev(n) + if p and getid(p) == glyph_code then + local variant = hash[getchar(p)] + if variant then + setchar(p,variant) + if not redundant then + redundant = { n } + else + redundant[#redundant+1] = n + end + end + end + end + end + end + end + if redundant then + for i=1,#redundant do + local n = redundant[i] + remove_node(nuthead,n) + free_node(n) + end + end + for d in traverse_id(disc_code,nuthead) do + local _, _, r = getdisc(d) + if r then + for n in traverse_id(glyph_code,r) do + local font = getfont(n) + if font ~= prevfont then + prevfont = font + local used = usedfonts[font] + if not used then + local tfmdata = fontdata[font] -- + if tfmdata then + local shared = tfmdata.shared -- we need to check shared, only when same features + if shared then + local processors = shared.processes + if processors and #processors > 0 then + usedfonts[font] = processors + end + end + end + end + end + end + end + end + if next(usedfonts) then + for font, processors in next, usedfonts do + for i=1,#processors do + head = processors[i](head,font,0) or head + end + end + end + if basemodepass and #basefonts > 0 then + for i=1,#basefonts do + local range = basefonts[i] + local start = range[1] + local stop = range[2] + if start then + local front = nuthead == start + local prev, next + if stop then + next = getnext(stop) + start, stop = ligaturing(start,stop) + start, stop = kerning(start,stop) + else + prev = getprev(start) + start = ligaturing(start) + start = kerning(start) + end + if prev then + setlink(prev,start) + end + if next then + setlink(stop,next) + end + if front and nuthead ~= start then + head = tonode(start) + end + end + end + end + return head, true + else + return head, false + end +end + +function nodes.handlers.basepass(head) + if not basemodepass then + head = n_ligaturing(head) + head = n_kerning(head) + end + return head, true +end + +local nodepass = nodes.handlers.nodepass +local basepass = nodes.handlers.basepass +local injectpass = nodes.injections.handler +local protectpass = nodes.handlers.protectglyphs + +function nodes.simple_font_handler(head) + if head then + head = nodepass(head) + head = injectpass(head) + if not basemodepass then + head = basepass(head) + end + protectpass(head) + return head, true + else + return head, false + end +end diff --git a/tex/context/base/mkiv/font-lib.mkvi b/tex/context/base/mkiv/font-lib.mkvi index 848fa872f..7bb042a59 100644 --- a/tex/context/base/mkiv/font-lib.mkvi +++ b/tex/context/base/mkiv/font-lib.mkvi @@ -47,34 +47,18 @@ \registerctxluafile{font-oti}{1.001} % otf initialization \registerctxluafile{font-ott}{1.001} % otf tables (first) -\iffalse % use new loader -% \iftrue % use old loader - - \registerctxluafile{font-otf}{1.001} % otf main - \registerctxluafile{font-otb}{1.001} % otf main base - \registerctxluafile{font-inj}{1.001} % otf kern injector - \registerctxluafile{font-ota}{1.001} % otf analyzers - \registerctxluafile{font-otn}{1.001} % otf main node - \registerctxluafile{font-otd}{1.001} % otf dynamics (does an overload) - \registerctxluafile{font-otp}{1.001} % otf pack - \registerctxluafile{font-otc}{1.001} % otf context - \registerctxluafile{font-oth}{1.001} % otf helpers - \registerctxluafile{font-odv}{1.001} % otf devanagari (experimental) - -\else - - \registerctxluafile{font-otl}{1.001} % otf replacement - \registerctxluafile{font-oto}{1.001} % otb replacement - \registerctxluafile{font-otj}{1.001} % inj replacement - \registerctxluafile{font-oup}{1.001} % otp replacement - \registerctxluafile{font-ota}{1.001} - \registerctxluafile{font-ots}{1.001} % otn replacement - \registerctxluafile{font-otd}{1.001} - \registerctxluafile{font-otc}{1.001} - \registerctxluafile{font-oth}{1.001} - \registerctxluafile{font-osd}{1.001} % odv replacement - -\fi +\registerctxluafile{font-otl}{1.001} +\registerctxluafile{font-oto}{1.001} +\registerctxluafile{font-otj}{1.001} +\registerctxluafile{font-oup}{1.001} +\registerctxluafile{font-ota}{1.001} +\registerctxluafile{font-ots}{1.001} +\registerctxluafile{font-otd}{1.001} +\registerctxluafile{font-otc}{1.001} +\registerctxluafile{font-oth}{1.001} +\registerctxluafile{font-osd}{1.001} + +% so far \registerctxluafile{font-pat}{1.001} % patchers diff --git a/tex/context/base/mkiv/font-nod.lua b/tex/context/base/mkiv/font-nod.lua index e0e0ca377..7f30b6d5c 100644 --- a/tex/context/base/mkiv/font-nod.lua +++ b/tex/context/base/mkiv/font-nod.lua @@ -66,6 +66,7 @@ local getsubtype = nuts.getsubtype local getchar = nuts.getchar local getlist = nuts.getlist local getdisc = nuts.getdisc +local isglyph = nuts.isglyph local setfield = nuts.setfield local setbox = nuts.setbox @@ -117,14 +118,12 @@ function char_tracers.collect(head,list,tag,n) n = n or 0 local ok, fn = false, nil while head do - local id = getid(head) - if id == glyph_code then + local c, id = isglyph(head) + if c then local f = getfont(head) if f ~= fn then ok, fn = false, f end - local c = getchar(head) - -- local i = fontidentifiers[f].indices[c] or 0 -- zero anyway as indices is nilled if not ok then ok = true n = n + 1 @@ -360,13 +359,14 @@ function step_tracers.codes(i,command,space) local c = collection[i] local function showchar(c) + local f = getfont(c) + local c = getchar(c) if command then - local f, c = getfont(c), getchar(c) local d = fontdescriptions[f] local d = d and d[c] context[command](f,c,d and d.class or "") else - context("[%s:U+%05X]",getfont(c),getchar(c)) + context("[%s:U+%05X]",f,c) end end @@ -478,43 +478,40 @@ local threshold = 65536 local function toutf(list,result,nofresult,stopcriterium) if list then for n in traverse_nodes(tonut(list)) do - local id = getid(n) - if id == glyph_code then + local c, id = isglyph(n) + if c then local components = getfield(n,"components") if components then result, nofresult = toutf(components,result,nofresult) - else - local c = getchar(n) - if c > 0 then - local fc = fontcharacters[getfont(n)] - if fc then - local fcc = fc[c] - if fcc then - local u = fcc.unicode - if not u then - nofresult = nofresult + 1 - result[nofresult] = utfchar(c) - elseif type(u) == "table" then - for i=1,#u do - nofresult = nofresult + 1 - result[nofresult] = utfchar(u[i]) - end - else + elseif c > 0 then + local fc = fontcharacters[getfont(n)] + if fc then + local fcc = fc[c] + if fcc then + local u = fcc.unicode + if not u then + nofresult = nofresult + 1 + result[nofresult] = utfchar(c) + elseif type(u) == "table" then + for i=1,#u do nofresult = nofresult + 1 - result[nofresult] = utfchar(u) + result[nofresult] = utfchar(u[i]) end else nofresult = nofresult + 1 - result[nofresult] = utfchar(c) + result[nofresult] = utfchar(u) end else nofresult = nofresult + 1 - result[nofresult] = f_unicode(c) + result[nofresult] = utfchar(c) end else nofresult = nofresult + 1 - result[nofresult] = f_badcode(c) + result[nofresult] = f_unicode(c) end + else + nofresult = nofresult + 1 + result[nofresult] = f_badcode(c) end elseif id == disc_code then result, nofresult = toutf(getfield(n,"replace"),result,nofresult) -- needed? diff --git a/tex/context/base/mkiv/font-osd.lua b/tex/context/base/mkiv/font-osd.lua index 23579ea48..6ff2e38b6 100644 --- a/tex/context/base/mkiv/font-osd.lua +++ b/tex/context/base/mkiv/font-osd.lua @@ -6,6 +6,9 @@ if not modules then modules = { } end modules ['font-osd'] = { -- script devanag license = "see context related readme files" } +-- I'll optimize this one with ischar (much faster) when I see a reason (read: I need a +-- proper test case first). + -- This is a version of font-odv.lua adapted to the new font loader and more -- direct hashing. The initialization code has been adapted (more efficient). One day -- I'll speed this up ... char swapping and properties. @@ -53,6 +56,9 @@ if not modules then modules = { } end modules ['font-osd'] = { -- script devanag -- -- Some data will move to char-def.lua (some day). -- +-- By now we have yet another incremental improved version. In the end I might rewrite the +-- code. + -- Hans Hagen, PRAGMA-ADE, Hasselt NL -- -- We could have c_nukta, c_halant, c_ra is we know that they are never used mixed within @@ -61,34 +67,6 @@ if not modules then modules = { } end modules ['font-osd'] = { -- script devanag -- Matras: according to Microsoft typography specifications "up to one of each type: -- pre-, above-, below- or post- base", but that does not seem to be right. It could -- become an option. --- --- The next code looks weird anyway: the "and boolean" should move inside the if --- or we should check differently (case vs successive). --- --- local function ms_matra(c) --- local prebase, abovebase, belowbase, postbase = true, true, true, true --- local n = getnext(c) --- while n and getid(n) == glyph_code and getsubtype(n) < 256 and getfont(n) == font do --- local char = getchar(n) --- if not dependent_vowel[char] then --- break --- elseif pre_mark[char] and prebase then --- prebase = false --- elseif above_mark[char] and abovebase then --- abovebase = false --- elseif below_mark[char] and belowbase then --- belowbase = false --- elseif post_mark[char] and postbase then --- postbase = false --- else --- return c --- end --- c = getnext(c) --- end --- return c --- end - --- todo: first test for font then for subtype local insert, imerge, copy = table.insert, table.imerge, table.copy local next, type = next, type @@ -116,6 +94,7 @@ local tonut = nuts.tonut local getnext = nuts.getnext local getprev = nuts.getprev +local getboth = nuts.getboth local getid = nuts.getid local getchar = nuts.getchar local getfont = nuts.getfont @@ -127,6 +106,8 @@ local setchar = nuts.setchar local getprop = nuts.getprop local setprop = nuts.setprop +local ischar = nuts.is_char + local insert_node_after = nuts.insert_after local copy_node = nuts.copy local free_node = nuts.free @@ -481,7 +462,6 @@ local both_joiners_true = { } local sequence_reorder_matras = { - chain = 0, -- obsolete features = { dv01 = dev2_defaults }, flags = false_flags, name = "dv01_reorder_matras", @@ -497,7 +477,6 @@ local sequence_reorder_matras = { } local sequence_reorder_reph = { - chain = 0, -- obsolete features = { dv02 = dev2_defaults }, flags = false_flags, name = "dv02_reorder_reph", @@ -513,7 +492,6 @@ local sequence_reorder_reph = { } local sequence_reorder_pre_base_reordering_consonants = { - chain = 0, -- obsolete features = { dv03 = dev2_defaults }, flags = false_flags, name = "dv03_reorder_pre_base_reordering_consonants", @@ -529,7 +507,6 @@ local sequence_reorder_pre_base_reordering_consonants = { } local sequence_remove_joiners = { - chain = 0, -- obsolete features = { dv04 = deva_defaults }, flags = false_flags, name = "dv04_remove_joiners", @@ -799,7 +776,7 @@ local function deva_reorder(head,start,stop,font,attr,nbspaces) local lastcons = nil local basefound = false - if ra[getchar(start)] and halant[getchar(n)] and reph then + if reph and ra[getchar(start)] and halant[getchar(n)] then -- if syllable starts with Ra + H and script has 'Reph' then exclude Reph -- from candidates for base consonants if n == stop then @@ -871,7 +848,8 @@ local function deva_reorder(head,start,stop,font,attr,nbspaces) while not basefound do -- find base consonant - if consonant[getchar(current)] then + local char = getchar(current) + if consonant[char] then setprop(current,a_state,s_half) if not firstcons then firstcons = current @@ -879,7 +857,7 @@ local function deva_reorder(head,start,stop,font,attr,nbspaces) lastcons = current if not base then base = current - elseif blwfcache[getchar(current)] then + elseif blwfcache[char] then -- consonant has below-base (or post-base) form setprop(current,a_state,s_blwf) else @@ -893,12 +871,14 @@ local function deva_reorder(head,start,stop,font,attr,nbspaces) if base ~= lastcons then -- if base consonant is not last one then move halant from base consonant to last one local np = base - local n = getnext(base) - if nukta[getchar(n)] then + local n = getnext(base) + local ch = getchar(n) + if nukta[ch] then np = n - n = getnext(n) + n = getnext(n) + ch = getchar(n) end - if halant[getchar(n)] then + if halant[ch] then if lastcons ~= stop then local ln = getnext(lastcons) if nukta[getchar(ln)] then @@ -938,7 +918,6 @@ local function deva_reorder(head,start,stop,font,attr,nbspaces) local nn = getnext(n) local mn = getnext(matra) setlink(sp,nn) - setprev(nn,sp) setlink(matra,start) setlink(n,mn) if head == start then @@ -982,25 +961,30 @@ local function deva_reorder(head,start,stop,font,attr,nbspaces) local n = getnext(current) local l = nil -- used ? if c ~= stop then - if nukta[getchar(n)] then - c = n - n = getnext(n) + local ch = getchar(n) + if nukta[ch] then + c = n + n = getnext(n) + ch = getchar(n) end if c ~= stop then - if halant[getchar(n)] then - c = n - n = getnext(n) + if halant[ch] then + c = n + n = getnext(n) + ch = getchar(n) end - while c ~= stop and dependent_vowel[getchar(n)] do - c = n - n = getnext(n) + while c ~= stop and dependent_vowel[ch] do + c = n + n = getnext(n) + ch = getchar(n) end if c ~= stop then - if vowel_modifier[getchar(n)] then - c = n - n = getnext(n) + if vowel_modifier[ch] then + c = n + n = getnext(n) + ch = getchar(n) end - if c ~= stop and stress_tone_mark[getchar(n)] then + if c ~= stop and stress_tone_mark[ch] then c = n n = getnext(n) end @@ -1016,8 +1000,7 @@ local function deva_reorder(head,start,stop,font,attr,nbspaces) if bp then setnext(bp,cn) end - local next = getnext(cn) - local prev = getprev(cn) + local prev, next = getboth(cn) if next then setprev(next,prev) end @@ -1074,12 +1057,12 @@ local function deva_reorder(head,start,stop,font,attr,nbspaces) setlink(prev,n) local next = getnext(b) setlink(c,next) - setnext(c,next) setlink(b,current) end elseif cns and getnext(cns) ~= current then -- todo: optimize next -- position below-base Ra (vattu) following the consonants on which it is placed (either the base consonant or one of the pre-base consonants) - local cp, cnsn = getprev(current), getnext(cns) + local cp = getprev(current) + local cnsn = getnext(cns) setlink(cp,n) setlink(cns,current) setlink(c,cnsn) @@ -1132,20 +1115,26 @@ function handlers.devanagari_reorder_matras(head,start) -- no leak local current = start -- we could cache attributes here local startfont = getfont(start) local startattr = getprop(start,a_syllabe) - -- can be fast loop - while current and getid(current) == glyph_code and getsubtype(current) < 256 and getfont(current) == font and getprop(current,a_syllabe) == startattr do + while current do + local char = ischar(current,startfont) local next = getnext(current) - if halant[getchar(current)] and not getprop(current,a_state) then - if next and getid(next) == glyph_code and getsubtype(next) < 256 and getfont(next) == font and getprop(next,a_syllabe) == startattr and zw_char[getchar(next)] then - current = next + if char and getprop(current,a_syllabe) == startattr then + if halant[char] and not getprop(current,a_state) then + if next then + local char = ischar(next,startfont) + if char and zw_char[char] and getprop(next,a_syllabe) == startattr then + current = next + next = getnext(current) + end + end + -- can be optimzied + local startnext = getnext(start) + head = remove_node(head,start) + setlink(start,next) + setlink(current,start) + start = startnext + break end - local startnext = getnext(start) - head = remove_node(head,start) - local next = getnext(current) - setlink(start,next) - setlink(current,start) - start = startnext - break end current = next end @@ -1184,54 +1173,68 @@ function handlers.devanagari_reorder_reph(head,start) local startprev = nil local startfont = getfont(start) local startattr = getprop(start,a_syllabe) - while current and getid(current) == glyph_code and getsubtype(current) < 256 and getfont(current) == startfont and getprop(current,a_syllabe) == startattr do --step 2 - if halant[getchar(current)] and not getprop(current,a_state) then - local next = getnext(current) - if next and getid(next) == glyph_code and getsubtype(next) < 256 and getfont(next) == startfont and getprop(next,a_syllabe) == startattr and zw_char[getchar(next)] then - current = next + while current do + local char = ischar(current,font) + if char and getprop(current,a_syllabe) == startattr then -- step 2 + if halant[char] and not getprop(current,a_state) then + local next = getnext(current) + if next then + local nextchar = ischar(next,font) + if nextchar and zw_char[nextchar] and getprop(next,a_syllabe) == startattr then + current = next + next = getnext(current) + end + end + startnext = getnext(start) + head = remove_node(head,start) + setlink(start,next) + setlink(current,start) + start = startnext + startattr = getprop(start,a_syllabe) + break end - startnext = getnext(start) - head = remove_node(head,start) - local next = getnext(current) - setlink(start,next) - setlink(current,start) - start = startnext - startattr = getprop(start,a_syllabe) + current = getnext(current) + else break end - current = getnext(current) end if not startnext then current = getnext(start) - while current and getid(current) == glyph_code and getsubtype(current) < 256 and getfont(current) == startfont and getprop(current,a_syllabe) == startattr do --step 4 - if getprop(current,a_state) == s_pstf then --post-base - startnext = getnext(start) - head = remove_node(head,start) - local prev = getprev(current) - setlink(prev,start) - setlink(start,"next",current) - start = startnext - startattr = getprop(start,a_syllabe) + while current do + local char = ischar(current,font) + if char and getprop(current,a_syllabe) == startattr then -- step 4 + if getprop(current,a_state) == s_pstf then -- post-base + startnext = getnext(start) + head = remove_node(head,start) + local prev = getprev(current) + setlink(prev,start) + setlink(start,current) + start = startnext + startattr = getprop(start,a_syllabe) + break + end + current = getnext(current) + else break end - current = getnext(current) end end - -- ToDo: determine position for reph with reordering position other than 'before postscript' + -- todo: determine position for reph with reordering position other than 'before postscript' -- (required for scripts other than dev2) -- leaks if not startnext then current = getnext(start) local c = nil - while current and getid(current) == glyph_code and getsubtype(current) < 256 and getfont(current) == startfont and getprop(current,a_syllabe) == startattr do --step 5 - if not c then - local char = getchar(current) - -- todo: combine in one - if mark_above_below_post[char] and reorder_class[char] ~= "after subscript" then + while current do + local char = ischar(current,font) + if char and getprop(current,a_syllabe) == startattr then -- step 5 + if not c and mark_above_below_post[char] and reorder_class[char] ~= "after subscript" then c = current end + current = getnext(current) + else + break end - current = getnext(current) end -- here we can loose the old start node: maybe best split cases if c then @@ -1249,9 +1252,14 @@ function handlers.devanagari_reorder_reph(head,start) if not startnext then current = start local next = getnext(current) - while next and getid(next) == glyph_code and getsubtype(next) < 256 and getfont(next) == startfont and getprop(next,a_syllabe) == startattr do --step 6 - current = next - next = getnext(current) + while next do + local nextchar = ischar(next,font) + if nextchar and getprop(next,a_syllabe) == startattr then --step 6 + current = next + next = getnext(current) + else + break + end end if start ~= current then startnext = getnext(start) @@ -1278,56 +1286,96 @@ end -- UNTESTED: NOT CALLED IN EXAMPLE function handlers.devanagari_reorder_pre_base_reordering_consonants(head,start) - local current = start + local current = start local startnext = nil local startprev = nil local startfont = getfont(start) local startattr = getprop(start,a_syllabe) -- can be fast for loop + caching state - while current and getid(current) == glyph_code and getsubtype(current) < 256 and getfont(current) == startfont and getprop(current,a_syllabe) == startattr do - local next = getnext(current) - if halant[getchar(current)] and not getprop(current,a_state) then - if next and getid(next) == glyph_code and getsubtype(next) < 256 and getfont(next) == font and getprop(next,a_syllabe) == startattr then - local char = getchar(next) - if char == c_zwnj or char == c_zwj then - current = next + while current do + local char = ischar(current,font) + if char and getprop(current,a_syllabe) == startattr then + local next = getnext(current) + if halant[char] and not getprop(current,a_state) then + if next then + local nextchar = ischar(next,font) + if nextchar and getprop(next,a_syllabe) == startattr then + if nextchar == c_zwnj or nextchar == c_zwj then + current = next + next = getnext(current) + end + end end + startnext = getnext(start) + removenode(start,start) + setlink(start,next) + setlink(current,start) + start = startnext + break end - startnext = getnext(start) - removenode(start,start) - local next = getnext(current) - setlink(start,next) - setlink(current,start) - start = startnext + current = next + else break end - current = next end if not startnext then - current = getnext(start) + current = getnext(start) startattr = getprop(start,a_syllabe) - while current and getid(current) == glyph_code and getsubtype(current) < 256 and getfont(current) == startfont and getprop(current,a_syllabe) == startattr do - if not consonant[getchar(current)] and getprop(current,a_state) then --main - startnext = getnext(start) - removenode(start,start) - local prev = getprev(current) - setlink(prev,"next",start) - setlink(start,"next",current) - start = startnext + while current do + local char = ischar(current,font) + if char and getprop(current,a_syllabe) == startattr then + if not consonant[char] and getprop(current,a_state) then -- main + startnext = getnext(start) + removenode(start,start) + local prev = getprev(current) + setlink(start,prev) + setlink(start,current) + start = startnext + break + end + current = getnext(current) + else break end - current = getnext(current) end end return head, start, true end -function handlers.devanagari_remove_joiners(head,start) +-- function handlers.devanagari_remove_joiners(head,start,kind,lookupname,replacement) +-- local stop = getnext(start) +-- local font = getfont(start) +-- while stop do +-- local char = ischar(stop) +-- if char and (char == c_zwnj or char == c_zwj) then +-- stop = getnext(stop) +-- else +-- break +-- end +-- end +-- if stop then +-- setnext(getprev(stop)) +-- setprev(stop,getprev(start)) +-- end +-- local prev = getprev(start) +-- if prev then +-- setnext(prev,stop) +-- end +-- if head == start then +-- head = stop +-- end +-- flush_list(start) +-- return head, stop, true +-- end + +function handlers.devanagari_remove_joiners(head,start,kind,lookupname,replacement) local stop = getnext(start) - local startfont = getfont(start) - while stop and getid(stop) == glyph_code and getsubtype(stop) < 256 and getfont(stop) == startfont do - local char = getchar(stop) - if char == c_zwnj or char == c_zwj then + local font = getfont(start) + local last = start + while stop do + local char = ischar(stop,font) + if char and (char == c_zwnj or char == c_zwj) then + last = stop stop = getnext(stop) else break @@ -1335,9 +1383,11 @@ function handlers.devanagari_remove_joiners(head,start) end local prev = getprev(start) if stop then - setnext(getprev(stop)) + setnext(last) + setlink(prev,stop) + elseif prev then + setnext(prev) end - setlink(prev,stop) if head == start then head = stop end @@ -1624,16 +1674,16 @@ local function dev2_reorder(head,start,stop,font,attr,nbspaces) -- maybe do a pa local extra = copy_node(current) copyinjection(extra,current) char = tpm[1] - setchar(current,"char",char) - setchar(extra,"char",tpm[2]) + setchar(current,char) + setchar(extra,tpm[2]) head = insert_node_after(head,current,extra) end -- if not moved[current] and dependent_vowel[char] then if pre_mark[char] then -- Before first half form in the syllable moved[current] = true - local prev = getprev(current) - local next = getnext(current) + -- can be helper to remove one node + local prev, next = getboth(current) setlink(prev,next) if current == stop then stop = getprev(current) @@ -1747,47 +1797,59 @@ local function analyze_next_chars_one(c,font,variant) -- skip one dependent vowe return c end if variant == 1 then - local v = getid(n) == glyph_code and getsubtype(n) < 256 and getfont(n) == font - if v and nukta[getchar(n)] then + local v = ischar(n,font) + if v and nukta[v] then n = getnext(n) if n then - v = getid(n) == glyph_code and getsubtype(n) < 256 and getfont(n) == font + v = ischar(n,font) end end if n and v then local nn = getnext(n) - if nn and getid(nn) == glyph_code and getsubtype(nn) < 256 and getfont(nn) == font then - local nnn = getnext(nn) - if nnn and getid(nnn) == glyph_code and getsubtype(nnn) < 256 and getfont(nnn) == font then - local nnc = getchar(nn) - local nnnc = getchar(nnn) - if nnc == c_zwj and consonant[nnnc] then - c = nnn - elseif (nnc == c_zwnj or nnc == c_zwj) and halant[nnnc] then - local nnnn = getnext(nnn) - if nnnn and getid(nnnn) == glyph_code and consonant[getchar(nnnn)] and getsubtype(nnnn) < 256 and getfont(nnnn) == font then - c = nnnn + if nn then + local vv = ischar(nn,font) + if vv then + local nnn = getnext(nn) + if nnn then + local vvv = ischar(nnn,font) + if vvv then + if vv == c_zwj and consonant[vvv] then + c = nnn + elseif (vv == c_zwnj or vv == c_zwj) and halant[vvv] then + local nnnn = getnext(nnn) + if nnnn then + local vvvv = ischar(nnnn) + if vvvv and consonant[vvvv] then + c = nnnn + end + end + end end end end end end elseif variant == 2 then - if getid(n) == glyph_code and nukta[getchar(n)] and getsubtype(n) < 256 and getfont(n) == font then + local v = ischar(n,font) + if v and nukta[v] then c = n end n = getnext(c) - if n and getid(n) == glyph_code and getsubtype(n) < 256 and getfont(n) == font then - local nn = getnext(n) - if nn then - local nv = getid(nn) == glyph_code and getsubtype(nn) < 256 and getfont(nn) == font - if nv and zw_char[getchar(n)] then - n = nn - nn = getnext(nn) - nv = nn and getid(nn) == glyph_code and getsubtype(nn) < 256 and getfont(nn) == font - end - if nv and halant[getchar(n)] and consonant[getchar(nn)] then - c = nn + if n then + v = ischar(n,font) + if v then + local nn = getnext(n) + if nn then + local vv = ischar(nn,font) + if vv and zw_char[vv] then + n = nn + v = vv + nn = getnext(nn) + vv = nn and ischar(nn,font) + end + if vv and halant[v] and consonant[vv] then + c = nn + end end end end @@ -1797,72 +1859,66 @@ local function analyze_next_chars_one(c,font,variant) -- skip one dependent vowe if not n then return c end - local v = getid(n) == glyph_code and getsubtype(n) < 256 and getfont(n) == font + local v = ischar(n,font) if not v then return c end - local char = getchar(n) - if dependent_vowel[char] then + if dependent_vowel[v] then c = getnext(c) n = getnext(c) if not n then return c end - v = getid(n) == glyph_code and getsubtype(n) < 256 and getfont(n) == font + v = ischar(n,font) if not v then return c end - char = getchar(n) end - if nukta[char] then + if nukta[v] then c = getnext(c) n = getnext(c) if not n then return c end - v = getid(n) == glyph_code and getsubtype(n) < 256 and getfont(n) == font + v = ischar(n,font) if not v then return c end - char = getchar(n) end - if halant[char] then + if halant[v] then c = getnext(c) n = getnext(c) if not n then return c end - v = getid(n) == glyph_code and getsubtype(n) < 256 and getfont(n) == font + v = ischar(n,font) if not v then return c end - char = getchar(n) end - if vowel_modifier[char] then + if vowel_modifier[v] then c = getnext(c) n = getnext(c) if not n then return c end - v = getid(n) == glyph_code and getsubtype(n) < 256 and getfont(n) == font + v = ischar(n,font) if not v then return c end - char = getchar(n) end - if stress_tone_mark[char] then + if stress_tone_mark[v] then c = getnext(c) n = getnext(c) if not n then return c end - v = getid(n) == glyph_code and getsubtype(n) < 256 and getfont(n) == font + v = ischar(n,font) if not v then return c end - char = getchar(n) end - if stress_tone_mark[char] then + if stress_tone_mark[v] then return n else return c @@ -1874,37 +1930,56 @@ local function analyze_next_chars_two(c,font) if not n then return c end - if getid(n) == glyph_code and nukta[getchar(n)] and getsubtype(n) < 256 and getfont(n) == font then + local v = ischar(n,font) + if v and nukta[v] then c = n end n = c while true do local nn = getnext(n) - if nn and getid(nn) == glyph_code and getsubtype(nn) < 256 and getfont(nn) == font then - local char = getchar(nn) - if halant[char] then - n = nn - local nnn = getnext(nn) - if nnn and getid(nnn) == glyph_code and zw_char[getchar(nnn)] and getsubtype(nnn) < 256 and getfont(nnn) == font then - n = nnn - end - elseif char == c_zwnj or char == c_zwj then - -- n = nn -- not here (?) - local nnn = getnext(nn) - if nnn and getid(nnn) == glyph_code and halant[getchar(nnn)] and getsubtype(nnn) < 256 and getfont(nnn) == font then - n = nnn + if nn then + local vv = ischar(nn,font) + if vv then + if halant[vv] then + n = nn + local nnn = getnext(nn) + if nnn then + local vvv = ischar(nnn,font) + if vvv and zw_char[vvv] then + n = nnn + end + end + elseif vv == c_zwnj or vv == c_zwj then + -- n = nn -- not here (?) + local nnn = getnext(nn) + if nnn then + local vvv = ischar(nnn,font) + if vvv and halant[vvv] then + n = nnn + end + end + else + break end - else - break - end - local nn = getnext(n) - if nn and getid(nn) == glyph_code and consonant[getchar(nn)] and getsubtype(nn) < 256 and getfont(nn) == font then - n = nn - local nnn = getnext(nn) - if nnn and getid(nnn) == glyph_code and nukta[getchar(nnn)] and getsubtype(nnn) < 256 and getfont(nnn) == font then - n = nnn + local nn = getnext(n) + if nn then + local vv = ischar(nn,font) + if vv and consonant[vv] then + n = nn + local nnn = getnext(nn) + if nnn then + local vvv = ischar(nnn,font) + if vvv and nukta[vvv] then + n = nnn + end + end + c = n + else + break + end + else + break end - c = n else break end @@ -1921,112 +1996,103 @@ local function analyze_next_chars_two(c,font) if not n then return c end - local v = getid(n) == glyph_code and getsubtype(n) < 256 and getfont(n) == font + local v = ischar(n,font) if not v then return c end - local char = getchar(n) - if char == c_anudatta then + if v == c_anudatta then c = n n = getnext(c) if not n then return c end - v = getid(n) == glyph_code and getsubtype(n) < 256 and getfont(n) == font + v = ischar(n,font) if not v then return c end - char = getchar(n) end - if halant[char] then - c = getnext(c) + if halant[v] then + c = n n = getnext(c) if not n then return c end - v = getid(n) == glyph_code and getsubtype(n) < 256 and getfont(n) == font + v = ischar(n,font) if not v then return c end - char = getchar(n) - if char == c_zwnj or char == c_zwj then - c = getnext(c) + if v == c_zwnj or v == c_zwj then + c = n n = getnext(c) if not n then return c end - v = getid(n) == glyph_code and getsubtype(n) < 256 and getfont(n) == font + v = ischar(n,font) if not v then return c end - char = getchar(n) end else -- c = ms_matra(c) -- same as one - if dependent_vowel[char] then - c = getnext(c) + if dependent_vowel[v] then + c = n n = getnext(c) if not n then return c end - v = getid(n) == glyph_code and getsubtype(n) < 256 and getfont(n) == font + v = ischar(n,font) if not v then return c end - char = getchar(n) end - if nukta[char] then - c = getnext(c) + if nukta[v] then + c = n n = getnext(c) if not n then return c end - v = getid(n) == glyph_code and getsubtype(n) < 256 and getfont(n) == font + v = ischar(n,font) if not v then return c end - char = getchar(n) end - if halant[char] then - c = getnext(c) + if halant[v] then + c = n n = getnext(c) if not n then return c end - v = getid(n) == glyph_code and getsubtype(n) < 256 and getfont(n) == font + v = ischar(n,font) if not v then return c end - char = getchar(n) end end -- same as one - if vowel_modifier[char] then - c = getnext(c) + if vowel_modifier[v] then + c = n n = getnext(c) if not n then return c end - v = getid(n) == glyph_code and getsubtype(n) < 256 and getfont(n) == font + v = ischar(n,font) if not v then return c end - char = getchar(n) end - if stress_tone_mark[char] then - c = getnext(c) + if stress_tone_mark[v] then + c = n n = getnext(c) if not n then return c end - v = getid(n) == glyph_code and getsubtype(n) < 256 and getfont(n) == font + v = ischar(n,font) if not v then return c end - char = getchar(n) end - if stress_tone_mark[char] then + if stress_tone_mark[v] then return n else return c @@ -2054,29 +2120,41 @@ function methods.deva(head,font,attr) local done = false local nbspaces = 0 while current do - if getid(current) == glyph_code and getsubtype(current) < 256 and getfont(current) == font then + local char = ischar(current,font) + if char then done = true local syllablestart = current - local syllableend = nil + local syllableend = nil local c = current local n = getnext(c) - if n and ra[getchar(c)] and getid(n) == glyph_code and halant[getchar(n)] and getsubtype(n) < 256 and getfont(n) == font then - local n = getnext(n) - if n and getid(n) == glyph_code and getsubtype(n) < 256 and getfont(n) == font then - c = n + local first = char + if n and ra[first] then + local second = ischar(n,font) + if second and halant[second] then + local n = getnext(n) + if n then + local third = ischar(n,font) + if third then + c = n + first = third + end + end end end - local standalone = getchar(c) == c_nbsp + local standalone = first == c_nbsp if standalone then local prev = getprev(current) - if not prev then - -- begin of paragraph or box - elseif getid(prev) ~= glyph_code or getsubtype(prev) >= 256 or getfont(prev) ~= font then - -- different font or language so quite certainly a different word - elseif not separator[getchar(prev)] then - -- something that separates words + if prev then + local prevchar = ischar(prev,font) + if not prevchar then + -- different font or language so quite certainly a different word + elseif not separator[prevchar] then + -- something that separates words + else + standalone = false + end else - standalone = false + -- begin of paragraph or box end end if standalone then @@ -2091,7 +2169,6 @@ function methods.deva(head,font,attr) -- we can delay the getsubtype(n) and getfont(n) and test for say halant first -- as an table access is faster than two function calls (subtype and font are -- pseudo fields) but the code becomes messy (unless we make it a function) - local char = getchar(current) if consonant[char] then -- syllable containing consonant local prevc = true @@ -2101,64 +2178,66 @@ function methods.deva(head,font,attr) if not n then break end - local v = getid(n) == glyph_code and getsubtype(n) < 256 and getfont(n) == font + local v = ischar(n,font) if not v then break end - local c = getchar(n) - if nukta[c] then + if nukta[v] then n = getnext(n) if not n then break end - v = getid(n) == glyph_code and getsubtype(n) < 256 and getfont(n) == font + v = ischar(n,font) if not v then break end - c = getchar(n) end - if halant[c] then + if halant[v] then n = getnext(n) if not n then break end - v = getid(n) == glyph_code and getsubtype(n) < 256 and getfont(n) == font + v = ischar(n,font) if not v then break end - c = getchar(n) - if c == c_zwnj or c == c_zwj then + if v == c_zwnj or v == c_zwj then n = getnext(n) if not n then break end - v = getid(n) == glyph_code and getsubtype(n) < 256 and getfont(n) == font + v = ischar(n,font) if not v then break end - c = getchar(n) end - if consonant[c] then + if consonant[v] then prevc = true current = n end end end local n = getnext(current) - if n and getid(n) == glyph_code and nukta[getchar(n)] and getsubtype(n) < 256 and getfont(n) == font then - -- nukta (not specified in Microsft Devanagari OpenType specification) - current = n - n = getnext(current) + if n then + local v = ischar(n,font) + if v and nukta[v] then + -- nukta (not specified in Microsft Devanagari OpenType specification) + current = n + n = getnext(current) + end end syllableend = current current = n if current then - local v = getid(current) == glyph_code and getsubtype(current) < 256 and getfont(current) == font - if v then - if halant[getchar(current)] then - -- syllable containing consonant without vowels: {C + [Nukta] + H} + C + H - local n = getnext(current) - if n and getid(n) == glyph_code and zw_char[getchar(n)] and getsubtype(n) < 256 and getfont(n) == font then + local v = ischar(current,font) + if not v then + -- skip + elseif halant[v] then + -- syllable containing consonant without vowels: {C + [Nukta] + H} + C + H + local n = getnext(current) + if n then + local v = ischar(n,font) + if v and zw_char[v] then -- code collapsed, probably needs checking with intention syllableend = n current = getnext(n) @@ -2167,28 +2246,24 @@ function methods.deva(head,font,attr) current = n end else - -- syllable containing consonant with vowels: {C + [Nukta] + H} + C + [M] + [VM] + [SM] - local c = getchar(current) - if dependent_vowel[c] then - syllableend = current - current = getnext(current) - v = current and getid(current) == glyph_code and getsubtype(current) < 256 and getfont(current) == font - if v then - c = getchar(current) - end - end - if v and vowel_modifier[c] then - syllableend = current - current = getnext(current) - v = current and getid(current) == glyph_code and getsubtype(current) < 256 and getfont(current) == font - if v then - c = getchar(current) - end - end - if v and stress_tone_mark[c] then - syllableend = current - current = getnext(current) - end + syllableend = current + current = n + end + else + -- syllable containing consonant with vowels: {C + [Nukta] + H} + C + [M] + [VM] + [SM] + if dependent_vowel[v] then + syllableend = current + current = getnext(current) + v = ischar(current,font) + end + if v and vowel_modifier[v] then + syllableend = current + current = getnext(current) + v = ischar(current,font) + end + if v and stress_tone_mark[v] then + syllableend = current + current = getnext(current) end end end @@ -2201,18 +2276,14 @@ function methods.deva(head,font,attr) syllableend = current current = getnext(current) if current then - local v = getid(current) == glyph_code and getsubtype(current) < 256 and getfont(current) == font + local v = ischar(current,font) if v then - local c = getchar(current) - if vowel_modifier[c] then + if vowel_modifier[v] then syllableend = current current = getnext(current) - v = current and getid(current) == glyph_code and getsubtype(current) < 256 and getfont(current) == font - if v then - c = getchar(current) - end + v = ischar(current,font) end - if v and stress_tone_mark[c] then + if v and stress_tone_mark[v] then syllableend = current current = getnext(current) end @@ -2252,19 +2323,27 @@ function methods.dev2(head,font,attr) local syllabe = 0 local nbspaces = 0 while current do - local syllablestart, syllableend = nil, nil - if getid(current) == glyph_code and getsubtype(current) < 256 and getfont(current) == font then + local syllablestart = nil + local syllableend = nil + local char = ischar(current,font) + if char then done = true syllablestart = current local c = current local n = getnext(current) - if n and ra[getchar(c)] and getid(n) == glyph_code and halant[getchar(n)] and getsubtype(n) < 256 and getfont(n) == font then - local n = getnext(n) - if n and getid(n) == glyph_code and getsubtype(n) < 256 and getfont(n) == font then - c = n + if n and ra[char] then + local nextchar = ischar(n,font) + if nextchar and halant[nextchar] then + local n = getnext(n) + if n then + local nextnextchar = ischar(n,font) + if nextnextchar then + c = n + char = nextnextchar + end + end end end - local char = getchar(c) if independent_vowel[char] then -- vowel-based syllable: [Ra+H]+V+[N]+[<[<ZWJ|ZWNJ>]+H+C|ZWJ+C>]+[{M}+[N]+[H]]+[SM]+[(VD)] current = analyze_next_chars_one(c,font,1) @@ -2276,7 +2355,7 @@ function methods.dev2(head,font,attr) local p = getprev(current) if not p then -- begin of paragraph or box - elseif getid(p) ~= glyph_code or getsubtype(p) >= 256 or getfont(p) ~= font then + elseif ischar(p,font) then -- different font or language so quite certainly a different word elseif not separator[getchar(p)] then -- something that separates words @@ -2309,10 +2388,13 @@ function methods.dev2(head,font,attr) if syllableend and syllablestart ~= syllableend then head, current, nbspaces = dev2_reorder(head,syllablestart,syllableend,font,attr,nbspaces) end - if not syllableend and getid(current) == glyph_code and getsubtype(current) < 256 and getfont(current) == font and not getprop(current,a_state) then - local mark = mark_four[getchar(current)] - if mark then - head, current = inject_syntax_error(head,current,mark) + if not syllableend then + local char = ischar(current,font) + if char and not getprop(current,a_state) then + local mark = mark_four[char] + if mark then + head, current = inject_syntax_error(head,current,mark) + end end end start = false diff --git a/tex/context/base/mkiv/font-ota.lua b/tex/context/base/mkiv/font-ota.lua index 08f69f92a..6a3804a74 100644 --- a/tex/context/base/mkiv/font-ota.lua +++ b/tex/context/base/mkiv/font-ota.lua @@ -35,19 +35,20 @@ local tonut = nuts.tonut local getfield = nuts.getfield local getnext = nuts.getnext local getprev = nuts.getprev -local getid = nuts.getid +local getprev = nuts.getprev local getprop = nuts.getprop local setprop = nuts.setprop local getfont = nuts.getfont local getsubtype = nuts.getsubtype local getchar = nuts.getchar +local ischar = nuts.is_char local traverse_id = nuts.traverse_id local traverse_node_list = nuts.traverse local end_of_math = nuts.end_of_math local nodecodes = nodes.nodecodes -local glyph_code = nodecodes.glyph +----- glyph_code = nodecodes.glyph local disc_code = nodecodes.disc local math_code = nodecodes.math @@ -75,7 +76,10 @@ local s_rest = 6 local states = { init = s_init, medi = s_medi, + med2 = s_medi, fina = s_fina, + fin2 = s_fina, + fin3 = s_fina, isol = s_isol, mark = s_mark, rest = s_rest, @@ -89,7 +93,10 @@ local states = { local features = { init = s_init, medi = s_medi, + med2 = s_medi, fina = s_fina, + fin2 = s_fina, + fin3 = s_fina, isol = s_isol, -- mark = s_mark, -- rest = s_rest, @@ -114,10 +121,9 @@ function analyzers.setstate(head,font) local first, last, current, n, done = nil, nil, head, 0, false -- maybe make n boolean current = tonut(current) while current do - local id = getid(current) - if id == glyph_code and getfont(current) == font then + local char, id = ischar(current,font) + if char and not getprop(current,a_state) then done = true - local char = getchar(current) local d = descriptions[char] if d then if d.class == "mark" then @@ -141,6 +147,17 @@ function analyzers.setstate(head,font) end first, last, n = nil, nil, 0 end + elseif char == false then + -- other font + if first and first == last then + setprop(last,a_state,s_isol) + elseif last then + setprop(last,a_state,s_fina) + end + first, last, n = nil, nil, 0 + if id == math_code then + current = end_of_math(current) + end elseif id == disc_code then -- always in the middle .. it doesn't make much sense to assign a property -- here ... we might at some point decide to flag the components when present @@ -240,38 +257,43 @@ local mappers = { u = s_isol, -- nonjoiner } -local classifiers = { } -- we can also use this trick for devanagari - -local first_arabic, last_arabic = characters.blockrange("arabic") -local first_syriac, last_syriac = characters.blockrange("syriac") -local first_mandiac, last_mandiac = characters.blockrange("mandiac") -local first_nko, last_nko = characters.blockrange("nko") - -table.setmetatableindex(classifiers,function(t,k) - local c = chardata[k] - local v = false - if c then - local arabic = c.arabic - if arabic then - v = mappers[arabic] - if not v then - log.report("analyze","error in mapping arabic %C",k) - -- error - v = false - end - elseif k >= first_arabic and k <= last_arabic or k >= first_syriac and k <= last_syriac or - k >= first_mandiac and k <= last_mandiac or k >= first_nko and k <= last_nko then - if categories[k] == "mn" then - v = s_mark - else - v = s_rest +-- we can also use this trick for devanagari + +local classifiers = characters.classifiers + +if not classifiers then + + local first_arabic, last_arabic = characters.blockrange("arabic") + local first_syriac, last_syriac = characters.blockrange("syriac") + local first_mandiac, last_mandiac = characters.blockrange("mandiac") + local first_nko, last_nko = characters.blockrange("nko") + + classifiers = table.setmetatableindex(function(t,k) + local c = chardata[k] + local v = false + if c then + local arabic = c.arabic + if arabic then + v = mappers[arabic] + if not v then + log.report("analyze","error in mapping arabic %C",k) + -- error + v = false + end + elseif k >= first_arabic and k <= last_arabic or k >= first_syriac and k <= last_syriac or + k >= first_mandiac and k <= last_mandiac or k >= first_nko and k <= last_nko then + if categories[k] == "mn" then + v = s_mark + else + v = s_rest + end end - else end - end - t[k] = v - return v -end) + t[k] = v + return v + end) + +end function methods.arab(head,font,attr) local first, last = nil, nil @@ -279,10 +301,9 @@ function methods.arab(head,font,attr) local current, done = head, false current = tonut(current) while current do - local id = getid(current) - if id == glyph_code and getfont(current) == font and getsubtype(current)<256 and not getprop(current,a_state) then + local char, id = ischar(current,font) + if char and not getprop(current,a_state) then done = true - local char = getchar(current) local classifier = classifiers[char] if not classifier then if last then diff --git a/tex/context/base/mkiv/font-otj.lua b/tex/context/base/mkiv/font-otj.lua index 678afa64c..aae70d1f3 100644 --- a/tex/context/base/mkiv/font-otj.lua +++ b/tex/context/base/mkiv/font-otj.lua @@ -30,20 +30,27 @@ local next, rawget = next, rawget local utfchar = utf.char local fastcopy = table.fastcopy -local trace_injections = false trackers.register("fonts.injections", function(v) trace_injections = v end) -local trace_marks = false trackers.register("fonts.injections.marks", function(v) trace_marks = v end) -local trace_cursive = false trackers.register("fonts.injections.cursive", function(v) trace_cursive = v end) +local registertracker = trackers.register + +local trace_injections = false registertracker("fonts.injections", function(v) trace_injections = v end) +local trace_marks = false registertracker("fonts.injections.marks", function(v) trace_marks = v end) +local trace_cursive = false registertracker("fonts.injections.cursive", function(v) trace_cursive = v end) +local trace_spaces = false registertracker("otf.spaces", function(v) trace_spaces = v end) -- use_advance is just an experiment: it makes copying glyphs (instead of new_glyph) dangerous local use_advance = false directives.register("fonts.injections.advance", function(v) use_advance = v end) local report_injections = logs.reporter("fonts","injections") +local report_spaces = logs.reporter("fonts","spaces") local attributes, nodes, node = attributes, nodes, node fonts = fonts -local fontdata = fonts.hashes.identifiers +local hashes = fonts.hashes +local fontdata = hashes.identifiers +local parameters = fonts.hashes.parameters +local resources = fonts.hashes.resources nodes.injections = nodes.injections or { } local injections = nodes.injections @@ -56,6 +63,7 @@ local nodecodes = nodes.nodecodes local glyph_code = nodecodes.glyph local disc_code = nodecodes.disc local kern_code = nodecodes.kern +local glue_code = nodecodes.glue local nuts = nodes.nuts local nodepool = nuts.pool @@ -73,6 +81,9 @@ local getid = nuts.getid local getfont = nuts.getfont local getsubtype = nuts.getsubtype local getchar = nuts.getchar +local getboth = nuts.getboth + +local ischar = nuts.is_char local getdisc = nuts.getdisc local setdisc = nuts.setdisc @@ -539,14 +550,17 @@ local function inject_kerns_only(head,where) if trace_injections then trace(head,"kerns") end - local current = head - local prev = nil - local next = nil - local prevdisc = nil - local prevglyph = nil - local pre = nil -- saves a lookup - local post = nil -- saves a lookup - local replace = nil -- saves a lookup + local current = head + local prev = nil + local next = nil + local prevdisc = nil + local prevglyph = nil + local pre = nil -- saves a lookup + local post = nil -- saves a lookup + local replace = nil -- saves a lookup + local pretail = nil -- saves a lookup + local posttail = nil -- saves a lookup + local replacetail = nil -- saves a lookup while current do local id = getid(current) local next = getnext(current) @@ -576,7 +590,6 @@ local function inject_kerns_only(head,where) if i then local leftkern = i.leftkern if leftkern and leftkern ~= 0 then - local posttail = find_tail(post) if use_advance then setfield(post,"xadvance",leftkern) else @@ -592,7 +605,6 @@ local function inject_kerns_only(head,where) if i then local leftkern = i.leftkern if leftkern and leftkern ~= 0 then - local replacetail = find_tail(replace) if use_advance then setfield(replace,"xadvance",leftkern) else @@ -601,6 +613,16 @@ local function inject_kerns_only(head,where) end end end + else + -- local i = rawget(p,"emptyinjections") + local i = p.emptyinjections + if i then + -- glyph|disc|glyph (special case) + local leftkern = i.leftkern + if leftkern and leftkern ~= 0 then + setfield(prev,"replace",newkern(leftkern)) -- maybe also leftkern + end + end end if done then setdisc(prevdisc,pre,post,replace) @@ -611,7 +633,7 @@ local function inject_kerns_only(head,where) prevdisc = nil prevglyph = current elseif id == disc_code then - pre, post, replace = getdisc(current) + pre, post, replace, pretail, posttail, replacetail = getdisc(current,true) local done = false if pre then -- left|pre glyphs|right @@ -705,14 +727,17 @@ local function inject_pairs_only(head,where) if trace_injections then trace(head,"pairs") end - local current = head - local prev = nil - local next = nil - local prevdisc = nil - local prevglyph = nil - local pre = nil -- saves a lookup - local post = nil -- saves a lookup - local replace = nil -- saves a lookup + local current = head + local prev = nil + local next = nil + local prevdisc = nil + local prevglyph = nil + local pre = nil -- saves a lookup + local post = nil -- saves a lookup + local replace = nil -- saves a lookup + local pretail = nil -- saves a lookup + local posttail = nil -- saves a lookup + local replacetail = nil -- saves a lookup while current do local id = getid(current) local next = getnext(current) @@ -741,10 +766,10 @@ local function inject_pairs_only(head,where) local i = p.emptyinjections if i then -- glyph|disc|glyph (special case) +-- is this okay? local rightkern = i.rightkern if rightkern and rightkern ~= 0 then if next and getid(next) == disc_code then - local replace = getfield(next,"replace") if replace then -- error, we expect an empty one else @@ -754,7 +779,7 @@ local function inject_pairs_only(head,where) end end end - if prevdisc and p then + if prevdisc then local done = false if post then -- local i = rawget(p,"postinjections") @@ -762,7 +787,6 @@ local function inject_pairs_only(head,where) if i then local leftkern = i.leftkern if leftkern and leftkern ~= 0 then - local posttail = find_tail(post) insert_node_after(post,posttail,newkern(leftkern)) done = true end @@ -774,11 +798,19 @@ local function inject_pairs_only(head,where) if i then local leftkern = i.leftkern if leftkern and leftkern ~= 0 then - local replacetail = find_tail(replace) insert_node_after(replace,replacetail,newkern(leftkern)) done = true end end + else + local i = p.emptyinjections + if i then +-- new .. okay? + local leftkern = i.leftkern + if leftkern and leftkern ~= 0 then + setfield(prev,"replace",newkern(leftkern)) -- maybe also leftkern + end + end end if done then setdisc(prevdisc,pre,post,replace) @@ -789,7 +821,7 @@ local function inject_pairs_only(head,where) prevdisc = nil prevglyph = current elseif id == disc_code then - pre, post, replace = getdisc(current) + pre, post, replace, pretail, posttail, replacetail = getdisc(current,true) local done = false if pre then -- left|pre glyphs|right @@ -957,20 +989,23 @@ local function inject_everything(head,where) if trace_injections then trace(head,"everything") end - local hascursives = nofregisteredcursives > 0 - local hasmarks = nofregisteredmarks > 0 + local hascursives = nofregisteredcursives > 0 + local hasmarks = nofregisteredmarks > 0 -- - local current = head - local last = nil - local font = font - local markdata = nil - local prev = nil - local next = nil - local prevdisc = nil - local prevglyph = nil - local pre = nil -- saves a lookup - local post = nil -- saves a lookup - local replace = nil -- saves a lookup + local current = head + local last = nil + local font = font + local markdata = nil + local prev = nil + local next = nil + local prevdisc = nil + local prevglyph = nil + local pre = nil -- saves a lookup + local post = nil -- saves a lookup + local replace = nil -- saves a lookup + local pretail = nil -- saves a lookup + local posttail = nil -- saves a lookup + local replacetail = nil -- saves a lookup -- local cursiveanchor = nil local minc = 0 @@ -1127,10 +1162,10 @@ local function inject_everything(head,where) local i = p.emptyinjections if i then -- glyph|disc|glyph (special case) +-- okay? local rightkern = i.rightkern if rightkern and rightkern ~= 0 then if next and getid(next) == disc_code then - local replace = getfield(next,"replace") if replace then -- error, we expect an empty one else @@ -1149,7 +1184,6 @@ local function inject_everything(head,where) if i then local leftkern = i.leftkern if leftkern and leftkern ~= 0 then - local posttail = find_tail(post) insert_node_after(post,posttail,newkern(leftkern)) done = true end @@ -1161,11 +1195,17 @@ local function inject_everything(head,where) if i then local leftkern = i.leftkern if leftkern and leftkern ~= 0 then - local replacetail = find_tail(replace) insert_node_after(replace,replacetail,newkern(leftkern)) done = true end end + else + -- local i = rawget(p,"emptyinjections") + local i = p.emptyinjections + local leftkern = i.leftkern + if leftkern and leftkern ~= 0 then + setfield(prev,"replace",newkern(leftkern)) -- maybe also leftkern + end end if done then setdisc(prevdisc,pre,post,replace) @@ -1189,7 +1229,7 @@ local function inject_everything(head,where) prevdisc = nil prevglyph = current elseif id == disc_code then - pre, post, replace = getdisc(current) + pre, post, replace, pretail, posttail, replacetail = getdisc(current,true) local done = false if pre then -- left|pre glyphs|right @@ -1368,7 +1408,118 @@ local function inject_everything(head,where) return tonode(head), true end +-- space triggers + +local triggers = false + +function nodes.injections.setspacekerns(font,sequence) + if triggers then + triggers[font] = sequence + else + triggers = { [font] = sequence } + end +end + +local function injectspaces(head) + + if not triggers then + return head, false + end + + local lastfont = nil + local spacekerns = nil + local leftkerns = nil + local rightkerns = nil + local factor = 0 + local threshold = 0 + local leftkern = false + local rightkern = false + + local function updatefont(font,trig) + -- local resources = resources[font] + -- local spacekerns = resources.spacekerns + -- if spacekerns then + -- leftkerns = spacekerns.left + -- rightkerns = spacekerns.right + -- end + leftkerns = trig.left + rightkerns = trig.right + local par = parameters[font] + factor = par.factor + threshold = par.spacing.width - 1 -- get rid of rounding errors + lastfont = font + end + + for n in traverse_id(glue_code,tonut(head)) do + local prev, next = getboth(n) + local prevchar = ischar(prev) + local nextchar = ischar(next) + if nextchar then + local font = getfont(next) + local trig = triggers[font] + if trig then + if lastfont ~= font then + updatefont(font,trig) + end + if rightkerns then + rightkern = rightkerns[nextchar] + end + end + end + if prevchar then + local font = getfont(next) + local trig = triggers[font] + if trig then + if lastfont ~= font then + updatefont(font,trig) + end + if leftkerns then + leftkern = leftkerns[prevchar] + end + end + end + if leftkern then + local old = getfield(n,"width") + if old >= threshold then + if rightkern then + local new = old + (leftkern + rightkern) * factor + if trace_spaces then + report_spaces("%C [%p -> %p] %C",prevchar,old,new,nextchar) + end + setfield(n,"width",new) + leftkern = false + else + local new = old + leftkern * factor + if trace_spaces then + report_spaces("%C [%p -> %p]",prevchar,old,new) + end + setfield(n,"width",new) + end + end + leftkern = false + elseif rightkern then + local old = getfield(n,"width") + if old >= threshold then + local new = old + rightkern * factor + if trace_spaces then + report_spaces("[%p -> %p] %C",nextchar,old,new) + end + setfield(n,"width",new) + end + rightkern = false + end + end + + triggers = false + return head, true +end + +-- + function injections.handler(head,where) + if triggers then + head = injectspaces(head) + end if nofregisteredmarks > 0 or nofregisteredcursives > 0 then return inject_everything(head,where) elseif nofregisteredpairs > 0 then diff --git a/tex/context/base/mkiv/font-otl.lua b/tex/context/base/mkiv/font-otl.lua index 99aae33b5..0deb4bce0 100644 --- a/tex/context/base/mkiv/font-otl.lua +++ b/tex/context/base/mkiv/font-otl.lua @@ -53,7 +53,7 @@ local report_otf = logs.reporter("fonts","otf loading") local fonts = fonts local otf = fonts.handlers.otf -otf.version = 3.015 -- beware: also sync font-mis.lua and in mtx-fonts +otf.version = 3.016 -- beware: also sync font-mis.lua and in mtx-fonts otf.cache = containers.define("fonts", "otl", otf.version, true) local otfreaders = otf.readers @@ -267,6 +267,7 @@ function otf.load(filename,sub,featurefile) -- second argument (format) is gone otfreaders.compact(data) otfreaders.rehash(data,"unicodes") otfreaders.addunicodetable(data) + otfreaders.extend(data) otfreaders.pack(data) report_otf("loading done") report_otf("saving %a in cache",filename) diff --git a/tex/context/base/mkiv/font-otr.lua b/tex/context/base/mkiv/font-otr.lua index 5839cbfb5..1fc338b38 100644 --- a/tex/context/base/mkiv/font-otr.lua +++ b/tex/context/base/mkiv/font-otr.lua @@ -2122,6 +2122,25 @@ function readers.compact(fontdata) report("the %a helper is not yet implemented","compact") end +-- plug in + +local extenders = { } + +function readers.registerextender(extender) + extenders[#extenders+1] = extender +end + +function readers.extend(fontdata) + for i=1,#extenders do + local extender = extenders[i] + local name = extender.name or "unknown" + local action = extender.action + if action then + action(fontdata) + end + end +end + -- if fonts.hashes then diff --git a/tex/context/base/mkiv/font-ots.lua b/tex/context/base/mkiv/font-ots.lua index e2cccebe8..15de12867 100644 --- a/tex/context/base/mkiv/font-ots.lua +++ b/tex/context/base/mkiv/font-ots.lua @@ -6,24 +6,29 @@ if not modules then modules = { } end modules ['font-ots'] = { -- sequences license = "see context related readme files", } +-- to be checked: discrun doesn't seem to do something useful now (except run the +-- check again) so if we need it again we'll do a zwnjrun or so + +-- beware, on my development machine we test a slightly a more optimized version + -- assumptions: -- -- cursives don't cross discretionaries -- marks precede bases - +-- -- pitfalls: -- -- when we append to a dics field we need to set the field in order to update tail - +-- -- This is a version of font-otn.lua adapted to the new font loader code. It -- is a context version which can contain experimental code, but when we -- have serious patches we will backport to the font-otn files. There will -- be a generic variant too. - +-- -- todo: looks like we have a leak somewhere (probably in ligatures) -- todo: copy attributes to disc -- todo: get rid of components, better use the tounicode entry if needed (at all) - +-- -- we do some disc juggling where we need to keep in mind that the -- pre, post and replace fields can have prev pointers to a nesting -- node ... i wonder if that is still needed @@ -94,6 +99,7 @@ results in different tables.</p> local type, next, tonumber = type, next, tonumber local random = math.random local formatters = string.formatters +local insert = table.insert local logs, trackers, nodes, attributes = logs, trackers, nodes, attributes @@ -123,6 +129,7 @@ local trace_directions = false registertracker("otf.directions", function(v local trace_kernruns = false registertracker("otf.kernruns", function(v) trace_kernruns = v end) local trace_discruns = false registertracker("otf.discruns", function(v) trace_discruns = v end) local trace_compruns = false registertracker("otf.compruns", function(v) trace_compruns = v end) +local trace_testruns = false registertracker("otf.testruns", function(v) trace_testruns = v end) local quit_on_no_replacement = true -- maybe per font local zwnjruns = true @@ -154,25 +161,24 @@ local tonut = nuts.tonut local getfield = nuts.getfield local setfield = nuts.setfield local getnext = nuts.getnext +local setnext = nuts.setnext local getprev = nuts.getprev +local setprev = nuts.setprev local getboth = nuts.getboth +local setboth = nuts.setboth local getid = nuts.getid local getattr = nuts.getattr +local setattr = nuts.setattr local getprop = nuts.getprop +local setprop = nuts.setprop local getfont = nuts.getfont local getsubtype = nuts.getsubtype +local setsubtype = nuts.setsubtype local getchar = nuts.getchar +local setchar = nuts.setchar local getdisc = nuts.getdisc - -local setattr = nuts.setattr -local setprop = nuts.setprop local setdisc = nuts.setdisc -local setnext = nuts.setnext -local setprev = nuts.setprev local setlink = nuts.setlink -local setboth = nuts.setboth -local setchar = nuts.setchar -local setsubtype = nuts.setsubtype local ischar = nuts.is_char @@ -219,7 +225,6 @@ local privateattribute = attributes.private -- of only some. local a_state = privateattribute('state') -local a_cursbase = privateattribute('cursbase') -- to be checked, probably can go local injections = nodes.injections local setmark = injections.setmark @@ -243,29 +248,38 @@ local onetimemessage = fonts.loggers.onetimemessage or function() end otf.defaultnodealternate = "none" -- first last -local handlers = { } - -- We use a few global variables. The handler can be called nested but this assumes that the -- same font is used. Nested calls are normally not needed (only for devanagari). -local tfmdata = false -local characters = false -local descriptions = false -local marks = false -local currentfont = false -local factor = 0 +local tfmdata = false +local characters = false +local descriptions = false +local marks = false +local currentfont = false +local factor = 0 +local threshold = 0 + +local sweepnode = nil +local sweepprev = nil +local sweepnext = nil +local sweephead = { } -local sweepnode = nil -local sweepprev = nil -local sweepnext = nil -local sweephead = { } +local notmatchpre = { } +local notmatchpost = { } +local notmatchreplace = { } -local notmatchpre = { } -local notmatchpost = { } -local notmatchreplace = { } +local handlers = { } --- handlers .whatever(head,start, dataset,sequence,kerns, step,i,injection) --- chainprocs.whatever(head,start,stop,dataset,sequence,currentlookup,chainindex) +-- helper + +local function isspace(n) + if getid(n) == glue_code then + local w = getfield(n,"width") + if w >= threshold then + return 32 + end + end +end -- we use this for special testing and documentation @@ -361,99 +375,6 @@ local function copy_glyph(g) -- next and prev are untouched ! end end --- temp here (context) - watch out: we need to set post/pre/replace in order to update its tail - --- local function collapsedisc(start,next) --- local replace1 = getfield(start,"replace") --- local replace2 = getfield(next,"replace") --- if replace1 and replace2 then --- local pre2 = getfield(next,"pre") --- local post2 = getfield(next,"post") --- setprev(replace1,nil) --- if pre2 then --- local pre1 = getfield(start,"pre") --- if pre1 then --- flush_node_list(pre1) --- end --- local pre1 = copy_node_list(replace1) --- local tail1 = find_node_tail(pre1) --- setnext(tail1,pre2) --- setprev(pre2,tail1) --- setfield(start,"pre",pre1) --- setfield(next,"pre",nil) --- else --- setfield(start,"pre",nil) --- end --- if post2 then --- local post1 = getfield(start,"post") --- if post1 then --- flush_node_list(post1) --- end --- setfield(start,"post",post2) --- else --- setfield(start,"post",nil) --- end --- local tail1 = find_node_tail(replace1) --- setnext(tail1,replace2) --- setprev(replace2,tail1) --- setfield(start,"replace",replace1) --- setfield(next,"replace",nil) --- -- --- local nextnext = getnext(next) --- setprev(nextnext,start) --- setnext(start,nextnext) --- free_node(next) --- else --- -- maybe remove it --- end --- end - --- local function prependdisc(first,last,prev) --- local prev = prev or getprev(first) --- local pre = getfield(last,"pre") --- local replace = getfield(last,"replace") --- local rs = getfield(first,"replace") --- local ps = copy_node_list(rs) --- local rt = ps and find_node_tail(rs) --- local pt = rs and find_node_tail(ps) --- if pre then --- setprev(pre,pt) --- setnext(pt,pre) --- end --- if replace then --- setprev(replace,rt) --- setnext(rt,replace) --- end --- setfield(last,"pre",ps) --- setfield(last,"replace",rs) --- setfield(first,"replace",nil) --- free_node(first) --- setprev(last,prev) --- setnext(prev,last) --- return prev -- if nil then last is head --- end - --- local function prependglyph(first,last,prev) --- local prev = prev or getprev(first) --- local pre = getfield(last,"pre") --- local replace = getfield(last,"replace") --- local rs = first --- local ps = copy_node(first) --- if pre then --- setprev(pre,ps) --- setnext(ps,pre) --- end --- if replace then --- setprev(replace,rs) --- setnext(rs,replace) --- end --- setfield(last,"pre",ps) --- setfield(last,"replace",rs) --- setprev(last,prev) --- setnext(prev,last) --- return prev -- if nil then last is head --- end - local function flattendisk(head,disc) local _, _, replace, _, _, replacetail = getdisc(disc,true) setfield(disc,"replace",nil) @@ -566,8 +487,8 @@ local function toligature(head,start,stop,char,dataset,sequence,markflag,discfou -- needs testing (side effects): local components = getfield(start,"components") if components then --- we get a double free .. needs checking --- flush_node_list(components) + -- we get a double free .. needs checking + -- flush_node_list(components) end -- local prev = getprev(start) @@ -582,7 +503,7 @@ local function toligature(head,start,stop,char,dataset,sequence,markflag,discfou resetinjection(base) setchar(base,char) setsubtype(base,ligature_code) - setfield(base,"components",comp) -- start can have components .. do we need to flush? + setfield(base,"components",comp) -- start can have components ... do we need to flush? if prev then setnext(prev,base) end @@ -619,17 +540,21 @@ local function toligature(head,start,stop,char,dataset,sequence,markflag,discfou -- we can have one accent as part of a lookup and another following -- local start = components -- was wrong (component scanning was introduced when more complex ligs in devanagari was added) local start = getnext(current) - while start and getid(start) == glyph_code do - local char = getchar(start) - if marks[char] then - setligaindex(start,baseindex + getligaindex(start,componentindex)) - if trace_marks then - logwarning("%s: set mark %s, gets index %s",pref(dataset,sequence),gref(char),getligaindex(start)) + while start do + local char = ischar(start) + if char then + if marks[char] then + setligaindex(start,baseindex + getligaindex(start,componentindex)) + if trace_marks then + logwarning("%s: set mark %s, gets index %s",pref(dataset,sequence),gref(char),getligaindex(start)) + end + start = getnext(start) + else + break end else break end - start = getnext(start) end else -- discfound ... forget about marks .. probably no scripts that hyphenate and have marks @@ -775,9 +700,9 @@ function handlers.gsub_ligature(head,start,dataset,sequence,ligature) local startchar = getchar(start) if marks[startchar] then while current do - local ch = ischar(current,currentfont) - if ch then - local lg = ligature[ch] + local char = ischar(current,currentfont) + if char then + local lg = ligature[char] if lg then stop = current ligature = lg @@ -809,30 +734,27 @@ function handlers.gsub_ligature(head,start,dataset,sequence,ligature) local discfound = false local lastdisc = nil while current do - local id = getid(current) - -- weird test here - if id == glyph_code then -- not needed - local char = ischar(current,currentfont) - if char then - if skipmark and marks[char] then - current = getnext(current) - else -- ligature is a tree - local lg = ligature[char] -- can there be multiple in a row? maybe in a bad font - if lg then - if not discfound and lastdisc then - discfound = lastdisc - lastdisc = nil - end - stop = current -- needed for fake so outside then - ligature = lg - current = getnext(current) - else - break + local char, id = ischar(current,currentfont) + if char then + if skipmark and marks[char] then + current = getnext(current) + else -- ligature is a tree + local lg = ligature[char] -- can there be multiple in a row? maybe in a bad font + if lg then + if not discfound and lastdisc then + discfound = lastdisc + lastdisc = nil end + stop = current -- needed for fake so outside then + ligature = lg + current = getnext(current) + else + break end - else - break end + elseif char == false then + -- kind of weird + break elseif id == disc_code then lastdisc = current current = getnext(current) @@ -866,8 +788,6 @@ function handlers.gsub_ligature(head,start,dataset,sequence,ligature) return head, start, false, discfound end --- todo: have this one directly (all are pair now) - function handlers.gpos_single(head,start,dataset,sequence,kerns,rlmode,step,i,injection) local startchar = getchar(start) if step.format == "pair" then @@ -938,6 +858,8 @@ function handlers.gpos_pair(head,start,dataset,sequence,kerns,rlmode,step,i,inje end done = true break + else -- can't happen + break end else break @@ -952,8 +874,6 @@ end we need to explicitly test for basechar, baselig and basemark entries.</p> --ldx]]-- --- can we share with chains if we have a stop == nil ? - function handlers.gpos_mark2base(head,start,dataset,sequence,markanchors,rlmode) local markchar = getchar(start) if marks[markchar] then @@ -962,7 +882,7 @@ function handlers.gpos_mark2base(head,start,dataset,sequence,markanchors,rlmode) local basechar = ischar(base,currentfont) if basechar then if marks[basechar] then - while true do + while base do base = getprev(base) if base then basechar = ischar(base,currentfont) @@ -1006,8 +926,6 @@ function handlers.gpos_mark2base(head,start,dataset,sequence,markanchors,rlmode) return head, start, false end --- ONCE CHECK HERE? - function handlers.gpos_mark2ligature(head,start,dataset,sequence,markanchors,rlmode) local markchar = getchar(start) if marks[markchar] then @@ -1016,7 +934,7 @@ function handlers.gpos_mark2ligature(head,start,dataset,sequence,markanchors,rlm local basechar = ischar(base,currentfont) if basechar then if marks[basechar] then - while true do + while base do base = getprev(base) if base then basechar = ischar(base,currentfont) @@ -1110,49 +1028,41 @@ function handlers.gpos_mark2mark(head,start,dataset,sequence,markanchors,rlmode) end function handlers.gpos_cursive(head,start,dataset,sequence,exitanchors,rlmode,step,i) -- to be checked - local alreadydone = cursonce and getprop(start,a_cursbase) - if not alreadydone then - local done = false - local startchar = getchar(start) - if marks[startchar] then - if trace_cursive then - logprocess("%s: ignoring cursive for mark %s",pref(dataset,sequence),gref(startchar)) - end - else - local nxt = getnext(start) - while not done and nxt do - local nextchar = ischar(nxt,currentfont) - if not nextchar then - break - elseif marks[nextchar] then - -- should not happen (maybe warning) - nxt = getnext(nxt) - else - local exit = exitanchors[3] - if exit then - local entry = exitanchors[1][nextchar] + local done = false + local startchar = getchar(start) + if marks[startchar] then + if trace_cursive then + logprocess("%s: ignoring cursive for mark %s",pref(dataset,sequence),gref(startchar)) + end + else + local nxt = getnext(start) + while not done and nxt do + local nextchar = ischar(nxt,currentfont) + if not nextchar then + break + elseif marks[nextchar] then + -- should not happen (maybe warning) + nxt = getnext(nxt) + else + local exit = exitanchors[3] + if exit then + local entry = exitanchors[1][nextchar] + if entry then + entry = entry[2] if entry then - entry = entry[2] - if entry then - local dx, dy, bound = setcursive(start,nxt,factor,rlmode,exit,entry,characters[startchar],characters[nextchar]) - if trace_cursive then - logprocess("%s: moving %s to %s cursive (%p,%p) using anchor %s and bound %s in %s mode",pref(dataset,sequence),gref(startchar),gref(nextchar),dx,dy,anchor,bound,mref(rlmode)) - end - done = true + local dx, dy, bound = setcursive(start,nxt,factor,rlmode,exit,entry,characters[startchar],characters[nextchar]) + if trace_cursive then + logprocess("%s: moving %s to %s cursive (%p,%p) using anchor %s and bound %s in %s mode",pref(dataset,sequence),gref(startchar),gref(nextchar),dx,dy,anchor,bound,mref(rlmode)) end + done = true end end - break end + break end end - return head, start, done - else - if trace_cursive and trace_details then - logprocess("%s, cursive %s is already done",pref(dataset,sequence),gref(getchar(start)),alreadydone) - end - return head, start, false end + return head, start, done end --[[ldx-- @@ -1221,36 +1131,6 @@ single lookup case. The efficiency of the replacements can be improved by deleti as less as needed but that would also make the code even more messy.</p> --ldx]]-- --- local function delete_till_stop(head,start,stop,ignoremarks) -- keeps start --- local n = 1 --- if start == stop then --- -- done --- elseif ignoremarks then --- repeat -- start x x m x x stop => start m --- local next = getnext(start) --- if not marks[getchar(next)] then --- local components = getfield(next,"components") --- if components then -- probably not needed --- flush_node_list(components) --- end --- head = delete_node(head,next) --- end --- n = n + 1 --- until next == stop --- else -- start x x x stop => start --- repeat --- local next = getnext(start) --- local components = getfield(next,"components") --- if components then -- probably not needed --- flush_node_list(components) --- end --- head = delete_node(head,next) --- n = n + 1 --- until next == stop --- end --- return head, n --- end - --[[ldx-- <p>Here we replace start by a single variant.</p> --ldx]]-- @@ -1271,8 +1151,8 @@ function chainprocs.gsub_single(head,start,stop,dataset,sequence,currentlookup,c end local current = start while current do - if getid(current) == glyph_code then - local currentchar = getchar(current) + local currentchar = ischar(current) + if currentchar then local replacement = steps[1].coverage[currentchar] if not replacement or replacement == "" then if trace_bugs then @@ -1286,6 +1166,9 @@ function chainprocs.gsub_single(head,start,stop,dataset,sequence,currentlookup,c setchar(current,replacement) end return head, start, true + elseif currentchar == false then + -- can't happen + break elseif current == stop then break else @@ -1343,8 +1226,8 @@ function chainprocs.gsub_alternate(head,start,stop,dataset,sequence,currentlooku local value = what == true and tfmdata.shared.features[kind] or what local current = start while current do - if getid(current) == glyph_code then -- is this check needed? - local currentchar = getchar(current) + local currentchar = ischar(current) + if currentchar then local alternatives = steps[1].coverage[currentchar] if alternatives then local choice, comment = get_alternative_glyph(current,alternatives,value) @@ -1361,6 +1244,9 @@ function chainprocs.gsub_alternate(head,start,stop,dataset,sequence,currentlooku end end return head, start, true + elseif currentchar == false then + -- can't happen + break elseif current == stop then break else @@ -1567,7 +1453,7 @@ function chainprocs.gpos_mark2base(head,start,stop,dataset,sequence,currentlooku local basechar = ischar(base,currentfont) if basechar then if marks[basechar] then - while true do + while base do base = getprev(base) if base then local basechar = ischar(base,currentfont) @@ -1631,7 +1517,7 @@ function chainprocs.gpos_mark2ligature(head,start,stop,dataset,sequence,currentl local basechar = ischar(base,currentfont) if basechar then if marks[basechar] then - while true do + while base do base = getprev(base) if base then local basechar = ischar(base,currentfont) @@ -1742,56 +1628,52 @@ function chainprocs.gpos_cursive(head,start,stop,dataset,sequence,currentlookup, if nofsteps > 1 then reportmoresteps(dataset,sequence) end - local alreadydone = cursonce and getprop(start,a_cursbase) -- also mkmk? - if not alreadydone then - local startchar = getchar(start) - local exitanchors = steps[1].coverage[startchar] -- always 1 step - if exitanchors then - local done = false - if marks[startchar] then - if trace_cursive then - logprocess("%s: ignoring cursive for mark %s",pref(dataset,sequence),gref(startchar)) - end - else - local nxt = getnext(start) - while not done and nxt do - local nextchar = ischar(nxt,currentfont) - if not nextchar then - break - elseif marks[nextchar] then - -- should not happen (maybe warning) - nxt = getnext(nxt) - else - local exit = exitanchors[3] - if exit then - local entry = exitanchors[1][nextchar] + local startchar = getchar(start) + local exitanchors = steps[1].coverage[startchar] -- always 1 step + if exitanchors then + local done = false + if marks[startchar] then + if trace_cursive then + logprocess("%s: ignoring cursive for mark %s",pref(dataset,sequence),gref(startchar)) + end + else + local nxt = getnext(start) + while not done and nxt do + local nextchar = ischar(nxt,currentfont) + if not nextchar then + break + elseif marks[nextchar] then + -- should not happen (maybe warning) + nxt = getnext(nxt) + else + local exit = exitanchors[3] + if exit then + local entry = exitanchors[1][nextchar] + if entry then + entry = entry[2] if entry then - entry = entry[2] - if entry then - local dx, dy, bound = setcursive(start,nxt,factor,rlmode,exit,entry,characters[startchar],characters[nextchar]) - if trace_cursive then - logprocess("%s: moving %s to %s cursive (%p,%p) using anchor %s and bound %s in %s mode",pref(dataset,sequence),gref(startchar),gref(nextchar),dx,dy,anchor,bound,mref(rlmode)) - end - done = true - break + local dx, dy, bound = setcursive(start,nxt,factor,rlmode,exit,entry,characters[startchar],characters[nextchar]) + if trace_cursive then + logprocess("%s: moving %s to %s cursive (%p,%p) using anchor %s and bound %s in %s mode",pref(dataset,sequence),gref(startchar),gref(nextchar),dx,dy,anchor,bound,mref(rlmode)) end + done = true + break end - elseif trace_bugs then - onetimemessage(currentfont,startchar,"no entry anchors",report_fonts) end - break + elseif trace_bugs then + onetimemessage(currentfont,startchar,"no entry anchors",report_fonts) end + break end end - return head, start, done - else - if trace_cursive and trace_details then - logprocess("%s, cursive %s is already done",pref(dataset,sequence),gref(getchar(start)),alreadydone) - end - return head, start, false end + return head, start, done + else + if trace_cursive and trace_details then + logprocess("%s, cursive %s is already done",pref(dataset,sequence),gref(getchar(start)),alreadydone) + end + return head, start, false end - return head, start, false end -- what pointer to return, spec says stop @@ -2178,6 +2060,7 @@ local noflags = { false, false, false, false } local function handle_contextchain(head,start,dataset,sequence,contexts,rlmode) local sweepnode = sweepnode local sweeptype = sweeptype + local currentfont = currentfont local diskseen = false local checkdisc = getprev(head) local flags = sequence.flags or noflags @@ -2198,7 +2081,9 @@ local function handle_contextchain(head,start,dataset,sequence,contexts,rlmode) if s == 1 then -- never happens local char = ischar(current,currentfont) - match = char and seq[1][char] + if char then + match = seq[1][char] + end else -- maybe we need a better space check (maybe check for glue or category or combination) -- we cannot optimize for n=2 because there can be disc nodes @@ -2222,33 +2107,22 @@ local function handle_contextchain(head,start,dataset,sequence,contexts,rlmode) sweeptype = nil end if last then - local id = getid(last) - if id == glyph_code then - local char = ischar(last,currentfont) - if char then - local ccd = descriptions[char] - if ccd then - local class = ccd.class or "base" - if class == skipmark or class == skipligature or class == skipbase or (markclass and class == "mark" and not markclass[char]) then - skipped = true - if trace_skips then - show_skip(dataset,sequence,char,ck,class) - end + local char, id = ischar(last,currentfont) + if char then + local ccd = descriptions[char] + if ccd then + local class = ccd.class or "base" + if class == skipmark or class == skipligature or class == skipbase or (markclass and class == "mark" and not markclass[char]) then + skipped = true + if trace_skips then + show_skip(dataset,sequence,char,ck,class) + end + last = getnext(last) + elseif seq[n][char] then + if n < l then last = getnext(last) - elseif seq[n][char] then - if n < l then - last = getnext(last) - end - n = n + 1 - else - if discfound then - notmatchreplace[discfound] = true - match = not notmatchpre[discfound] - else - match = false - end - break end + n = n + 1 else if discfound then notmatchreplace[discfound] = true @@ -2267,6 +2141,15 @@ local function handle_contextchain(head,start,dataset,sequence,contexts,rlmode) end break end + last = getnext(last) + elseif char == false then + if discfound then + notmatchreplace[discfound] = true + match = not notmatchpre[discfound] + else + match = false + end + break elseif id == disc_code then diskseen = true discfound = last @@ -2336,29 +2219,18 @@ local function handle_contextchain(head,start,dataset,sequence,contexts,rlmode) local n = f - 1 while n >= 1 do if prev then - local id = getid(prev) - if id == glyph_code then - local char = ischar(prev,currentfont) - if char then - local ccd = descriptions[char] - if ccd then - local class = ccd.class - if class == skipmark or class == skipligature or class == skipbase or (markclass and class == "mark" and not markclass[char]) then - skipped = true - if trace_skips then - show_skip(dataset,sequence,char,ck,class) - end - elseif seq[n][char] then - n = n -1 - else - if discfound then - notmatchreplace[discfound] = true - match = not notmatchpost[discfound] - else - match = false - end - break + local char, id = ischar(prev,currentfont) + if char then + local ccd = descriptions[char] + if ccd then + local class = ccd.class + if class == skipmark or class == skipligature or class == skipbase or (markclass and class == "mark" and not markclass[char]) then + skipped = true + if trace_skips then + show_skip(dataset,sequence,char,ck,class) end + elseif seq[n][char] then + n = n -1 else if discfound then notmatchreplace[discfound] = true @@ -2377,6 +2249,15 @@ local function handle_contextchain(head,start,dataset,sequence,contexts,rlmode) end break end + prev = getprev(prev) + elseif char == false then + if discfound then + notmatchreplace[discfound] = true + match = not notmatchpost[discfound] + else + match = false + end + break elseif id == disc_code then -- the special case: f i where i becomes dottless i .. diskseen = true @@ -2439,7 +2320,7 @@ local function handle_contextchain(head,start,dataset,sequence,contexts,rlmode) -- skip 'm end elseif seq[n][32] then - n = n -1 + n = n - 1 else match = false break @@ -2474,29 +2355,18 @@ local function handle_contextchain(head,start,dataset,sequence,contexts,rlmode) local n = l + 1 while n <= s do if current then - local id = getid(current) - if id == glyph_code then - local char = ischar(current,currentfont) - if char then - local ccd = descriptions[char] - if ccd then - local class = ccd.class - if class == skipmark or class == skipligature or class == skipbase or (markclass and class == "mark" and not markclass[char]) then - skipped = true - if trace_skips then - show_skip(dataset,sequence,char,ck,class) - end - elseif seq[n][char] then - n = n + 1 - else - if discfound then - notmatchreplace[discfound] = true - match = not notmatchpre[discfound] - else - match = false - end - break + local char, id = ischar(current,currentfont) + if char then + local ccd = descriptions[char] + if ccd then + local class = ccd.class + if class == skipmark or class == skipligature or class == skipbase or (markclass and class == "mark" and not markclass[char]) then + skipped = true + if trace_skips then + show_skip(dataset,sequence,char,ck,class) end + elseif seq[n][char] then + n = n + 1 else if discfound then notmatchreplace[discfound] = true @@ -2515,6 +2385,15 @@ local function handle_contextchain(head,start,dataset,sequence,contexts,rlmode) end break end + current = getnext(current) + elseif char == false then + if discfound then + notmatchreplace[discfound] = true + match = not notmatchpre[discfound] + else + match = false + end + break elseif id == disc_code then diskseen = true discfound = current @@ -2572,6 +2451,7 @@ local function handle_contextchain(head,start,dataset,sequence,contexts,rlmode) current = getnext(current) elseif seq[n][32] then n = n + 1 +current = getnext(current) else match = false break @@ -2619,7 +2499,7 @@ local function handle_contextchain(head,start,dataset,sequence,contexts,rlmode) local i = 1 while start and true do if skipped then - while true do -- todo: use properties + while start do -- todo: use properties local char = getchar(start) local ccd = descriptions[char] if ccd then @@ -2739,11 +2619,11 @@ end local logwarning = report_process -local function report_missing_cache(dataset,sequence) +local function report_missing_coverage(dataset,sequence) local t = missing[currentfont] if not t[sequence] then t[sequence] = true - logwarning("missing cache for feature %a, lookup %a, type %a, font %a, name %a", + logwarning("missing coverage for feature %a, lookup %a, type %a, font %a, name %a", dataset[4],sequence.name,sequence.type,currentfont,tfmdata.properties.fullname) end end @@ -2836,20 +2716,23 @@ function otf.dataset(tfmdata,font) -- generic variant, overloaded in context return rl end --- assumptions: --- --- * languages that use complex disc nodes +local function report_disc(n) + report_run("kern: %s > %s",disc,languages.serializediscretionary(disc)) +end -local function kernrun(disc,run) +local function kernrun(disc,k_run,font,attr,...) -- -- we catch <font 1><disc font 2> -- if trace_kernruns then - report_run("kern") -- will be more detailed + report_disc("kern") end -- local prev, next = getboth(disc) -- + local nextstart = next + local done = false + -- local pre, post, replace, pretail, posttail, replacetail = getdisc(disc,true) -- local prevmarks = prev @@ -2858,7 +2741,7 @@ local function kernrun(disc,run) -- has happened but then it should be in the disc so basically this test indicates an error) -- while prevmarks do - local char = ischar(prevmarks,currentfont) + local char = ischar(prevmarks,font) if char and marks[char] then prevmarks = getprev(prevmarks) else @@ -2866,68 +2749,77 @@ local function kernrun(disc,run) end end -- - if prev and (pre or replace) and not ischar(prev,currentfont) then + if prev and (pre or replace) and not ischar(prev,font) then prev = false end - if next and (post or replace) and not ischar(next,currentfont) then + if next and (post or replace) and not ischar(next,font) then next = false end -- if pre then - run(pre,"injections") + if k_run(pre,"injections",nil,font,attr,...) then + done = true + end if prev then local nest = getprev(pre) setlink(prev,pre) - run(prevmarks,"preinjections",pre) -- getnext(pre)) + if k_run(prevmarks,"preinjections",pre,font,attr,...) then -- getnext(pre)) + done = true + end setprev(pre,nest) setnext(prev,disc) end end -- if post then - run(post,"injections") + if k_run(post,"injections",nil,font,attr,...) then + done = true + end if next then setlink(posttail,next) - run(posttail,"postinjections",next) + if k_run(posttail,"postinjections",next,font,attr,...) then + done = true + end setnext(posttail,nil) setprev(next,disc) end end -- if replace then - run(replace,"injections") + if k_run(replace,"injections",nil,font,attr,...) then + done = true + end if prev then local nest = getprev(replace) setlink(prev,replace) - run(prevmarks,"replaceinjections",replace) -- getnext(replace)) + if k_run(prevmarks,"replaceinjections",replace,font,attr,...) then -- getnext(replace)) + done = true + end setprev(replace,nest) setnext(prev,disc) end if next then setlink(replacetail,next) - run(replacetail,"replaceinjections",next) + if k_run(replacetail,"replaceinjections",next,font,attr,...) then + done = true + end setnext(replacetail,nil) setprev(next,disc) end elseif prev and next then setlink(prev,next) - run(prevmarks,"emptyinjections",next) + if k_run(prevmarks,"emptyinjections",next,font,attr,...) then + done = true + end setlink(prev,disc) setlink(disc,next) end + return nextstart, done end --- the if new test might be dangerous as luatex will check / set some tail stuff --- in a temp node - -local function checkdisc(str,d) -- only used when debugging - local pre, post, replace = getdisc(d) - report_check("%s : [%s][%s][%s]",str,nodes.toutf(pre),nodes.toutf(post),nodes.toutf(replace)) -end - -local function comprun(disc,run) +local function comprun(disc,c_run,...) if trace_compruns then - report_run("comp: %s",languages.serializediscretionary(disc)) + report_disc("comp") end -- local pre, post, replace = getdisc(disc) @@ -2935,8 +2827,8 @@ local function comprun(disc,run) -- if pre then sweepnode = disc - sweeptype = "pre" -- in alternative code preinjections is used (also used then for proeprties, saves a variable) - local new, done = run(pre) + sweeptype = "pre" -- in alternative code preinjections is uc_c_sed (also used then for proeprties, saves a variable) + local new, done = c_run(pre,...) if done then pre = new renewed = true @@ -2946,7 +2838,7 @@ local function comprun(disc,run) if post then sweepnode = disc sweeptype = "post" - local new, done = run(post) + local new, done = c_run(post,...) if done then post = new renewed = true @@ -2956,106 +2848,446 @@ local function comprun(disc,run) if replace then sweepnode = disc sweeptype = "replace" - local new, done = run(replace) + local new, done = c_run(replace,...) if done then replace = new renewed = true end end + -- sweepnode = nil sweeptype = nil if renewed then setdisc(disc,pre,post,replace) end + -- + return getnext(disc), done end -local function testrun(disc,trun,crun) -- use helper - local next = getnext(disc) - if next then - local _, _, replace, _, _, tail = getdisc(disc,true) - if replace then - local prev = getprev(disc) - if prev then - -- only look ahead - -- local nest = getprev(replace) - setlink(tail,next) - if trun(replace,next) then - setfield(disc,"replace",nil) -- beware, side effects of nest so first - setlink(prev,replace) - setlink(tail,next) - setboth(disc,nil,nil) - flush_node_list(disc) - return replace -- restart - else - setnext(tail,nil) - setprev(next,disc) +local function testrun(disc,t_run,c_run,...) + if trace_testruns then + report_disc("test") + end + local prev, next = getboth(disc) + if not next then + -- weird discretionary + return + end + local pre, post, replace, pretail, posttail, replacetail = getdisc(disc) + local done = false + if replace and prev then + -- only look ahead + -- local nest = getprev(replace) + setlink(replacetail,next) + if t_run(replace,next,...) then + setfield(disc,"replace",nil) -- beware, side effects of nest so first + setlink(prev,replace) + setlink(replacetail,next) + setboth(disc) + flush_node_list(disc) + return replace, true -- restart .. tricky ! + else + setnext(replacetail) + setprev(next,disc) + end + -- pre, post, replace, pretail, posttail, replacetail = getdisc(disc) + end + -- + -- like comprun + -- + local renewed = false + -- + if pre then + sweepnode = disc + sweeptype = "pre" + local new, ok = c_run(pre,...) + if ok then + pre = new + renewed = true + end + end + -- + if post then + sweepnode = disc + sweeptype = "post" + local new, ok = c_run(post,...) + if ok then + post = new + renewed = true + end + end + -- + if replace then + sweepnode = disc + sweeptype = "replace" + local new, ok = c_run(replace,...) + if ok then + replace = new + renewed = true + end + end + -- + sweepnode = nil + sweeptype = nil + if renewed then + setdisc(disc,pre,post,replace) + return next, true + else + return next, done + end +end + +-- A discrun happens when we have a zwnj. We're gpossing so it is unlikely that +-- there has been a match changing the character. Now, as we check again here +-- the question is: why do we do this ... needs checking as drun seems useless +-- ... maybe that code can go away + +-- local function discrun(disc,drun,krun) +-- local prev, next = getboth(disc) +-- if trace_discruns then +-- report_disc("disc") +-- end +-- if next and prev then +-- setnext(prev,next) +-- -- setprev(next,prev) +-- drun(prev) +-- setnext(prev,disc) +-- -- setprev(next,disc) +-- end +-- -- +-- if krun then -- currently always false +-- local pre = getfield(disc,"pre") +-- if not pre then +-- -- go on +-- elseif prev then +-- local nest = getprev(pre) +-- setlink(prev,pre) +-- krun(prev,"preinjections") +-- setprev(pre,nest) +-- setnext(prev,disc) +-- else +-- krun(pre,"preinjections") +-- end +-- end +-- return next +-- end + +-- We can make some assumptions with respect to discretionaries. First of all it is very +-- unlikely that some of the analysis related attributes applies. Then we can also assume +-- that the ConTeXt specific dynamic attribute is different, although we do use explicit +-- discretionaries (maybe we need to tag those some day). So, at least for now, we don't +-- have the following test in the sub runs: +-- +-- -- local a = getattr(start,0) +-- -- if a then +-- -- a = (a == attr) and (not attribute or getprop(start,a_state) == attribute) +-- -- else +-- -- a = not attribute or getprop(start,a_state) == attribute +-- -- end +-- -- if a then +-- +-- but use this instead: +-- +-- -- local a = getattr(start,0) +-- -- if not a or (a == attr) then +-- +-- and even that one is probably not needed. + +local nesting = 0 + +local function c_run_single(head,font,attr,lookupcache,step,dataset,sequence,rlmode,handler) + local done = false + local start = sweephead[head] + if start then + sweephead[head] = nil + else + start = head + end + while start do + local char = ischar(start,font) + if char then + local a = getattr(start,0) + if not a or (a == attr) then + local lookupmatch = lookupcache[char] + if lookupmatch then + local ok + head, start, ok = handler(head,start,dataset,sequence,lookupmatch,rlmode,step,1) + if ok then + done = true + end + end + if start then + start = getnext(start) end else - -- weird case + start = getnext(start) end + elseif char == false then + return head, done else - -- no need + -- weird + start = getnext(start) end - else - -- weird case end - comprun(disc,crun) - return next + return head, done end -local function discrun(disc,drun,krun) - local prev, next = getboth(disc) - if trace_discruns then - report_run("disc") -- will be more detailed +local function t_run_single(start,stop,font,attr,lookupcache) + while start ~= stop do + local char = ischar(start,font) + if char then + local a = getattr(start,0) + if not a or (a == attr) then + local lookupmatch = lookupcache[char] + if lookupmatch then -- hm, hyphens can match (tlig) so we need to really check + -- if we need more than ligatures we can outline the code and use functions + local s = getnext(start) + local l = nil + while s do + local lg = lookupmatch[getchar(s)] + if lg then + l = lg + s = getnext(s) + else + break + end + end + if l and l.ligature then + return true + end + end + end + start = getnext(start) + else + break + end end - if next and prev then - setnext(prev,next) - -- setprev(next,prev) - drun(prev) - setnext(prev,disc) - -- setprev(next,disc) +end + +-- local function d_run_single(prev,font,attr,lookupcache,step,dataset,sequence,rlmode,handler) +-- local a = getattr(prev,0) +-- if not a or (a == attr) then +-- local char = ischar(prev) -- can be disc +-- if char then +-- local lookupmatch = lookupcache[char] +-- if lookupmatch then +-- local h, d, ok = handler(head,start,dataset,sequence,lookupmatch,rlmode,step,1) +-- if ok then +-- done = true +-- success = true +-- end +-- end +-- end +-- end +-- end + +local function k_run_single(sub,injection,last,font,attr,lookupcache,step,dataset,sequence,rlmode,handler) + local a = getattr(sub,0) + if not a or (a == attr) then + for n in traverse_nodes(sub) do -- only gpos + if n == last then + break + end + local char = ischar(n) + if char then + local lookupmatch = lookupcache[char] + if lookupmatch then + local h, d, ok = handler(sub,n,dataset,sequence,lookupmatch,rlmode,step,1,injection) + if ok then + return true + end + end + end + end end - -- - local pre = getfield(disc,"pre") - if not pre then - -- go on - elseif prev then - local nest = getprev(pre) - setlink(prev,pre) - krun(prev,"preinjections") - setprev(pre,nest) - setnext(prev,disc) +end + +local function c_run_multiple(head,font,attr,steps,nofsteps,dataset,sequence,rlmode,handler) + local done = false + local start = sweephead[head] + if start then + sweephead[head] = nil else - krun(pre,"preinjections") + start = head + end + while start do + local char = ischar(start,font) + if char then + local a = getattr(start,0) + if not a or (a == attr) then + for i=1,nofsteps do + local step = steps[i] + local lookupcache = step.coverage + if lookupcache then + local lookupmatch = lookupcache[char] + if lookupmatch then + -- we could move all code inline but that makes things even more unreadable + local ok + head, start, ok = handler(head,start,dataset,sequence,lookupmatch,rlmode,step,i) + if ok then + done = true + break + elseif not start then + -- don't ask why ... shouldn't happen + break + end + end + else + report_missing_coverage(dataset,sequence) + end + end + if start then + start = getnext(start) + end + else + start = getnext(start) + end + elseif char == false then + -- whatever glyph + return head, done + else + -- very unlikely + start = getnext(start) + end + end + return head, done +end + +local function t_run_multiple(start,stop,font,attr,steps,nofsteps) + while start ~= stop do + local char = ischar(start,font) + if char then + local a = getattr(start,0) + if not a or (a == attr) then + for i=1,nofsteps do + local step = steps[i] + local lookupcache = step.coverage + if lookupcache then + local lookupmatch = lookupcache[char] + if lookupmatch then + -- if we need more than ligatures we can outline the code and use functions + local s = getnext(start) + local l = nil + while s do + local lg = lookupmatch[getchar(s)] + if lg then + l = lg + s = getnext(s) + else + break + end + end + if l and l.ligature then + return true + end + end + else + report_missing_coverage(dataset,sequence) + end + end + end + start = getnext(start) + else + break + end end - return next end --- todo: maybe run lr and rl stretches +-- local function d_run_multiple(prev,attr,steps,nofsteps,dataset,sequence,rlmode,handler) +-- local a = getattr(prev,0) +-- if not a or (a == attr) then +-- local char = ischar(prev) -- can be disc +-- if char then +-- for i=1,nofsteps do +-- local step = steps[i] +-- local lookupcache = step.coverage +-- if lookupcache then +-- local lookupmatch = lookupcache[char] +-- if lookupmatch then +-- -- we could move all code inline but that makes things even more unreadable +-- local h, d, ok = handler(head,prev,dataset,sequence,lookupmatch,rlmode,step,i) +-- if ok then +-- done = true +-- break +-- end +-- end +-- else +-- report_missing_coverage(dataset,sequence) +-- end +-- end +-- end +-- end +-- end + +local function k_run_multiple(sub,injection,last,font,attr,steps,nofsteps,dataset,sequence,rlmode,handler) + local a = getattr(sub,0) + if not a or (a == attr) then + for n in traverse_nodes(sub) do -- only gpos + if n == last then + break + end + local char = ischar(n) + if char then + for i=1,nofsteps do + local step = steps[i] + local lookupcache = step.coverage + if lookupcache then + local lookupmatch = lookupcache[char] + if lookupmatch then + local h, d, ok = handler(head,n,dataset,sequence,lookupmatch,step,rlmode,i,injection) + if ok then + return true + end + end + else + report_missing_coverage(dataset,sequence) + end + end + end + end + end +end + +-- to be checkedL nowadays we probably can assume properly matched directions +-- so maybe we no longer need a stack local function txtdirstate(start,stack,top,rlparmode) local dir = getfield(start,"dir") + local new = 1 if dir == "+TRT" then top = top + 1 stack[top] = dir - return top, -1 + new = -1 elseif dir == "+TLT" then top = top + 1 stack[top] = dir - return top, 1 - end - if dir == "-TRT" or dir == "-TLT" then + elseif dir == "-TRT" or dir == "-TLT" then top = top - 1 - if dir == "+TRT" then - return top, -1 - else - return top, 1 + if stack[top] == "+TRT" then + new = -1 end + else + new = rlparmode + end + if trace_directions then + report_process("directions after txtdir %a: parmode %a, txtmode %a, level %a",dir,mref(rlparmode),mref(new),topstack) end - return top, rlparmode + return getnext(start), top, new end -local nesting = 0 +local function pardirstate(start) + local dir = getfield(start,"dir") + local new = 0 + if dir == "TLT" then + new = 1 + elseif dir == "TRT" then + new = -1 + end + if trace_directions then + report_process("directions after pardir %a: parmode %a",dir,mref(new)) + end + return getnext(start), new, new +end local function featuresprocessor(head,font,attr) @@ -3075,6 +3307,7 @@ local function featuresprocessor(head,font,attr) characters = tfmdata.characters marks = tfmdata.resources.marks factor = tfmdata.parameters.factor + threshold = tfmdata.parameters.spacing.width or 65536*10 elseif currentfont ~= font then @@ -3095,7 +3328,7 @@ local function featuresprocessor(head,font,attr) local done = false local datasets = otf.dataset(tfmdata,font,attr) - local dirstack = { } -- could move outside function + local dirstack = { } -- could move outside function btu we can have local runss sweephead = { } @@ -3110,8 +3343,6 @@ local function featuresprocessor(head,font,attr) -- We don't goto the next node of a disc node is created so that we can then treat -- the pre, post and replace. It's a bit of a hack but works out ok for most cases. - -- there can be less subtype and attr checking in the comprun etc helpers - for s=1,#datasets do local dataset = datasets[s] ----- featurevalue = dataset[1] -- todo: pass to function instead of using a global @@ -3121,25 +3352,30 @@ local function featuresprocessor(head,font,attr) local topstack = 0 local success = false local typ = sequence.type - local gpossing = typ == "gpos_single" or typ == "gpos_pair" -- store in dataset + local gpossing = typ == "gpos_single" or typ == "gpos_pair" -- store in dataset local handler = handlers[typ] local steps = sequence.steps local nofsteps = sequence.nofsteps - if typ == "gsub_reversecontextchain" then -- chain < 0 + if not steps then + -- this permits injection, watch the different arguments + local h, d, ok = handler(head,start,dataset,sequence,nil,nil,nil,0,font,attr) + if ok then + success = true + if h then + head = h + end + if d then + start = d + end + end + elseif typ == "gsub_reversecontextchain" then -- this is a limited case, no special treatments like 'init' etc - -- we need to get rid of this slide! probably no longer needed in latest luatex - local start = find_node_tail(head) -- slow (we can store tail because there's always a skip at the end): todo + local start = find_node_tail(head) while start do - local id = getid(start) local char = ischar(start,font) if char then local a = getattr(start,0) - if a then - a = a == attr - else - a = true - end - if a then + if not a or (a == attr) then for i=1,nofsteps do local step = steps[i] local lookupcache = step.coverage @@ -3147,16 +3383,20 @@ local function featuresprocessor(head,font,attr) local lookupmatch = lookupcache[char] if lookupmatch then -- todo: disc? - head, start, success = handler(head,start,dataset,sequence,lookupmatch,rlmode,step,i) - if success then + local ok + head, start, ok = handler(head,start,dataset,sequence,lookupmatch,rlmode,step,i) + if ok then + success = true break end end else - report_missing_cache(dataset,sequence) + report_missing_coverage(dataset,sequence) end end - if start then start = getprev(start) end + if start then + start = getprev(start) + end else start = getprev(start) end @@ -3168,230 +3408,63 @@ local function featuresprocessor(head,font,attr) local start = head -- local ? rlmode = 0 -- to be checked ? if nofsteps == 1 then -- happens often + local step = steps[1] local lookupcache = step.coverage - if not lookupcache then -- also check for empty cache - report_missing_cache(dataset,sequence) + if not lookupcache then + -- can't happen, no check in loop either + report_missing_coverage(dataset,sequence) else - local function c_run(head) -- no need to check for 256 and attr probably also the same - local done = false - local start = sweephead[head] - if start then - sweephead[head] = nil - else - start = head - end - while start do - local id = getid(start) - if id ~= glyph_code then - -- very unlikely (if so we could use ischar) - start = getnext(start) - else - local char = ischar(start,font) - if char then - local a = getattr(start,0) - -- if a then - -- a = (a == attr) and (not attribute or getprop(start,a_state) == attribute) - -- else - -- a = not attribute or getprop(start,a_state) == attribute - -- end - -- if a then - if not a or (a == attr) then - local lookupmatch = lookupcache[char] - if lookupmatch then - -- sequence kan weg - local ok - head, start, ok = handler(head,start,dataset,sequence,lookupmatch,rlmode,step,1) - if ok then - done = true - end - end - if start then start = getnext(start) end - else - start = getnext(start) - end - else - return head, false - end - end - end - if done then - success = true -- needed in this subrun? - end - return head, done - end - - local function t_run(start,stop) - while start ~= stop do - local id = getid(start) - local char = ischar(start,font) - if char then - local a = getattr(start,0) - -- if a then - -- a = (a == attr) and (not attribute or getprop(start,a_state) == attribute) - -- else - -- a = not attribute or getprop(start,a_state) == attribute - -- end - -- if a then - if not a or (a == attr) then - local lookupmatch = lookupcache[char] - if lookupmatch then -- hm, hyphens can match (tlig) so we need to really check - -- if we need more than ligatures we can outline the code and use functions - local s = getnext(start) - local l = nil - while s do - local lg = lookupmatch[getchar(s)] - if lg then - l = lg - s = getnext(s) - else - break - end - end - if l and l.ligature then - return true - end - end - end - start = getnext(start) + while start do + local char, id = ischar(start,font) + if char then + local a = getattr(start,0) + if a then + a = (a == attr) and (not attribute or getprop(start,a_state) == attribute) else - break - end - end - end - - local function d_run(prev) -- we can assume that prev and next are glyphs - local a = getattr(prev,0) - -- if a then - -- a = (a == attr) and (not attribute or getprop(prev,a_state) == attribute) - -- else - -- a = not attribute or getprop(prev,a_state) == attribute - -- end - -- if a then - if not a or (a == attr) then - local lookupmatch = lookupcache[getchar(prev)] - if lookupmatch then - -- sequence kan weg - local h, d, ok = handler(head,start,dataset,sequence,lookupmatch,rlmode,step,1) - if ok then - done = true - success = true - end + a = not attribute or getprop(start,a_state) == attribute end - end - end - - local function k_run(sub,injection,last) - local a = getattr(sub,0) - -- if a then - -- a = (a == attr) and (not attribute or getprop(sub,a_state) == attribute) - -- else - -- a = not attribute or getprop(sub,a_state) == attribute - -- end - -- if a then - if not a or (a == attr) then - -- sequence kan weg - for n in traverse_nodes(sub) do -- only gpos - if n == last then - break - end - local id = getid(n) - if id == glyph_code then - local lookupmatch = lookupcache[getchar(n)] - if lookupmatch then - local h, d, ok = handler(sub,n,dataset,sequence,lookupmatch,rlmode,step,1,injection) - if ok then - done = true - success = true - end + if a then + local lookupmatch = lookupcache[char] + if lookupmatch then + local ok + head, start, ok = handler(head,start,dataset,sequence,lookupmatch,rlmode,step,1) + if ok then + success = true + -- elseif gpossing and zwnjruns and char == zwnj then + -- discrun(start,d_run,font,attr,lookupcache) end - else - -- message + -- elseif gpossing and zwnjruns and char == zwnj then + -- discrun(start,d_run,font,attr,lookupcache) end - end - end - end - - while start do - local id = getid(start) - if id == glyph_code then - local char = ischar(start,font) - if char then - local a = getattr(start,0) - if a then - a = (a == attr) and (not attribute or getprop(start,a_state) == attribute) - else - a = not attribute or getprop(start,a_state) == attribute - end - if a then - local lookupmatch = lookupcache[char] - if lookupmatch then - -- sequence kan weg - local ok - head, start, ok = handler(head,start,dataset,sequence,lookupmatch,rlmode,step,1) - if ok then - success = true - elseif gpossing and zwnjruns and char == zwnj then - discrun(start,d_run) - end - elseif gpossing and zwnjruns and char == zwnj then - discrun(start,d_run) - end - if start then start = getnext(start) end - else - start = getnext(start) + if start then + start = getnext(start) end else - start = getnext(start) + start = getnext(start) end + elseif char == false then + -- whatever glyph + start = getnext(start) elseif id == disc_code then + local ok if gpossing then - kernrun(start,k_run) - start = getnext(start) + start, ok = kernrun(start,k_run_single, font,attr,lookupcache,step,dataset,sequence,rlmode,handler) elseif typ == "gsub_ligature" then - start = testrun(start,t_run,c_run) + start, ok = testrun(start,t_run_single,c_run_single,font,attr,lookupcache,step,dataset,sequence,rlmode,handler) else - comprun(start,c_run) - start = getnext(start) + start, ok = comprun(start,c_run_single, font,attr,lookupcache,step,dataset,sequence,rlmode,handler) + end + if ok then + success = true end elseif id == math_code then start = getnext(end_of_math(start)) elseif id == dir_code then - local dir = getfield(start,"dir") - if dir == "+TLT" then - topstack = topstack + 1 - dirstack[topstack] = dir - rlmode = 1 - elseif dir == "+TRT" then - topstack = topstack + 1 - dirstack[topstack] = dir - rlmode = -1 - elseif dir == "-TLT" or dir == "-TRT" then - topstack = topstack - 1 - rlmode = dirstack[topstack] == "+TRT" and -1 or 1 - else - rlmode = rlparmode - end - if trace_directions then - report_process("directions after txtdir %a: parmode %a, txtmode %a, # stack %a, new dir %a",dir,mref(rlparmode),mref(rlmode),topstack,mref(newdir)) - end - start = getnext(start) + start, topstack, rlmode = txtdirstate(start,dirstack,topstack,rlparmode) elseif id == localpar_code then - local dir = getfield(start,"dir") - if dir == "TRT" then - rlparmode = -1 - elseif dir == "TLT" then - rlparmode = 1 - else - rlparmode = 0 - end - -- one might wonder if the par dir should be looked at, so we might as well drop the next line - rlmode = rlparmode - if trace_directions then - report_process("directions after pardir %a: parmode %a, txtmode %a",dir,mref(rlparmode),mref(rlmode)) - end - start = getnext(start) + start, rlparmode, rlmode = pardirstate(start) else start = getnext(start) end @@ -3400,280 +3473,74 @@ local function featuresprocessor(head,font,attr) else - local function c_run(head) - local done = false - local start = sweephead[head] - if start then - sweephead[head] = nil - else - start = head - end - while start do - local id = getid(start) - if id ~= glyph_code then - -- very unlikely - start = getnext(start) + while start do + local char, id = ischar(start,font) + if char then + local a = getattr(start,0) + if a then + a = (a == attr) and (not attribute or getprop(start,a_state) == attribute) else - local char = ischar(start,font) - if char then - local a = getattr(start,0) - -- if a then - -- a = (a == attr) and (not attribute or getprop(start,a_state) == attribute) - -- else - -- a = not attribute or getprop(start,a_state) == attribute - -- end - -- if a then - if not a or (a == attr) then - for i=1,nofsteps do - local step = steps[i] - local lookupcache = step.coverage - if lookupcache then - local lookupmatch = lookupcache[char] - if lookupmatch then - -- we could move all code inline but that makes things even more unreadable - local ok - head, start, ok = handler(head,start,dataset,sequence,lookupmatch,rlmode,step,i) - if ok then - done = true - break - elseif not start then - -- don't ask why ... shouldn't happen - break - end - end - else - report_missing_cache(dataset,sequence) - end - end - if start then start = getnext(start) end - else - start = getnext(start) - end - else - return head, false - end + a = not attribute or getprop(start,a_state) == attribute end - end - if done then - success = true - end - return head, done - end - - local function d_run(prev) - local a = getattr(prev,0) - -- if a then - -- a = (a == attr) and (not attribute or getprop(prev,a_state) == attribute) - -- else - -- a = not attribute or getprop(prev,a_state) == attribute - -- end - -- if a then - if not a or (a == attr) then - -- brr prev can be disc - local char = getchar(prev) - for i=1,nofsteps do - local step = steps[i] - local lookupcache = step.coverage - if lookupcache then - local lookupmatch = lookupcache[char] - if lookupmatch then - -- we could move all code inline but that makes things even more unreadable - local h, d, ok = handler(head,prev,dataset,sequence,lookupmatch,rlmode,step,i) - if ok then - done = true - break - end - end - else - report_missing_cache(dataset,sequence) - end - end - end - end - - local function k_run(sub,injection,last) - local a = getattr(sub,0) - -- if a then - -- a = (a == attr) and (not attribute or getprop(sub,a_state) == attribute) - -- else - -- a = not attribute or getprop(sub,a_state) == attribute - -- end - -- if a then - if not a or (a == attr) then - for n in traverse_nodes(sub) do -- only gpos - if n == last then - break - end - local id = getid(n) - if id == glyph_code then - local char = getchar(n) - for i=1,nofsteps do - local step = steps[i] - local lookupcache = step.coverage - if lookupcache then - local lookupmatch = lookupcache[char] - if lookupmatch then - local h, d, ok = handler(head,n,dataset,sequence,lookupmatch,step,rlmode,i,injection) - if ok then - done = true - break - end - end - else - report_missing_cache(dataset,sequence) - end - end - else - -- message - end - end - end - end - - local function t_run(start,stop) - while start ~= stop do - local id = getid(start) - local char = ischar(start,font) - if char then - local a = getattr(start,0) - -- if a then - -- a = (a == attr) and (not attribute or getprop(start,a_state) == attribute) - -- else - -- a = not attribute or getprop(start,a_state) == attribute - -- end - -- if a then - if not a or (a == attr) then - for i=1,nofsteps do - local step = steps[i] - local lookupcache = step.coverage - if lookupcache then - local lookupmatch = lookupcache[char] - if lookupmatch then - -- if we need more than ligatures we can outline the code and use functions - local s = getnext(start) - local l = nil - while s do - local lg = lookupmatch[getchar(s)] - if lg then - l = lg - s = getnext(s) - else - break - end - end - if l and l.ligature then - return true - end + if a then + for i=1,nofsteps do + local step = steps[i] + local lookupcache = step.coverage + if lookupcache then + local lookupmatch = lookupcache[char] + if lookupmatch then + -- we could move all code inline but that makes things even more unreadable + local ok + head, start, ok = handler(head,start,dataset,sequence,lookupmatch,rlmode,step,i) + if ok then + success = true + break + elseif not start then + -- don't ask why ... shouldn't happen + break + -- elseif gpossing and zwnjruns and char == zwnj then + -- discrun(start,d_run,font,attr,steps,nofsteps) end - else - report_missing_cache(dataset,sequence) + -- elseif gpossing and zwnjruns and char == zwnj then + -- discrun(start,d_run,font,attr,steps,nofsteps) end + else + report_missing_coverage(dataset,sequence) end end - start = getnext(start) - else - break - end - end - end - - while start do - local id = getid(start) - if id == glyph_code then - local char = ischar(start,font) - if char then - local a = getattr(start,0) - if a then - a = (a == attr) and (not attribute or getprop(start,a_state) == attribute) - else - a = not attribute or getprop(start,a_state) == attribute - end - if a then - for i=1,nofsteps do - local step = steps[i] - local lookupcache = step.coverage - if lookupcache then - -- local char = getchar(start) - local lookupmatch = lookupcache[char] - if lookupmatch then - -- we could move all code inline but that makes things even more unreadable - local ok - head, start, ok = handler(head,start,dataset,sequence,lookupmatch,rlmode,step,i) - if ok then - success = true - break - elseif not start then - -- don't ask why ... shouldn't happen - break - elseif gpossing and zwnjruns and char == zwnj then - discrun(start,d_run) - end - elseif gpossing and zwnjruns and char == zwnj then - discrun(start,d_run) - end - else - report_missing_cache(dataset,sequence) - end - end - if start then start = getnext(start) end - else + if start then start = getnext(start) end else start = getnext(start) end + elseif char == false then + start = getnext(start) elseif id == disc_code then + local ok if gpossing then - kernrun(start,k_run) - start = getnext(start) + start, ok = kernrun(start,k_run_multiple, font,attr,steps,nofsteps,dataset,sequence,rlmode,handler) elseif typ == "gsub_ligature" then - start = testrun(start,t_run,c_run) + start, ok = testrun(start,t_run_multiple,c_run_multiple,font,attr,steps,nofsteps,dataset,sequence,rlmode,handler) else - comprun(start,c_run) - start = getnext(start) + start, ok = comprun(start,c_run_multiple, font,attr,steps,nofsteps,dataset,sequence,rlmode,handler) + end + if ok then + success = true end elseif id == math_code then start = getnext(end_of_math(start)) elseif id == dir_code then - local dir = getfield(start,"dir") - if dir == "+TLT" then - topstack = topstack + 1 - dirstack[topstack] = dir - rlmode = 1 - elseif dir == "+TRT" then - topstack = topstack + 1 - dirstack[topstack] = dir - rlmode = -1 - elseif dir == "-TLT" or dir == "-TRT" then - topstack = topstack - 1 - rlmode = dirstack[topstack] == "+TRT" and -1 or 1 - else - rlmode = rlparmode - end - if trace_directions then - report_process("directions after txtdir %a: parmode %a, txtmode %a, # stack %a, new dir %a",dir,mref(rlparmode),mref(rlmode),topstack,mref(newdir)) - end - start = getnext(start) + start, topstack, rlmode = txtdirstate(start,dirstack,topstack,rlparmode) elseif id == localpar_code then - local dir = getfield(start,"dir") - if dir == "TRT" then - rlparmode = -1 - elseif dir == "TLT" then - rlparmode = 1 - else - rlparmode = 0 - end - rlmode = rlparmode - if trace_directions then - report_process("directions after pardir %a: parmode %a, txtmode %a",dir,mref(rlparmode),mref(rlmode)) - end - start = getnext(start) + start, rlparmode, rlmode = pardirstate(start) else start = getnext(start) end end end end + if success then done = true end @@ -3711,3 +3578,129 @@ registerotffeature { -- This can be used for extra handlers, but should be used with care! otf.handlers = handlers -- used in devanagari + +-- We implement one here: + +local setspacekerns = nodes.injections.setspacekerns if not setspacekerns then os.exit() end + +function otf.handlers.trigger_space_kerns(head,start,dataset,sequence,_,_,_,_,font,attr) + -- if not setspacekerns then + -- setspacekerns = nodes.injections.setspacekerns + -- end + setspacekerns(font,sequence) + return head, start, true +end + +local function hasspacekerns(data) + local sequences = data.resources.sequences + for i=1,#sequences do + local sequence = sequences[i] + local steps = sequence.steps + if steps and sequence.features.kern then + for i=1,#steps do + local coverage = steps[i].coverage + if not coverage then + -- maybe an issue + elseif coverage[32] then + return true + else + for k, v in next, coverage do + if v[32] then + return true + end + end + end + end + end + end + return false +end + +otf.readers.registerextender { + name = "spacekerns", + action = function(data) + data.properties.hasspacekerns = hasspacekerns(data) + end +} + +local function spaceinitializer(tfmdata,value) -- attr + local resources = tfmdata.resources + local spacekerns = resources and resources.spacekerns + if spacekerns == nil then + local properties = tfmdata.properties + if properties and properties.hasspacekerns then + local sequences = resources.sequences + local left = { } + local right = { } + local last = 0 + local feat = nil + for i=1,#sequences do + local sequence = sequences[i] + local steps = sequence.steps + if steps then + local kern = sequence.features.kern + if kern then + feat = feat or kern -- or maybe merge + for i=1,#steps do + local step = steps[i] + local coverage = step.coverage + if coverage then + local kerns = coverage[32] + if kerns then + for k, v in next, kerns do + right[k] = v + end + end + for k, v in next, coverage do + local kern = v[32] + if kern then + left[k] = kern + end + end + end + end + last = i + end + else + -- no steps ... needed for old one ... we could use the basekerns + -- instead + end + end + left = next(left) and left or false + right = next(right) and right or false + if left or right then + spacekerns = { + left = left, + right = right, + } + if last > 0 then + local triggersequence = { + features = { kern = feat or { dflt = { dflt = true, } } }, + flags = noflags, + name = "trigger_space_kerns", + order = { "kern" }, + type = "trigger_space_kerns", + left = left, + right = right, + } + insert(sequences,last,triggersequence) + end + else + spacekerns = false + end + else + spacekerns = false + end + resources.spacekerns = spacekerns + end + return spacekerns +end + +registerotffeature { + name = "spacekern", + description = "space kern injection", + default = true, + initializers = { + node = spaceinitializer, + }, +} diff --git a/tex/context/base/mkiv/font-pre.mkiv b/tex/context/base/mkiv/font-pre.mkiv index 17adc5290..584bd1779 100644 --- a/tex/context/base/mkiv/font-pre.mkiv +++ b/tex/context/base/mkiv/font-pre.mkiv @@ -541,6 +541,7 @@ \definefontstyle [\v!teletype,\v!type,\v!mono] [\s!tt] \definefontstyle [\v!handwritten] [\s!hw] \definefontstyle [\v!calligraphic] [\s!cg] +\definefontstyle [\v!math,\v!mathematics] [\s!mm] \definefontalternative[\s!tf] \definefontalternative[\s!bf] @@ -558,7 +559,6 @@ \definealternativestyle [\v!bold] [\bf] [] \definealternativestyle [\v!type] [\tt] [] \definealternativestyle [\v!mono] [\tt] [] -\definealternativestyle [\v!monobold] [\tt\bf] [] \definealternativestyle [\v!slanted] [\sl] [] \definealternativestyle [\v!italic] [\it] [] \definealternativestyle [\v!boldslanted,\v!slantedbold] [\bs] [] @@ -567,7 +567,7 @@ \definealternativestyle [\v!small,\v!smallnormal] [\setsmallbodyfont\tf] [] \definealternativestyle [\v!smallbold] [\setsmallbodyfont\bf] [] \definealternativestyle [\v!smalltype] [\setsmallbodyfont\tt] [] -\definealternativestyle [\v!smallslanted] [\setsmallbodyfont\sl] [] +\definealternativestyle [\v!smallitalic,\v!smallslanted] [\setsmallbodyfont\sl] [] \definealternativestyle [\v!smallboldslanted,\v!smallslantedbold] [\setsmallbodyfont\bs] [] \definealternativestyle [\v!smallbolditalic,\v!smallitalicbold] [\setsmallbodyfont\bi] [] @@ -586,6 +586,13 @@ \definealternativestyle [\v!mononormal] [\tt\tf] [] \definealternativestyle [\v!monobold] [\tt\bf] [] +% For Alan: + +\definealternativestyle + [\v!camel] + [{\setcharactercasing[\v!camel]}] + [{\setcharactercasing[\v!camel]}] + % % maybe we need interface neutral as well (for use in cld): % % \letcscsname\mediaeval \csname\v!mediaeval \endcsname diff --git a/tex/context/base/mkiv/font-sol.lua b/tex/context/base/mkiv/font-sol.lua index eca51cd61..8d45552a5 100644 --- a/tex/context/base/mkiv/font-sol.lua +++ b/tex/context/base/mkiv/font-sol.lua @@ -63,7 +63,6 @@ local getid = nuts.getid local getattr = nuts.getattr local getfont = nuts.getfont local getsubtype = nuts.getsubtype -local getchar = nuts.getchar local getlist = nuts.getlist local setfield = nuts.setfield diff --git a/tex/context/base/mkiv/font-syn.lua b/tex/context/base/mkiv/font-syn.lua index f750f92e9..dc090a1d9 100644 --- a/tex/context/base/mkiv/font-syn.lua +++ b/tex/context/base/mkiv/font-syn.lua @@ -2041,6 +2041,10 @@ function names.resolvespec(askedname,sub) -- overloads previous definition end end +function fonts.names.ignoredfile(filename) -- only supported in mkiv + return false -- will be overloaded +end + -- We could generate typescripts with designsize info from the name database but -- it's not worth the trouble as font names remain a mess: for instance how do we -- idenfity a font? Names, families, subfamilies or whatever snippet can contain diff --git a/tex/context/base/mkiv/font-xtx.lua b/tex/context/base/mkiv/font-xtx.lua new file mode 100644 index 000000000..494ac00a9 --- /dev/null +++ b/tex/context/base/mkiv/font-xtx.lua @@ -0,0 +1,97 @@ +if not modules then modules = { } end modules ['luatex-fonts-def'] = { + version = 1.001, + comment = "companion to luatex-*.tex", + author = "Hans Hagen, PRAGMA-ADE, Hasselt NL", + copyright = "PRAGMA ADE / ConTeXt Development Team", + license = "see context related readme files" +} + +if context then + texio.write_nl("fatal error: this module is not for context") + os.exit() +end + +local fonts = fonts + +-- A bit of tuning for definitions. + +fonts.constructors.namemode = "specification" -- somehow latex needs this (changed name!) => will change into an overload + +-- tricky: we sort of bypass the parser and directly feed all into +-- the sub parser + +function fonts.definers.getspecification(str) + return "", str, "", ":", str +end + +-- the generic name parser (different from context!) + +local list = { } + +local function issome () list.lookup = 'name' end -- xetex mode prefers name (not in context!) +local function isfile () list.lookup = 'file' end +local function isname () list.lookup = 'name' end +local function thename(s) list.name = s end +local function issub (v) list.sub = v end +local function iscrap (s) list.crap = string.lower(s) end +local function iskey (k,v) list[k] = v end +local function istrue (s) list[s] = true end +local function isfalse(s) list[s] = false end + +local P, S, R, C = lpeg.P, lpeg.S, lpeg.R, lpeg.C + +local spaces = P(" ")^0 +local namespec = (1-S("/:("))^0 -- was: (1-S("/: ("))^0 +local crapspec = spaces * P("/") * (((1-P(":"))^0)/iscrap) * spaces +local filename_1 = P("file:")/isfile * (namespec/thename) +local filename_2 = P("[") * P(true)/isname * (((1-P("]"))^0)/thename) * P("]") +local fontname_1 = P("name:")/isname * (namespec/thename) +local fontname_2 = P(true)/issome * (namespec/thename) +local sometext = (R("az","AZ","09") + S("+-.{}"))^1 +local truevalue = P("+") * spaces * (sometext/istrue) +local falsevalue = P("-") * spaces * (sometext/isfalse) +local keyvalue = (C(sometext) * spaces * P("=") * spaces * C(sometext))/iskey +local somevalue = sometext/istrue +local subvalue = P("(") * (C(P(1-S("()"))^1)/issub) * P(")") -- for Kim +local option = spaces * (keyvalue + falsevalue + truevalue + somevalue) * spaces +local options = P(":") * spaces * (P(";")^0 * option)^0 + +local pattern = (filename_1 + filename_2 + fontname_1 + fontname_2) * subvalue^0 * crapspec^0 * options^0 + +local function colonized(specification) -- xetex mode + list = { } + lpeg.match(pattern,specification.specification) + list.crap = nil -- style not supported, maybe some day + if list.name then + specification.name = list.name + list.name = nil + end + if list.lookup then + specification.lookup = list.lookup + list.lookup = nil + end + if list.sub then + specification.sub = list.sub + list.sub = nil + end + specification.features.normal = fonts.handlers.otf.features.normalize(list) + return specification +end + +fonts.definers.registersplit(":",colonized,"cryptic") +fonts.definers.registersplit("", colonized,"more cryptic") -- catches \font\text=[names] + +function fonts.definers.applypostprocessors(tfmdata) + local postprocessors = tfmdata.postprocessors + if postprocessors then + for i=1,#postprocessors do + local extrahash = postprocessors[i](tfmdata) -- after scaling etc + if type(extrahash) == "string" and extrahash ~= "" then + -- e.g. a reencoding needs this + extrahash = string.gsub(lower(extrahash),"[^a-z]","-") + tfmdata.properties.fullname = format("%s-%s",tfmdata.properties.fullname,extrahash) + end + end + end + return tfmdata +end diff --git a/tex/context/base/mkiv/lang-dis.lua b/tex/context/base/mkiv/lang-dis.lua index ab62cc479..84d9b2d5b 100644 --- a/tex/context/base/mkiv/lang-dis.lua +++ b/tex/context/base/mkiv/lang-dis.lua @@ -29,6 +29,7 @@ local setsubtype = nuts.setsubtype local getchar = nuts.getchar local getdisc = nuts.getdisc local setdisc = nuts.setdisc +local isglyph = nuts.isglyph local copy_node = nuts.copy local free_node = nuts.free @@ -59,13 +60,19 @@ local expanders = { -- \- local pre, post, replace = getdisc(d) local done = false - if pre and getid(pre) == glyph_code and getchar(pre) <= 0 then - done = true - pre = nil + if pre then + local char = isglyph(pre) + if char and char <= 0 then + done = true + pre = nil + end end - if post and getid(post) == glyph_code and getchar(post) <= 0 then - done = true - post = nil + if post then + local char = isglyph(post) + if char and char <= 0 then + done = true + post = nil + end end if done then setdisc(d,pre,post,replace,discretionary_code,tex.exhyphenpenalty) diff --git a/tex/context/base/mkiv/lang-hyp.lua b/tex/context/base/mkiv/lang-hyp.lua index dad0f5232..65337143d 100644 --- a/tex/context/base/mkiv/lang-hyp.lua +++ b/tex/context/base/mkiv/lang-hyp.lua @@ -8,6 +8,8 @@ if not modules then modules = { } end modules ['lang-hyp'] = { -- todo: hyphenate over range if needed +-- setattr: helper for full attr + -- to be considered: reset dictionary.hyphenated when a pattern is added -- or maybe an explicit reset of the cache @@ -610,16 +612,17 @@ if context then local new_disc = nodepool.disc local new_glyph = nodepool.glyph + local new_penalty = nodepool.penalty local getfield = nuts.getfield local getfont = nuts.getfont - local getchar = nuts.getchar local getid = nuts.getid local getattr = nuts.getattr local getnext = nuts.getnext local getprev = nuts.getprev local getsubtype = nuts.getsubtype local getlist = nuts.getlist + local isglyph = nuts.isglyph local setfield = nuts.setfield local setchar = nuts.setchar @@ -638,6 +641,7 @@ if context then local variables = interfaces.variables local v_reset = variables.reset local v_yes = variables.yes + local v_word = variables.word local v_all = variables.all local settings_to_array = utilities.parsers.settings_to_array @@ -652,6 +656,8 @@ if context then local a_hyphenation = attributes.private("hyphenation") + local interwordpenalty = 5000 + function traditional.loadpatterns(language) return dictionaries[language] end @@ -828,9 +834,10 @@ if context then local rightedge = featureset.rightedge local leftchar = somehyphenchar(featureset.leftchar) local rightchar = somehyphenchar(featureset.rightchar) - -- - joinerchars = joinerchars == v_yes and defaultjoiners or joinerchars - hyphenchars = hyphenchars == v_yes and defaulthyphens or hyphenchars + local rightchars = featureset.rightchars + rightchars = rightchars == v_word and true or tonumber(rightchars) + joinerchars = joinerchars == v_yes and defaultjoiners or joinerchars + hyphenchars = hyphenchars == v_yes and defaulthyphens or hyphenchars -- not yet ok: extrachars have to be ignored so it cannot be all) featureset.extrachars = makeset(joinerchars or "",extrachars or "") featureset.hyphenchars = makeset(hyphenchars or "") @@ -839,6 +846,7 @@ if context then featureset.charmin = charmin and charmin > 0 and charmin or nil featureset.leftcharmin = leftcharmin and leftcharmin > 0 and leftcharmin or nil featureset.rightcharmin = rightcharmin and rightcharmin > 0 and rightcharmin or nil + featureset.rightchars = rightchars featureset.leftchar = leftchar featureset.rightchar = rightchar featureset.strict = rightedge == 'tex' @@ -883,6 +891,7 @@ if context then { "characters" }, { "hyphens" }, { "joiners" }, + { "rightchars" }, { "rightwordmin", "integer" }, { "charmin", "integer" }, { "leftcharmin", "integer" }, @@ -980,6 +989,7 @@ if context then local rightcharmin = nil ----- leftwordmin = nil local rightwordmin = nil + local rightchars = nil local leftchar = nil local rightchar = nil local attr = nil @@ -1000,6 +1010,16 @@ if context then starttiming(traditional) + local function insertpenalty() + local p = new_penalty(interwordpenalty) + setfield(p,"attr",getfield(last,"attr")) + if trace_visualize then + nuts.setvisual(p,"penalty") + end + last = getprev(last) + first, last = insert_after(first,last,p) + end + local function synchronizefeatureset(a) local f = a and featuresets[a] if f then @@ -1013,6 +1033,7 @@ if context then leftchar = f.leftchar rightchar = f.rightchar strict = f.strict and strictids + rightchars = f.rightchars if rightwordmin and rightwordmin > 0 and lastwordlast ~= rightwordmin then -- so we can change mid paragraph but it's kind of unpredictable then if not tail then @@ -1020,16 +1041,25 @@ if context then end last = tail local inword = false + local count = 0 while last and rightwordmin > 0 do local id = getid(last) if id == glyph_code then + count = count + 1 inword = true if trace_visualize then - setcolor(last,"darkred") + setcolor(last,"darkgreen") end elseif inword then inword = false rightwordmin = rightwordmin - 1 + if rightchars == true then + if rightwordmin > 0 then + insertpenalty() + end + elseif rightchars and count <= rightchars then + insertpenalty() + end end last = getprev(last) end @@ -1283,9 +1313,8 @@ if context then -- for extensions. while current and current ~= last do -- and current - local id = getid(current) - if id == glyph_code then - local code = getchar(current) + local code, id = isglyph(current) + if code then local lang = getfield(current,"lang") if lang ~= language then if dictionary and size > charmin and leftmin + rightmin <= size then diff --git a/tex/context/base/mkiv/lang-hyp.mkiv b/tex/context/base/mkiv/lang-hyp.mkiv index e3f032c6b..ca9113386 100644 --- a/tex/context/base/mkiv/lang-hyp.mkiv +++ b/tex/context/base/mkiv/lang-hyp.mkiv @@ -107,6 +107,7 @@ \letdummyparameter\s!righthyphenchar\zerocount \letdummyparameter\c!alternative\empty \letdummyparameter\c!rightedge\empty + \letdummyparameter\c!rightchars\empty \getdummyparameters[#2]% \clf_definehyphenationfeatures {#1}% @@ -115,6 +116,7 @@ hyphens {\dummyparameter\c!hyphens}% joiners {\dummyparameter\c!joiners}% rightwordmin \numexpr\dummyparameter\c!rightwords\relax + rightchars {\dummyparameter\c!rightchars}% charmin \numexpr\dummyparameter\s!hyphenmin\relax leftcharmin \numexpr\dummyparameter\s!lefthyphenmin\relax rightcharmin \numexpr\dummyparameter\s!righthyphenmin\relax diff --git a/tex/context/base/mkiv/lang-rep.lua b/tex/context/base/mkiv/lang-rep.lua index ec82b7b19..28f2e5d50 100644 --- a/tex/context/base/mkiv/lang-rep.lua +++ b/tex/context/base/mkiv/lang-rep.lua @@ -49,6 +49,7 @@ local getprev = nuts.getprev local getattr = nuts.getattr local getid = nuts.getid local getchar = nuts.getchar +local isglyph = nuts.isglyph local setfield = nuts.setfield local setattr = nuts.setattr @@ -146,23 +147,28 @@ local function hit(a,head) local current = getnext(head) local lastrun = false local lastfinal = false - while current and getid(current) == glyph_code do - local newroot = root[getchar(current)] - if not newroot then - return lastrun, lastfinal - else - local final = newroot.final - if final then - if trace_detail then - report_replacement("hitting word %a, replacement %a",final.word,final.replacement) - end - lastrun = current - lastfinal = final + while current do + local char = isglyph(current) + if char then + local newroot = root[char] + if not newroot then + return lastrun, lastfinal else - root = newroot + local final = newroot.final + if final then + if trace_detail then + report_replacement("hitting word %a, replacement %a",final.word,final.replacement) + end + lastrun = current + lastfinal = final + else + root = newroot + end end + current = getnext(current) + else + break end - current = getnext(current) end if lastrun then return lastrun, lastfinal diff --git a/tex/context/base/mkiv/lang-wrd.lua b/tex/context/base/mkiv/lang-wrd.lua index 7d625fa9e..38e6187af 100644 --- a/tex/context/base/mkiv/lang-wrd.lua +++ b/tex/context/base/mkiv/lang-wrd.lua @@ -38,6 +38,7 @@ local getid = nuts.getid local getsubtype = nuts.getsubtype local getchar = nuts.getchar local setattr = nuts.setattr +local isglyph = nuts.isglyph local traverse_nodes = nuts.traverse local traverse_ids = nuts.traverse_id @@ -158,8 +159,8 @@ local function mark_words(head,whenfound) -- can be optimized and shared -- we haven't done the fonts yet so we have characters (otherwise -- we'd have to use the tounicodes) while current do - local id = getid(current) - if id == glyph_code then + local code, id = isglyph(current) + if code then local a = getfield(current,"lang") if a then if a ~= language then @@ -172,7 +173,6 @@ local function mark_words(head,whenfound) -- can be optimized and shared action() language = a end - local code = getchar(current) local data = chardata[code] if is_letter[data.category] then n = n + 1 diff --git a/tex/context/base/mkiv/lpdf-ini.lua b/tex/context/base/mkiv/lpdf-ini.lua index e2a85bccf..0d96abb7d 100644 --- a/tex/context/base/mkiv/lpdf-ini.lua +++ b/tex/context/base/mkiv/lpdf-ini.lua @@ -12,6 +12,7 @@ local setmetatable, getmetatable, type, next, tostring, tonumber, rawset = setme local char, byte, format, gsub, concat, match, sub, gmatch = string.char, string.byte, string.format, string.gsub, table.concat, string.match, string.sub, string.gmatch local utfchar, utfbyte, utfvalues = utf.char, utf.byte, utf.values local sind, cosd, floor, max, min = math.sind, math.cosd, math.floor, math.max, math.min +local sort = table.sort local lpegmatch, P, C, R, S, Cc, Cs = lpeg.match, lpeg.P, lpeg.C, lpeg.R, lpeg.S, lpeg.Cc, lpeg.Cs local formatters = string.formatters local isboolean = string.is_boolean @@ -369,34 +370,85 @@ local f_tonumber = formatters["%F"] local tostring_a, tostring_d +-- tostring_d = function(t,contentonly,key) +-- if next(t) then +-- local r, rn = { }, 0 +-- for k, v in next, t do +-- -- for k, v in sortedhash(t) do -- can be an option +-- rn = rn + 1 +-- local tv = type(v) +-- if tv == "string" then +-- r[rn] = f_key_value(k,toeight(v)) +-- elseif tv == "number" then +-- r[rn] = f_key_number(k,v) +-- -- elseif tv == "unicode" then -- can't happen +-- -- r[rn] = f_key_value(k,tosixteen(v)) +-- elseif tv == "table" then +-- local mv = getmetatable(v) +-- if mv and mv.__lpdftype then +-- -- if v == t then +-- -- report_objects("ignoring circular reference in dirctionary") +-- -- r[rn] = f_key_null(k) +-- -- else +-- r[rn] = f_key_value(k,tostring(v)) +-- -- end +-- elseif v[1] then +-- r[rn] = f_key_value(k,tostring_a(v)) +-- else +-- r[rn] = f_key_value(k,tostring_d(v)) +-- end +-- else +-- r[rn] = f_key_value(k,tostring(v)) +-- end +-- end +-- if contentonly then +-- return concat(r," ") +-- elseif key then +-- return f_key_dictionary(key,r) +-- else +-- return f_dictionary(r) +-- end +-- elseif contentonly then +-- return "" +-- else +-- return "<< >>" +-- end +-- end + tostring_d = function(t,contentonly,key) if next(t) then - local r, rn = { }, 0 - for k, v in next, t do - rn = rn + 1 + local r, n = { }, 0 + for k in next, t do + n = n + 1 + r[n] = k + end + sort(r) + for i=1,n do + local k = r[i] + local v = t[k] local tv = type(v) if tv == "string" then - r[rn] = f_key_value(k,toeight(v)) + r[i] = f_key_value(k,toeight(v)) elseif tv == "number" then - r[rn] = f_key_number(k,v) + r[i] = f_key_number(k,v) -- elseif tv == "unicode" then -- can't happen - -- r[rn] = f_key_value(k,tosixteen(v)) + -- r[i] = f_key_value(k,tosixteen(v)) elseif tv == "table" then local mv = getmetatable(v) if mv and mv.__lpdftype then -- if v == t then -- report_objects("ignoring circular reference in dirctionary") - -- r[rn] = f_key_null(k) + -- r[i] = f_key_null(k) -- else - r[rn] = f_key_value(k,tostring(v)) + r[i] = f_key_value(k,tostring(v)) -- end elseif v[1] then - r[rn] = f_key_value(k,tostring_a(v)) + r[i] = f_key_value(k,tostring_a(v)) else - r[rn] = f_key_value(k,tostring_d(v)) + r[i] = f_key_value(k,tostring_d(v)) end else - r[rn] = f_key_value(k,tostring(v)) + r[i] = f_key_value(k,tostring(v)) end end if contentonly then diff --git a/tex/context/base/mkiv/lxml-ini.mkiv b/tex/context/base/mkiv/lxml-ini.mkiv index 1770d087c..6fa14ddfc 100644 --- a/tex/context/base/mkiv/lxml-ini.mkiv +++ b/tex/context/base/mkiv/lxml-ini.mkiv @@ -45,15 +45,12 @@ % aliased \let\xmlall \clf_xmlall -\let\xmllastmatch \clf_xmllastmatch \let\xmlatt \clf_xmlatt -\let\xmllastatt \clf_xmllastatt \let\xmlattdef \clf_xmlattdef \let\xmlattribute \clf_xmlattribute \let\xmlattributedef \clf_xmlattributedef \let\xmlchainatt \clf_xmlchainatt \let\xmlchainattdef \clf_xmlchainattdef -\let\xmlrefatt \clf_xmlrefatt \let\xmlchecknamespace \clf_xmlchecknamespace \let\xmlcommand \clf_xmlcommand \let\xmlcontext \clf_xmlcontext @@ -71,7 +68,9 @@ \let\xmlflush \clf_xmlflush \let\xmlflushcontext \clf_xmlflushcontext \let\xmlflushlinewise \clf_xmlflushlinewise +\let\xmlflushpure \clf_xmlflushpure \let\xmlflushspacewise \clf_xmlflushspacewise +\let\xmlflushtext \clf_xmlflushtext \let\xmlfunction \clf_xmlfunction \let\xmlinclude \clf_xmlinclude \let\xmlincludeoptions \clf_xmlincludeoptions @@ -79,18 +78,22 @@ \let\xmlinclusions \clf_xmlinclusions \let\xmlbadinclusions \clf_xmlbadinclusions \let\xmlindex \clf_xmlindex -\let\xmlposition \clf_xmlindex \let\xmlinlineverbatim \clf_xmlinlineverbatim \let\xmllast \clf_xmllast +\let\xmllastatt \clf_xmllastatt +\let\xmllastmatch \clf_xmllastmatch \let\xmlloaddirectives \clf_xmlloaddirectives \let\xmlmain \clf_xmlmain \let\xmlmatch \clf_xmlmatch -\let\xmlpath \clf_xmlpath \let\xmlname \clf_xmlname \let\xmlnamespace \clf_xmlnamespace \let\xmlnonspace \clf_xmlnonspace +\let\xmlpath \clf_xmlpath \let\xmlpos \clf_xmlpos +\let\xmlposition \clf_xmlindex +\let\xmlpure \clf_xmlpure \let\xmlraw \clf_xmlraw +\let\xmlrefatt \clf_xmlrefatt \let\xmlregisterns \clf_xmlregisterns % document \let\xmlremapname \clf_xmlremapname % element \let\xmlremapnamespace \clf_xmlremapnamespace % document @@ -104,16 +107,12 @@ \let\xmlstrippednolines \clf_xmlstrippednolines \let\xmltag \clf_xmltag \let\xmltext \clf_xmltext -\let\xmlpure \clf_xmlpure \let\xmltobuffer \clf_xmltobuffer % id pattern name \let\xmltobufferverbose \clf_xmltobufferverbose % id pattern name \let\xmltofile \clf_xmltofile % id pattern filename \let\xmltoparameters \clf_xmltoparameters \let\xmlverbatim \clf_xmlverbatim -\let\xmlflushtext \clf_xmlflushtext -\let\xmlflushpure \clf_xmlflushpure - \unexpanded\def\xmlinfo #1{\hbox{\ttxx[\clf_xmlname{#1}]}} \unexpanded\def\xmlshow #1{\startpacked\ttx\xmlverbatim{#1}\stoppacked} diff --git a/tex/context/base/mkiv/lxml-tab.lua b/tex/context/base/mkiv/lxml-tab.lua index b03c7eb43..60d6262c7 100644 --- a/tex/context/base/mkiv/lxml-tab.lua +++ b/tex/context/base/mkiv/lxml-tab.lua @@ -36,6 +36,7 @@ local xml = xml local concat, remove, insert = table.concat, table.remove, table.insert local type, next, setmetatable, getmetatable, tonumber, rawset = type, next, setmetatable, getmetatable, tonumber, rawset local lower, find, match, gsub = string.lower, string.find, string.match, string.gsub +local sort = table.sort local utfchar = utf.char local lpegmatch, lpegpatterns = lpeg.match, lpeg.patterns local P, S, R, C, V, C, Cs = lpeg.P, lpeg.S, lpeg.R, lpeg.C, lpeg.V, lpeg.C, lpeg.Cs @@ -1316,29 +1317,44 @@ and then handle the lot.</p> local f_attribute = formatters['%s=%q'] +-- we could reuse ats + local function verbose_element(e,handlers,escape) -- options local handle = handlers.handle local serialize = handlers.serialize local ens, etg, eat, edt, ern = e.ns, e.tg, e.at, e.dt, e.rn local ats = eat and next(eat) and { } if ats then + -- we now sort attributes local n = 0 - for k,v in next, eat do + for k in next, eat do n = n + 1 - ats[n] = f_attribute(k,escaped(v)) + ats[n] = k + end + if n == 1 then + local k = ats[1] + ats = f_attribute(k,escaped(eat[k])) + else + sort(ats) + for i=1,n do + local k = ats[i] + ats[i] = f_attribute(k,escaped(eat[k])) + end + ats = concat(ats," ") end end if ern and trace_entities and ern ~= ens then ens = ern end + local n = edt and #edt if ens ~= "" then - if edt and #edt > 0 then + if n and n > 0 then if ats then - handle("<",ens,":",etg," ",concat(ats," "),">") + handle("<",ens,":",etg," ",ats,">") else handle("<",ens,":",etg,">") end - for i=1,#edt do + for i=1,n do local e = edt[i] if type(e) == "string" then handle(escaped(e)) @@ -1349,19 +1365,19 @@ local function verbose_element(e,handlers,escape) -- options handle("</",ens,":",etg,">") else if ats then - handle("<",ens,":",etg," ",concat(ats," "),"/>") + handle("<",ens,":",etg," ",ats,"/>") else handle("<",ens,":",etg,"/>") end end else - if edt and #edt > 0 then + if n and n > 0 then if ats then - handle("<",etg," ",concat(ats," "),">") + handle("<",etg," ",ats,">") else handle("<",etg,">") end - for i=1,#edt do + for i=1,n do local e = edt[i] if type(e) == "string" then handle(escaped(e)) -- option: hexify escaped entities @@ -1372,7 +1388,7 @@ local function verbose_element(e,handlers,escape) -- options handle("</",etg,">") else if ats then - handle("<",etg," ",concat(ats," "),"/>") + handle("<",etg," ",ats,"/>") else handle("<",etg,"/>") end diff --git a/tex/context/base/mkiv/math-ini.mkiv b/tex/context/base/mkiv/math-ini.mkiv index d20278c9b..8627436b7 100644 --- a/tex/context/base/mkiv/math-ini.mkiv +++ b/tex/context/base/mkiv/math-ini.mkiv @@ -1331,7 +1331,7 @@ % \setupmathematics % [\v!autopunctuation=\v!no] % -% \def\math_punctuation_next{\ifx\nexttoken\blankspace\char\zerocount\fi} +% \def\math_punctuation_next{\ifx\nexttoken\blankspace\signalcharacter\fi} % % \unexpanded\def\math_punctuation_comma {\textcomma \futurelet\nexttoken\math_punctuation_next} % \unexpanded\def\math_punctuation_period{\textperiod\futurelet\nexttoken\math_punctuation_next} diff --git a/tex/context/base/mkiv/math-noa.lua b/tex/context/base/mkiv/math-noa.lua index 878b1e9a1..d3409e01b 100644 --- a/tex/context/base/mkiv/math-noa.lua +++ b/tex/context/base/mkiv/math-noa.lua @@ -170,9 +170,6 @@ local math_style = nodecodes.style -- attr style local math_choice = nodecodes.choice -- attr display text script scriptscript local math_fence = nodecodes.fence -- attr subtype -local hlist_code = nodecodes.hlist -local glyph_code = nodecodes.glyph - local left_fence_code = fencecodes.left local middle_fence_code = fencecodes.middle local right_fence_code = fencecodes.right @@ -198,8 +195,8 @@ local function process(start,what,n,parent) report_processing("%w%S, class %a",n*2,nutstring(start),noadcodes[getsubtype(start)]) elseif id == math_char then local char = getchar(start) + local font = getfont(start) local fam = getfield(start,"fam") - local font = font_of_family(fam) report_processing("%w%S, family %a, font %a, char %a, shape %c",n*2,nutstring(start),fam,font,char,char) else report_processing("%w%S",n*2,nutstring(start)) @@ -531,8 +528,6 @@ do local function checked(pointer) local char = getchar(pointer) - -- local fam = getfield(pointer,"fam") - -- local font = font_of_family(fam) local font = getfont(pointer) local data = fontcharacters[font] if not data[char] then @@ -556,8 +551,6 @@ do local g = getattr(pointer,a_mathgreek) or 0 local a = getattr(pointer,a_mathalphabet) or 0 local char = getchar(pointer) - -- local fam = getfield(pointer,"fam") - -- local font = font_of_family(fam) local font = getfont(pointer) local characters = fontcharacters[font] if a > 0 or g > 0 then @@ -648,8 +641,6 @@ processors.render[math_char] = function(pointer) if renderset then local newchar = renderset[char] if newchar then - -- local fam = getfield(pointer,"fam") - -- local font = font_of_family(fam) local font = getfont(pointer) local characters = fontcharacters[font] if characters and characters[newchar] then @@ -1110,7 +1101,6 @@ alternate[math_char] = function(pointer) local a = getattr(pointer,a_mathalternate) if a and a > 0 then setattr(pointer,a_mathalternate,0) - -- local tfmdata = fontdata[font_of_family(getfield(pointer,"fam"))] local tfmdata = fontdata[getfont(pointer)] local resources = tfmdata.resources -- was tfmdata.shared if resources then @@ -1239,7 +1229,6 @@ italics[math_char] = function(pointer,what,n,parent) local method = getattr(pointer,a_mathitalics) if method and method > 0 and method < 100 then local char = getchar(pointer) - -- local font = font_of_family(getfield(pointer,"fam")) -- todo: table local font = getfont(pointer) local correction, visual = getcorrection(method,font,char) if correction and correction ~= 0 then @@ -1357,7 +1346,7 @@ local validpair = { } local function movesubscript(parent,current_nucleus,current_char) - local prev = getfield(parent,"prev") + local prev = getprev(parent) if prev and getid(prev) == math_noad then if not getfield(prev,"sup") and not getfield(prev,"sub") then -- {f} {'}_n => f_n^' @@ -1407,8 +1396,6 @@ local function collapsepair(pointer,what,n,parent,nested) -- todo: switch to tur if getid(next_nucleus) == math_char then local newchar = mathpair[next_char] if newchar then - -- local fam = getfield(current_nucleus,"fam") - -- local id = font_of_family(fam) local id = getfont(current_nucleus) local characters = fontcharacters[id] if characters and characters[newchar] then @@ -1487,7 +1474,6 @@ variants[math_char] = function(pointer,what,n,parent) -- also set export value local nucleus = getfield(next,"nucleus") if nucleus and getid(nucleus) == math_char and getchar(nucleus) == selector then local variant - -- local tfmdata = fontdata[font_of_family(getfield(pointer,"fam"))] -- we can also have a famdata local tfmdata = fontdata[getfont(pointer)] local mathvariants = tfmdata.resources.variants -- and variantdata if mathvariants then diff --git a/tex/context/base/mkiv/mult-def.lua b/tex/context/base/mkiv/mult-def.lua index 7a6268876..47f6518c4 100644 --- a/tex/context/base/mkiv/mult-def.lua +++ b/tex/context/base/mkiv/mult-def.lua @@ -10134,6 +10134,9 @@ return { ["rightwords"]={ ["en"]="rightwords", }, + ["rightchars"]={ + ["en"]="rightchars", + }, ["roffset"]={ ["en"]="roffset", }, diff --git a/tex/context/base/mkiv/mult-low.lua b/tex/context/base/mkiv/mult-low.lua index 9bf001352..bea7d6fee 100644 --- a/tex/context/base/mkiv/mult-low.lua +++ b/tex/context/base/mkiv/mult-low.lua @@ -338,6 +338,7 @@ return { "offinterlineskip", "oninterlineskip", "nointerlineskip", -- "strut", "halfstrut", "quarterstrut", "depthstrut", "setstrut", "strutbox", "strutht", "strutdp", "strutwd", "struthtdp", "begstrut", "endstrut", "lineheight", + "leftboundary", "rightboundary", "signalcharacter", -- "ordordspacing", "ordopspacing", "ordbinspacing", "ordrelspacing", "ordopenspacing", "ordclosespacing", "ordpunctspacing", "ordinnerspacing", diff --git a/tex/context/base/mkiv/mult-prm.lua b/tex/context/base/mkiv/mult-prm.lua index 931ffb007..4ecc006d0 100644 --- a/tex/context/base/mkiv/mult-prm.lua +++ b/tex/context/base/mkiv/mult-prm.lua @@ -420,6 +420,7 @@ return { "pdfinclusionerrorlevel", "pdfignoreunknownimages", "pdfinfo", + "pdfinfoid", "pdfinsertht", "pdflastannot", "pdflastlinedepth", @@ -471,6 +472,8 @@ return { "pdftexbanner", "pdftexrevision", "pdftexversion", + "pdfsuppressptexinfo", + "pdfsuppressoptionalinfo", "pdfthread", "pdfthreadmargin", "pdftracingfonts", @@ -1041,6 +1044,7 @@ return { "pdfinclusionerrorlevel", "pdfignoreunknownimages", "pdfinfo", + "pdfinfoid", "pdfinsertht", "pdflastannot", "pdflastlinedepth", @@ -1092,6 +1096,8 @@ return { "pdftexbanner", "pdftexrevision", "pdftexversion", + "pdfsuppressptexinfo", + "pdfsuppressoptionalinfo", "pdfthread", "pdfthreadmargin", "pdftracingfonts", diff --git a/tex/context/base/mkiv/node-fnt.lua b/tex/context/base/mkiv/node-fnt.lua index 5e6d8f3d3..76273cfd6 100644 --- a/tex/context/base/mkiv/node-fnt.lua +++ b/tex/context/base/mkiv/node-fnt.lua @@ -44,6 +44,7 @@ local getid = nuts.getid local getfont = nuts.getfont local getsubtype = nuts.getsubtype local getchar = nuts.getchar +local getdisc = nuts.getdisc local getnext = nuts.getnext local getprev = nuts.getprev local getfield = nuts.getfield @@ -52,6 +53,9 @@ local setchar = nuts.setchar local setlink = nuts.setlink local setfield = nuts.setfield +local isglyph = nuts.isglyph -- unchecked +local ischar = nuts.ischar -- checked + local traverse_id = nuts.traverse_id local traverse_char = nuts.traverse_char local delete_node = nuts.delete @@ -174,11 +178,11 @@ function handlers.characters(head) report_fonts() local n = tonut(head) while n do - local id = getid(n) - if id == glyph_code then + local char, id = isglyph(n) + if char then local font = getfont(n) local attr = getattr(n,0) or 0 - report_fonts("font %03i, dynamic %03i, glyph %C",font,attr,getchar(n)) + report_fonts("font %03i, dynamic %03i, glyph %C",font,attr,char) elseif id == disc_code then report_fonts("[disc] %s",nodes.listtoutf(n,true,false,n)) else @@ -244,8 +248,8 @@ function handlers.characters(head) local hash = variants[char] if hash then local p = getprev(n) - if p and getid(p) == glyph_code then - local char = getchar(p) + if p then + local char = ischar(p) -- checked local variant = hash[char] if variant then if trace_variants then @@ -285,8 +289,8 @@ function handlers.characters(head) -- local prevattr = 0 for d in traverse_id(disc_code,nuthead) do - -- we could use first_glyph - local r = getfield(d,"replace") -- good enough + -- we could use first_glyph, only doing replace is good enough + local _, _, r = getdisc(d) if r then for n in traverse_char(r) do local font = getfont(n) @@ -414,18 +418,18 @@ function handlers.characters(head) end else -- multiple fonts - local front = nuthead == start for i=1,b do local range = basefonts[i] local start = range[1] local stop = range[2] - if (start or stop) and (start ~= stop) then + if start then + local front = nuthead == start local prev, next if stop then next = getnext(stop) start, stop = ligaturing(start,stop) start, stop = kerning(start,stop) - elseif start then -- safeguard + else prev = getprev(start) start = ligaturing(start) start = kerning(start) @@ -436,18 +440,10 @@ function handlers.characters(head) if next then setlink(stop,next) end - if front then - nuthead = start - front = nil -- we assume a proper sequence + if front and nuthead ~= start then + head = tonode(nuthead) end end - if front then - -- shouldn't happen - nuthead = start - end - end - if front then - head = tonode(nuthead) end end stoptiming(nodes) @@ -457,198 +453,6 @@ function handlers.characters(head) return head, true end --- local formatters = string.formatters - --- local function make(processors,font,attribute) --- _G.__temp = processors --- local t = { } --- for i=1,#processors do --- if processors[i] then --- t[#t+1] = formatters["local p_%s = _G.__temp[%s]"](i,i) --- end --- end --- t[#t+1] = "return function(head,done)" --- if #processors == 1 then --- t[#t+1] = formatters["return p_%s(head,%s,%s)"](1,font,attribute or 0) --- else --- for i=1,#processors do --- if processors[i] then --- t[#t+1] = formatters["local h,d=p_%s(head,%s,%s) if d then head=h or head done=true end"](i,font,attribute or 0) --- end --- end --- t[#t+1] = "return head, done" --- end --- t[#t+1] = "end" --- t = concat(t,"\n") --- t = load(t)(processors) --- _G.__temp = nil --- return t --- end - --- setmetatableindex(fontprocesses, function(t,font) --- local tfmdata = fontdata[font] --- local shared = tfmdata.shared -- we need to check shared, only when same features --- local processes = shared and shared.processes --- if processes and #processes > 0 then --- processes = make(processes,font,0) --- t[font] = processes --- return processes --- else --- t[font] = false --- return false --- end --- end) - --- setmetatableindex(setfontdynamics, function(t,font) --- local tfmdata = fontdata[font] --- local shared = tfmdata.shared --- local f = shared and shared.dynamics and otf.setdynamics or false --- if f then --- local v = { } --- t[font] = v --- setmetatableindex(v,function(t,k) --- local v = f(font,k) --- v = make(v,font,k) --- t[k] = v --- return v --- end) --- return v --- else --- t[font] = false --- return false --- end --- end) --- --- -- TODO: basepasses! --- --- function handlers.characters(head) --- -- either next or not, but definitely no already processed list --- starttiming(nodes) --- local usedfonts, attrfonts --- local a, u, prevfont, prevattr, done = 0, 0, nil, 0, false --- if trace_fontrun then --- run = run + 1 --- report_fonts() --- report_fonts("checking node list, run %s",run) --- report_fonts() --- local n = head --- while n do --- local id = n.id --- if id == glyph_code then --- local font = n.font --- local attr = n[0] or 0 --- report_fonts("font %03i, dynamic %03i, glyph %s",font,attr,utf.char(n.char)) --- else --- report_fonts("[%s]",nodecodes[n.id]) --- end --- n = n.next --- end --- end --- for n in traverse_id(glyph_code,head) do --- -- if n.subtype<256 then -- all are 1 --- local font = n.font --- local attr = n[0] or 0 -- zero attribute is reserved for fonts in context --- if font ~= prevfont or attr ~= prevattr then --- if attr > 0 then --- if not attrfonts then --- attrfonts = { --- [font] = { --- [attr] = setfontdynamics[font][attr] --- } --- } --- a = 1 --- else --- local used = attrfonts[font] --- if not used then --- attrfonts[font] = { --- [attr] = setfontdynamics[font][attr] --- } --- a = a + 1 --- elseif not used[attr] then --- used[attr] = setfontdynamics[font][attr] --- a = a + 1 --- end --- end --- else --- if not usedfonts then --- local fp = fontprocesses[font] --- if fp then --- usedfonts = { --- [font] = fp --- } --- u = 1 --- end --- else --- local used = usedfonts[font] --- if not used then --- local fp = fontprocesses[font] --- if fp then --- usedfonts[font] = fp --- u = u + 1 --- end --- end --- end --- end --- prevfont = font --- prevattr = attr --- variants = fontvariants[font] --- end --- if variants then --- local char = getchar(n) --- if char >= 0xFE00 and (char <= 0xFE0F or (char >= 0xE0100 and char <= 0xE01EF)) then --- local hash = variants[char] --- if hash then --- local p = getprev(n) --- if p and getid(p) == glyph_code then --- local variant = hash[getchar(p)] --- if variant then --- setchar(p,variant) --- delete_node(nuthead,n) --- end --- end --- end --- end --- end --- end --- -- end --- end --- if trace_fontrun then --- report_fonts() --- report_fonts("statics : %s",(u > 0 and concat(keys(usedfonts)," ")) or "none") --- report_fonts("dynamics: %s",(a > 0 and concat(keys(attrfonts)," ")) or "none") --- report_fonts() --- end --- if not usedfonts then --- -- skip --- elseif u == 1 then --- local font, processors = next(usedfonts) --- head, done = processors(head,done) --- else --- for font, processors in next, usedfonts do --- head, done = processors(head,done) --- end --- end --- if not attrfonts then --- -- skip --- elseif a == 1 then --- local font, dynamics = next(attrfonts) --- for attribute, processors in next, dynamics do --- head, done = processors(head,done) --- end --- else --- for font, dynamics in next, attrfonts do --- for attribute, processors in next, dynamics do --- head, done = processors(head,done) --- end --- end --- end --- stoptiming(nodes) --- if trace_characters then --- nodes.report(head,done) --- end --- return head, true --- end - local d_protect_glyphs = nuts.protect_glyphs local d_unprotect_glyphs = nuts.unprotect_glyphs diff --git a/tex/context/base/mkiv/node-ini.lua b/tex/context/base/mkiv/node-ini.lua index 9a8337e4e..f311bb811 100644 --- a/tex/context/base/mkiv/node-ini.lua +++ b/tex/context/base/mkiv/node-ini.lua @@ -53,6 +53,10 @@ into the <l n='tex'/> engine, but this is a not so natural extension.</p> also ignore the empty nodes. [This is obsolete!]</p> --ldx]]-- +-- local gf = node.direct.getfield +-- local n = table.setmetatableindex("number") +-- function node.direct.getfield(a,b) n[b] = n[b] + 1 print(b,n[b]) return gf(a,b) end + nodes = nodes or { } local nodes = nodes nodes.handlers = nodes.handlers or { } diff --git a/tex/context/base/mkiv/node-ltp.lua b/tex/context/base/mkiv/node-ltp.lua index 5b5cc5c08..95efbcb9c 100644 --- a/tex/context/base/mkiv/node-ltp.lua +++ b/tex/context/base/mkiv/node-ltp.lua @@ -203,9 +203,12 @@ local getboth = nuts.getboth local getlist = nuts.getlist local getfont = nuts.getfont local getchar = nuts.getchar +local getdisc = nuts.getdisc local getattr = nuts.getattr local getdisc = nuts.getdisc +local isglyph = nuts.isglyph + local setfield = nuts.setfield local setlink = nuts.setlink local setlist = nuts.setlist @@ -486,20 +489,23 @@ end) local function kern_stretch_shrink(p,d) local left = getprev(p) - if left and getid(left) == glyph_code then -- how about disc nodes? - local data = expansions[getfont(left)][getchar(left)] - if data then - local stretch = data.stretch - local shrink = data.shrink - if stretch ~= 0 then - -- stretch = data.factor * (d * stretch - d) - stretch = data.factor * d * (stretch - 1) - end - if shrink ~= 0 then - -- shrink = data.factor * (d * shrink - d) - shrink = data.factor * d * (shrink - 1) + if left then + local char = isglyph(left) + if char then + local data = expansions[getfont(left)][char] + if data then + local stretch = data.stretch + local shrink = data.shrink + if stretch ~= 0 then + -- stretch = data.factor * (d * stretch - d) + stretch = data.factor * d * (stretch - 1) + end + if shrink ~= 0 then + -- shrink = data.factor * (d * shrink - d) + shrink = data.factor * d * (shrink - 1) + end + return stretch, shrink end - return stretch, shrink end end return 0, 0 @@ -694,8 +700,8 @@ local function add_to_width(line_break_dir,checked_expansion,s) -- split into tw local adjust_stretch = 0 local adjust_shrink = 0 while s do - local id = getid(s) - if id == glyph_code then + local char, id = isglyph(s) + if char then if is_rotated[line_break_dir] then -- can be shared size = size + getfield(s,"height") + getfield(s,"depth") else @@ -704,7 +710,7 @@ local function add_to_width(line_break_dir,checked_expansion,s) -- split into tw if checked_expansion then local data = checked_expansion[getfont(s)] if data then - data = data[getchar(s)] + data = data[char] if data then adjust_stretch = adjust_stretch + data.glyphstretch adjust_shrink = adjust_shrink + data.glyphshrink @@ -1200,7 +1206,7 @@ local function post_line_break(par) local prevlast = getprev(lastnode) local nextlast = getnext(lastnode) local subtype = getsubtype(lastnode) - local pre, post, replace = getdisc(lastnode) + local pre, post, replace, pretail, posttail, replacetail = getdisc(lastnode) if subtype == second_disc_code then if not (getid(prevlast) == disc_code and getsubtype(prevlast) == first_disc_code) then report_parbuilders('unsupported disc at location %a',3) @@ -1210,12 +1216,11 @@ local function post_line_break(par) pre = nil -- signal end if replace then - local n = find_tail(replace) setlink(prevlast,replace) - setlink(n,lastnode) + setlink(replacetail,lastnode) replace = nil -- signal end - setdisc(pre,post,replace) + setdisc(lastnode,pre,post,replace) local pre, post, replace = getdisc(prevlast) if pre then flush_nodelist(pre) @@ -1234,20 +1239,18 @@ local function post_line_break(par) end setsubtype(nextlast,regular_disc_code) setfield(nextlast,"replace",post) - setfield(lastnode,"post") + setfield(lastnode,"post") -- nil end if replace then flush_nodelist(replace) end if pre then - local n = find_tail(pre) setlink(prevlast,pre) - setlink(n,lastnode) + setlink(pretail,lastnode) end if post then - local n = find_tail(post) setlink(lastnode,post) - setlink(n,nextlast) + setlink(posttail,nextlast) post_disc_break = true end setdisc(lastnode) -- nil, nil, nil @@ -1882,8 +1885,13 @@ local function try_break(pi, break_type, par, first_p, current, checked_expansio local b = r.break_node local l = b and b.cur_break or first_p local o = current and getprev(current) - if current and getid(current) == disc_code and getfield(current,"pre") then - o = find_tail(getfield(current,"pre")) + if current and getid(current) == disc_code then + local pre, _, _, pretail = getdisc(current) + if pre then + o = pretail + else + o = find_protchar_right(l,o) + end else o = find_protchar_right(l,o) end @@ -2176,8 +2184,8 @@ function constructors.methods.basic(head,d) trialcount = 0 while current and p_active ~= n_active do - local id = getid(current) - if id == glyph_code then + local char, id = isglyph(current) + if char then if is_rotated[par.line_break_dir] then active_width.size = active_width.size + getfield(current,"height") + getfield(current,"depth") else @@ -2185,14 +2193,14 @@ function constructors.methods.basic(head,d) end if checked_expansion then local currentfont = getfont(current) - local data= checked_expansion[currentfont] + local data = checked_expansion[currentfont] if data then if currentfont ~= lastfont then fontexps = checked_expansion[currentfont] -- a bit redundant for the par line packer lastfont = currentfont end if fontexps then - local expansion = fontexps[getchar(current)] + local expansion = fontexps[char] if expansion then active_width.adjust_stretch = active_width.adjust_stretch + expansion.glyphstretch active_width.adjust_shrink = active_width.adjust_shrink + expansion.glyphshrink @@ -2238,7 +2246,7 @@ function constructors.methods.basic(head,d) -- 0.81 : -- local actual_pen = getfield(current,"penalty") -- - local pre = getfield(current,"pre") + local pre, post, replace = getdisc(current) if not pre then -- trivial pre-break disc_width.size = 0 if checked_expansion then @@ -2297,7 +2305,6 @@ function constructors.methods.basic(head,d) end end end - local replace = getfield(current,"replace") if replace then local size, adjust_stretch, adjust_shrink = add_to_width(line_break_dir,checked_expansion,replace) active_width.size = active_width.size + size @@ -2453,8 +2460,8 @@ local verbose = false -- true local function short_display(target,a,font_in_short_display) while a do - local id = getid(a) - if id == glyph_code then + local char, id = isglyph(a) + if char then local font = getfont(a) if font ~= font_in_short_display then write(target,tex.fontidentifier(font) .. ' ') @@ -2463,11 +2470,12 @@ local function short_display(target,a,font_in_short_display) if getsubtype(a) == ligature_code then font_in_short_display = short_display(target,getfield(a,"components"),font_in_short_display) else - write(target,utfchar(getchar(a))) + write(target,utfchar(char)) end elseif id == disc_code then - font_in_short_display = short_display(target,getfield(a,"pre"),font_in_short_display) - font_in_short_display = short_display(target,getfield(a,"post"),font_in_short_display) + local pre, post, replace = getdisc(a) + font_in_short_display = short_display(target,pre,font_in_short_display) + font_in_short_display = short_display(target,post,font_in_short_display) elseif verbose then write(target,format("[%s]",nodecodes[id])) elseif id == rule_code then @@ -2822,8 +2830,8 @@ local function hpack(head,width,method,direction,firstline,line) -- fast version local function process(current) -- called nested in disc replace while current do - local id = getid(current) - if id == glyph_code then + local char, id = isglyph(current) + if char then if cal_expand_ratio then local currentfont = getfont(current) if currentfont ~= lastfont then @@ -2831,7 +2839,7 @@ local function hpack(head,width,method,direction,firstline,line) -- fast version lastfont = currentfont end if fontexps then - local expansion = fontexps[getchar(current)] + local expansion = fontexps[char] if expansion then font_stretch = font_stretch + expansion.glyphstretch font_shrink = font_shrink + expansion.glyphshrink @@ -3004,15 +3012,16 @@ local function hpack(head,width,method,direction,firstline,line) -- fast version local fontexps, lastfont for i=1,expansion_index do - local g = expansion_stack[i] - local e - if getid(g) == glyph_code then + local g = expansion_stack[i] + local e = 0 + local char = isglyph(g) + if char then local currentfont = getfont(g) if currentfont ~= lastfont then fontexps = expansions[currentfont] lastfont = currentfont end - local data = fontexps[getchar(g)] + local data = fontexps[char] if trace_expansion then setnodecolor(g,"hz:positive") end @@ -3060,15 +3069,16 @@ local function hpack(head,width,method,direction,firstline,line) -- fast version local fontexps, lastfont for i=1,expansion_index do - local g = expansion_stack[i] - local e - if getid(g) == glyph_code then + local g = expansion_stack[i] + local e = 0 + local char = isglyph(g) + if char then local currentfont = getfont(g) if currentfont ~= lastfont then fontexps = expansions[currentfont] lastfont = currentfont end - local data = fontexps[getchar(g)] + local data = fontexps[char] if trace_expansion then setnodecolor(g,"hz:negative") end diff --git a/tex/context/base/mkiv/node-met.lua b/tex/context/base/mkiv/node-met.lua index 5c6e18bd3..a5ad15c80 100644 --- a/tex/context/base/mkiv/node-met.lua +++ b/tex/context/base/mkiv/node-met.lua @@ -127,32 +127,70 @@ nodes.tonut = function(n) return n end local getfield = node.getfield local setfield = node.setfield -local getattr = node.get_attribute or node.has_attribute or getfield +local getattr = node.get_attribute local setattr = setfield -local getnext = node.getnext or function(n) return getfield(n,"next") end -local getprev = node.getprev or function(n) return getfield(n,"prev") end -local getid = node.getid or function(n) return getfield(n,"id") end -local getchar = node.getchar or function(n) return getfield(n,"char") end -local getfont = node.getfont or function(n) return getfield(n,"font") end -local getsubtype = node.getsubtype or function(n) return getfield(n,"subtype") end -local getlist = node.getlist or function(n) return getfield(n,"list") end -local getleader = node.getleader or function(n) return getfield(n,"leader") end - -nodes.getfield = getfield -nodes.getattr = getattr - -nodes.setfield = setfield -nodes.setattr = setattr - -nodes.getnext = getnext -nodes.getprev = getprev -nodes.getid = getid -nodes.getchar = getchar -nodes.getfont = getfont -nodes.getsubtype = getsubtype -nodes.getlist = getlist -nodes.getleader = getleader +local n_getid = node.getid +local n_getlist = node.getlist +local n_getnext = node.getnext +local n_getprev = node.getprev +local n_getchar = node.getchar +local n_getfont = node.getfont +local n_getsubtype = node.getsubtype +local n_setfield = node.setfield +local n_getfield = node.getfield +local n_setattr = node.setattr +local n_getattr = node.getattr +local n_getdisc = node.getdisc +local n_getleader = node.getleader + +local n_setnext = node.setnext or + function(c,next) + setfield(c,"next",n) + end +local n_setprev = node.setprev or + function(c,prev) + setfield(c,"prev",p) + end +local n_setlink = node.setlink or + function(c1,c2) + if c1 then setfield(c1,"next",c2) end + if c2 then setfield(c2,"prev",c1) end + end +local n_setboth = node.setboth or + function(c,p,n) + setfield(c,"prev",p) + setfield(c,"next",n) + end + +node.setnext = n_setnext +node.setprev = n_setprev +node.setlink = n_setlink +node.setboth = n_setboth + +nodes.getfield = n_getfield +nodes.setfield = n_setfield +nodes.getattr = n_getattr +nodes.setattr = n_setattr + +nodes.getnext = n_getnext +nodes.getprev = n_getprev +nodes.getid = n_getid +nodes.getchar = n_getchar +nodes.getfont = n_getfont +nodes.getsubtype = n_getsubtype +nodes.getlist = n_getlist +nodes.getleader = n_getleader +nodes.getdisc = n_getdisc +-----.getpre = node.getpre or function(n) local h, _, _, t = n_getdisc(n,true) return h, t end +-----.getpost = node.getpost or function(n) local _, h, _, _, t = n_getdisc(n,true) return h, t end +-----.getreplace = node.getreplace or function(n) local _, _, h, _, _, t = n_getdisc(n,true) return h, t end + +nodes.is_char = node.is_char +nodes.ischar = node.is_char + +nodes.is_glyph = node.is_glyph +nodes.isglyph = node.is_glyph nodes.getbox = node.getbox or tex.getbox nodes.setbox = node.setbox or tex.setbox @@ -160,12 +198,6 @@ nodes.getskip = node.getskip or tex.get local n_new_node = nodes.new local n_free_node = nodes.free -local n_setfield = nodes.setfield -local n_getfield = nodes.getfield -local n_getnext = nodes.getnext -local n_getprev = nodes.getprev -local n_getid = nodes.getid -local n_getlist = nodes.getlist local n_copy_node = nodes.copy local n_copy_list = nodes.copy_list local n_find_tail = nodes.tail @@ -184,8 +216,7 @@ local function remove(head,current,free_too) n_free_node(t) t = nil else - n_setfield(t,"next",nil) - n_setfield(t,"prev",nil) + n_setboth(t) end return head, current, t end @@ -210,12 +241,10 @@ function nodes.replace(head,current,new) -- no head returned if false local prev = n_getprev(current) local next = n_getnext(current) if next then - n_setfield(new,"next",next) - n_setfield(next,"prev",new) + n_setlink(new,next) end if prev then - n_setfield(new,"prev",prev) - n_setfield(prev,"next",new) + n_setlink(prev,new) end if head then if head == current then @@ -270,8 +299,7 @@ function nodes.linked(...) local next = select(i,...) if next then if head then - n_setfield(last,"next",next) - n_setfield(next,"prev",last) + n_setlink(last,next) else head = next end @@ -287,8 +315,7 @@ function nodes.concat(list) -- consider tail instead of slide local li = list[i] if li then if head then - n_setfield(tail,"next",li) - n_setfield(li,"prev",tail) + n_setlink(tail,li) else head = li end @@ -431,8 +458,7 @@ metatable.__concat = function(n1,n2) -- todo: accept nut on one end return n2 -- or n2 * 2 else local tail = n_find_tail(n1) - n_setfield(tail,"next",n2) - n_setfield(n2,"prev",tail) + n_setlink(tail,n2) return n1 end end @@ -449,26 +475,22 @@ metatable.__mul = function(n,multiplier) local h = n_copy_list(n) if head then local t = n_find_tail(h) - n_setfield(t,"next",head) - n_setfield(head,"prev",t) + n_setlink(t,head) end head = h end local t = n_find_tail(n) - n_setfield(t,"next",head) - n_setfield(head,"prev",t) + n_setlink(t,head) else local head for i=2,multiplier do local c = n_copy_node(n) if head then - n_setfield(c,"next",head) - n_setfield(head,"prev",c) + n_setlink(c,head) end head = c end - n_setfield(n,"next",head) - n_setfield(head,"prev",n) + n_setlink(n,head) end return n end @@ -477,7 +499,7 @@ metatable.__sub = function(first,second) if type(second) == "number" then local tail = n_find_tail(first) for i=1,second do - local prev = n_getfield(tail,"prev") + local prev = n_getprev(tail) n_free_node(tail) -- can become flushlist/flushnode if prev then tail = prev @@ -486,7 +508,7 @@ metatable.__sub = function(first,second) end end if tail then - n_setfield(tail,"next",nil) + n_setnext(tail) return first else return nil @@ -497,15 +519,12 @@ metatable.__sub = function(first,second) local prev = n_getprev(firsttail) if prev then local secondtail = n_find_tail(second) - n_setfield(secondtail,"next",firsttail) - n_setfield(firsttail,"prev",ltail) - n_setfield(prev,"next",second) - n_setfield(second,"prev",prev) + n_setlink(secondtail,firsttail) + n_setlink(prev,second) return first else local secondtail = n_find_tail(second) - n_setfield(secondtail,"next",first) - n_setfield(first,"prev",ltail) + n_setlink(secondtail,first) return second end end @@ -524,7 +543,7 @@ metatable.__add = function(first,second) end end if head then - n_setfield(head,"prev",nil) + n_setprev(head) return head else return nil @@ -534,13 +553,10 @@ metatable.__add = function(first,second) local next = n_getnext(first) if next then local secondtail = n_find_tail(second) - n_setfield(first,"next",second) - n_setfield(second,"prev",first) - n_setfield(secondtail,"next",next) - n_setfield(next,"prev",secondtail) + n_setlink(first,second) + n_setlink(secondtail,next) else - n_setfield(first,"next",second) - n_setfield(second,"prev",first) + n_setlink(first,second) end return first end @@ -562,7 +578,7 @@ end metatable.__pow = function(n,multiplier) local tail = n local head = nil - if getnext(n) then + if n_getnext(n) then if multiplier == 1 then head = n_copy_list(n) else @@ -570,8 +586,7 @@ metatable.__pow = function(n,multiplier) local h = n_copy_list(n) if head then local t = n_find_tail(h) - n_setfield(t,"next",head) - n_setfield(head,"prev",t) + n_setlink(t,head) end head = h end @@ -583,8 +598,7 @@ metatable.__pow = function(n,multiplier) for i=2,multiplier do local c = n_copy_node(n) if head then - n_setfield(head,"next",c) - n_setfield(c,"prev",head) + n_setlink(head,c) end head = c end @@ -600,13 +614,12 @@ metatable.__unm = function(head) local current = n_getnext(head) while current do local next = n_getnext(current) - n_setfield(first,"prev",current) - n_setfield(current,"next",first) + n_setlink(current,first) first = current current = next end - n_setfield(first,"prev",nil) - n_setfield(last,"next",nil) + n_setprev(first) + n_setnext(last) return first end diff --git a/tex/context/base/mkiv/node-nut.lua b/tex/context/base/mkiv/node-nut.lua index d82a21443..200cbce5b 100644 --- a/tex/context/base/mkiv/node-nut.lua +++ b/tex/context/base/mkiv/node-nut.lua @@ -142,9 +142,7 @@ nuts.getleader = direct.getleader -- end -- end --- track("getsubtype") - --- local dgf = direct.getfield function nuts.getlist(n) return dgf(n,"list") end +-- track("getfield") -- setters @@ -268,7 +266,20 @@ if not direct.setlist then end +-- if not direct.getpre then +-- +-- local getfield = nuts.getfield +-- +-- function direct.getpre (n) local h, _, _, t = getdisc(n,true) return h, t end +-- function direct.getpost (n) local _, h, _, _, t = getdisc(n,true) return h, t end +-- function direct.getreplace(n) local _, _, h, _, _, t = getdisc(n,true) return h, t end +-- +-- end + nuts.getdisc = direct.getdisc +----.getpre = direct.getpre +----.getpost = direct.getpost +----.getreplace = direct.getreplace nuts.setdisc = direct.setdisc nuts.setchar = direct.setchar nuts.setnext = direct.setnext @@ -279,7 +290,50 @@ nuts.setlink = direct.setlink nuts.setlist = direct.setlist nuts.setleader = direct.setleader nuts.setsubtype = direct.setsubtype + +if not direct.is_glyph then + + local getchar = direct.getchar + local getid = direct.getid + local getfont = direct.getfont + local getsubtype = direct.getsubtype + + local glyph_code = nodes.nodecodes.glyph + + function direct.is_glyph(n,f) + local id = getid(n) + if id == glyph_code then + if f and getfont(n) == f then + return getchar(n) + else + return false + end + else + return nil, id + end + end + + function direct.is_char(n,f) + local id = getid(n) + if id == glyph_code then + if getsubtype(n) >= 256 then + return false + elseif f and getfont(n) == f then + return getchar(n) + else + return false + end + else + return nil, id + end + end + +end + nuts.is_char = direct.is_char +nuts.ischar = direct.is_char +nuts.is_glyph = direct.is_glyph +nuts.isglyph = direct.is_glyph local d_remove_node = direct.remove local d_free_node = direct.free diff --git a/tex/context/base/mkiv/node-pro.lua b/tex/context/base/mkiv/node-pro.lua index d6a8e9fe3..36670eed2 100644 --- a/tex/context/base/mkiv/node-pro.lua +++ b/tex/context/base/mkiv/node-pro.lua @@ -35,8 +35,7 @@ local actions = tasks.actions("processors") do local tonut = nuts.tonut - local getid = nuts.getid - local getchar = nuts.getchar + local isglyph = nuts.isglyph local getnext = nuts.getnext local n = 0 @@ -45,9 +44,9 @@ do local t, n, h = { }, 0, tonut(head) while h do n = n + 1 - local id = getid(h) - if id == glyph_code then -- todo: disc etc - t[n] = utfchar(getchar(h)) + local char, id = isglyph(h) + if char then -- todo: disc etc + t[n] = utfchar(char) else t[n] = "[]" end diff --git a/tex/context/base/mkiv/node-rul.lua b/tex/context/base/mkiv/node-rul.lua index 6d6c5fd02..e0649e99b 100644 --- a/tex/context/base/mkiv/node-rul.lua +++ b/tex/context/base/mkiv/node-rul.lua @@ -30,7 +30,6 @@ local getattr = nuts.getattr local setattr = nuts.setattr local getfont = nuts.getfont local getsubtype = nuts.getsubtype -local getchar = nuts.getchar local getlist = nuts.getlist local setlist = nuts.setlist diff --git a/tex/context/base/mkiv/node-shp.lua b/tex/context/base/mkiv/node-shp.lua index 19b99b12c..4e4c88c03 100644 --- a/tex/context/base/mkiv/node-shp.lua +++ b/tex/context/base/mkiv/node-shp.lua @@ -40,7 +40,6 @@ local tonode = nuts.tonode local free_node = nuts.free local remove_node = nuts.remove local traverse_nodes = nuts.traverse -local find_tail = nuts.tail local getfield = nuts.getfield local setfield = nuts.setfield @@ -48,8 +47,9 @@ local setsetlink = nuts.setlink local setsetprev = nuts.setprev local setsetnext = nuts.setnext local getid = nuts.getid +local getdisc = nuts.getdisc +local getboth = nuts.getboth local getnext = nuts.getnext -local getprev = nuts.getprev local getlist = nuts.getlist local getsubtype = nuts.getsubtype @@ -78,11 +78,9 @@ local function cleanup_redundant(head) -- better name is: flatten_page local id = getid(start) if id == disc_code then if getsubtype(start) == fulldisc_code then - local replace = getfield(start,"replace") + local _, _, replace, _, _ tail = getdisc(start) if replace then - local prev = getprev(start) - local next = getnext(start) - local tail = find_tail(replace) + local prev, next = getboth(start) setfield(start,"replace",nil) if start == head then remove_node(head,start,true) diff --git a/tex/context/base/mkiv/node-tra.lua b/tex/context/base/mkiv/node-tra.lua index e68228fe8..eb1832947 100644 --- a/tex/context/base/mkiv/node-tra.lua +++ b/tex/context/base/mkiv/node-tra.lua @@ -46,8 +46,8 @@ local getchar = nuts.getchar local getsubtype = nuts.getsubtype local getlist = nuts.getlist local getdisc = nuts.getdisc - local setattr = nuts.setattr +local isglyph = nuts.isglyph local flush_list = nuts.flush_list local count_nodes = nuts.count @@ -129,9 +129,8 @@ local function tosequence(start,stop,compact) stop = stop and tonut(stop) local t = { } while start do - local id = getid(start) - if id == glyph_code then - local c = getchar(start) + local c, id = isglyph(start) + if c then if compact then local components = getfield(start,"components") if components then @@ -293,9 +292,8 @@ nodes.showsimplelist = function(h,depth) showsimplelist(h,depth,0) end local function listtoutf(h,joiner,textonly,last,nodisc) local w = { } while h do - local id = getid(h) - if id == glyph_code then -- always true - local c = getchar(h) + local c, id = isglyph(h) + if c then w[#w+1] = c >= 0 and utfchar(c) or formatters["<%i>"](c) if joiner then w[#w+1] = joiner diff --git a/tex/context/base/mkiv/publ-ini.mkiv b/tex/context/base/mkiv/publ-ini.mkiv index 782f73e0c..cf51b831a 100644 --- a/tex/context/base/mkiv/publ-ini.mkiv +++ b/tex/context/base/mkiv/publ-ini.mkiv @@ -1386,8 +1386,8 @@ \unexpanded\def\citation {\doifelsenextoptionalcs\btxlistcitation \btxdirectlistcite} \unexpanded\def\nocitation{\doifelsenextoptionalcs\btxhiddencitation\btxdirecthiddencite} -\let\citation \listcitation \let\cite \citation -\let\nocitation\nocitation \let\nocite\nocitation +\let\cite \citation +\let\nocite\nocitation \unexpanded\def\publ_entry_citation {\doifelsenextoptionalcs\btxlistcitation \btxdirectlistcite} \unexpanded\def\publ_entry_nocitation{\doifelsenextoptionalcs\btxhiddencitation\btxdirecthiddencite} diff --git a/tex/context/base/mkiv/scrp-cjk.lua b/tex/context/base/mkiv/scrp-cjk.lua index 1d8191008..77c58b18a 100644 --- a/tex/context/base/mkiv/scrp-cjk.lua +++ b/tex/context/base/mkiv/scrp-cjk.lua @@ -47,6 +47,8 @@ local skipcodes = nodes.skipcodes local glyph_code = nodecodes.glyph local glue_code = nodecodes.glue local userskip_code = skipcodes.userskip +local spaceskip_code = skipcodes.spaceskip +local xspaceskip_code = skipcodes.xspaceskip local a_scriptstatus = attributes.private('scriptstatus') local a_scriptinjection = attributes.private('scriptinjection') @@ -954,15 +956,19 @@ local function process(head,first,last) or pcjk == "half_width_close" or ncjk == "half_width_open" then -- extra compared to korean previous = "start" else -- if head ~= first then - if id == glue_code and getsubtype(first) == userskip_code then -- also scriptstatus check? - -- for the moment no distinction possible between space and userskip - local w = getfield(first,"width") - local s = spacedata[getfont(p)] - if w == s then -- could be option - if trace_details then - trace_detail_between(p,n,"space removed") + if id == glue_code then + -- also scriptstatus check? + local subtype = getsubtype(first) + if subtype == userskip_code or subtype == spaceskip_code or subtype == xspaceskip_code then + -- for the moment no distinction possible between space and userskip + local w = getfield(first,"width") + local s = spacedata[getfont(p)] + if w == s then -- could be option + if trace_details then + trace_detail_between(p,n,"space removed") + end + remove_node(head,first,true) end - remove_node(head,first,true) end end previous = pcjk diff --git a/tex/context/base/mkiv/scrp-eth.lua b/tex/context/base/mkiv/scrp-eth.lua index 8ecbce522..43cb2ff6a 100644 --- a/tex/context/base/mkiv/scrp-eth.lua +++ b/tex/context/base/mkiv/scrp-eth.lua @@ -13,7 +13,6 @@ local nuts = nodes.nuts local getnext = nuts.getnext local getfont = nuts.getfont -local getchar = nuts.getchar local getid = nuts.getid local getattr = nuts.getattr diff --git a/tex/context/base/mkiv/scrp-ini.lua b/tex/context/base/mkiv/scrp-ini.lua index 3c3517542..c35f99038 100644 --- a/tex/context/base/mkiv/scrp-ini.lua +++ b/tex/context/base/mkiv/scrp-ini.lua @@ -57,10 +57,12 @@ local getfont = nuts.getfont local getid = nuts.getid local getattr = nuts.getattr local setattr = nuts.setattr +local isglyph = nuts.isglyph local insert_node_after = nuts.insert_after local first_glyph = nuts.first_glyph local traverse_id = nuts.traverse_id +local traverse_char = nuts.traverse_char local nodepool = nuts.pool @@ -453,8 +455,8 @@ function scripts.injectors.handler(head) local last_a, normal_process, lastfont, originals = nil, nil, nil, nil local done, first, last, ok = false, nil, nil, false while start do - local id = getid(start) - if id == glyph_code then + local char, id = isglyph(start) + if char then local a = getattr(start,a_scriptinjection) if a then if a ~= last_a then @@ -478,21 +480,20 @@ function scripts.injectors.handler(head) end if normal_process then -- wrong: originals are indices ! - local f = getfont(start) - if f ~= lastfont then - originals = fontdata[f].resources + local font = getfont(start) + if font ~= lastfont then + originals = fontdata[font].resources if resources then originals = resources.originals else originals = nil -- can't happen end - lastfont = f + lastfont = font end - local c = getchar(start) if originals and type(originals) == "number" then - c = originals[c] or c + char = originals[char] or char end - local h = hash[c] + local h = hash[char] if h then setattr(start,a_scriptstatus,categorytonumber[h]) if not first then @@ -697,26 +698,55 @@ end) local categories = characters.categories or { } +-- local function hit(root,head) +-- local current = getnext(head) +-- local lastrun = false +-- local lastfinal = false +-- while current and getid(current) == glyph_code do +-- local char = getchar(current) +-- local newroot = root[char] +-- if newroot then +-- local final = newroot.final +-- if final then +-- lastrun = current +-- lastfinal = final +-- end +-- root = newroot +-- elseif categories[char] == "mn" then +-- -- continue +-- else +-- return lastrun, lastfinal +-- end +-- current = getnext(current) +-- end +-- if lastrun then +-- return lastrun, lastfinal +-- end +-- end + local function hit(root,head) local current = getnext(head) local lastrun = false local lastfinal = false - while current and getid(current) == glyph_code do - local char = getchar(current) - local newroot = root[char] - if newroot then - local final = newroot.final - if final then - lastrun = current - lastfinal = final + while current do + local char = isglyph(current) + if char then + local newroot = root[char] + if newroot then + local final = newroot.final + if final then + lastrun = current + lastfinal = final + end + root = newroot + elseif categories[char] == "mn" then + -- continue + else + return lastrun, lastfinal end - root = newroot - elseif categories[char] == "mn" then - -- continue else - return lastrun, lastfinal + break end - current = getnext(current) end if lastrun then return lastrun, lastfinal @@ -746,9 +776,11 @@ function splitters.handler(head) -- todo: also first_glyph test local last, final = hit(root,current) if last then local next = getnext(last) - if next and getid(next) == glyph_code then - local nextchar = getchar(next) - if tree[nextchar] then + if next then + local nextchar = isglyph(next) + if not nextchar then + -- we're done + elseif tree[nextchar] then if trace_splitdetail then if type(final) == "string" then report_splitting("advance %s processing between <%s> and <%c>","with",final,nextchar) @@ -886,11 +918,11 @@ setmetatableindex(cache_nop,function(t,k) local v = { } t[k] = v return v end) -- playing nice function autofontfeature.handler(head) - for n in traverse_id(glyph_code,tonut(head)) do + for n in traverse_char(tonut(head)) do -- if getattr(n,a_scriptinjection) then -- -- already tagged by script feature, maybe some day adapt -- else - local char = getchar(n) + local char = getchar(n) local script = otfscripts[char] if script then local dynamic = getattr(n,0) or 0 diff --git a/tex/context/base/mkiv/spac-ali.mkiv b/tex/context/base/mkiv/spac-ali.mkiv index e896b3910..e7d4137a0 100644 --- a/tex/context/base/mkiv/spac-ali.mkiv +++ b/tex/context/base/mkiv/spac-ali.mkiv @@ -288,6 +288,7 @@ \newconstant\c_spac_align_state_horizontal \newconstant\c_spac_align_state_broad +\newconstant\c_spac_align_state_par_fill \def\v_spac_align_fill_amount {\plusone fil} \def\v_spac_align_fill_amount_negative {\minusone fil} @@ -472,7 +473,8 @@ \spac_align_set_horizontal_centered_last_line \or \parfillskip\zeropoint - \fi} + \fi + \relax} % Page spacing: @@ -542,6 +544,7 @@ \c_spac_align_state_vertical \zerocount \c_spac_align_state_direction \zerocount % what is default ? \c_spac_align_state_page \zerocount + \c_spac_align_state_par_fill \zerocount \ifcsname\??aligncommand\m_spac_align_asked\endcsname \lastnamedcs \else @@ -555,6 +558,7 @@ \spac_align_flush_vertical \spac_align_flush_direction \spac_align_flush_page + \spac_align_flush_parfill }}% kept, nice for tracing \edef\raggedcommand {\the\t_spac_align_collected }% \edef\updateraggedskips{\spac_align_flush_horizontal}% @@ -631,7 +635,7 @@ \unexpanded\def\installalign#1#2% beware: commands must be unexpandable! {\ifcsname\??aligncommand#1\endcsname \else - \setvalue{\??aligncommand#1}{\t_spac_align_collected\expandafter{\the\t_spac_align_collected#2}}% + \setvalue{\??aligncommand#1}{\toksapp\t_spac_align_collected{#2}}% \fi} % beware, toks stuff and states are set at a differt time, so installalign is @@ -639,7 +643,7 @@ % % \setvalue{\??aligncommand whatever}% % {\c_spac_align_state_horizontal\plushundred -% \t_spac_align_collected\expandafter{\the\t_spac_align_collected .....}} +% \toksapp\t_spac_align_collected{.....}} % % this one could deal with both % @@ -648,7 +652,7 @@ % \setvalue{\??aligncommand#1}% % {\spac_align_set_horizontal_none % \c_spac_align_state_horizontal\plushundred % don't set -% \t_spac_align_collected\expandafter{\the\t_spac_align_collected#2}}% +% \toksapp\t_spac_align_collected{#2}}% % \fi} % % \installalignoption @@ -665,7 +669,7 @@ \setvalue{\??aligncommand\v!height }{\c_spac_align_state_page \plustwo } \setvalue{\??aligncommand\v!line }{\c_spac_align_state_page \plusthree % this will become another keyword (undocumented anyway) - \t_spac_align_collected\expandafter{\the\t_spac_align_collected\settrue\raggedonelinerstate}} + \toksapp\t_spac_align_collected{\settrue\raggedonelinerstate}} \setvalue{\??aligncommand\v!high }{\c_spac_align_state_vertical \plusthree} \setvalue{\??aligncommand\v!low }{\c_spac_align_state_vertical \plustwo } @@ -702,23 +706,42 @@ \c_spac_align_state_broad \plusone \c_spac_align_state_horizontal\plustwo } -\setvalue{\??aligncommand\v!lesshyphenation}{\t_spac_align_collected\expandafter{\the\t_spac_align_collected\lesshyphens}} -\setvalue{\??aligncommand\v!morehyphenation}{\t_spac_align_collected\expandafter{\the\t_spac_align_collected\morehyphens}} - -\setvalue{\??aligncommand\v!hanging }{\t_spac_align_collected\expandafter{\the\t_spac_align_collected\font_protruding_enable }} -\setvalue{\??aligncommand\v!nothanging }{\t_spac_align_collected\expandafter{\the\t_spac_align_collected\font_protruding_disable}} -\setvalue{\??aligncommand\v!hz }{\t_spac_align_collected\expandafter{\the\t_spac_align_collected\font_expansion_enable }} -\setvalue{\??aligncommand\v!fullhz }{\t_spac_align_collected\expandafter{\the\t_spac_align_collected\font_expansion_enable_k}} -\setvalue{\??aligncommand\v!nohz }{\t_spac_align_collected\expandafter{\the\t_spac_align_collected\font_expansion_disable }} -%setvalue{\??aligncommand\v!spacing }{\t_spac_align_collected\expandafter{\the\t_spac_align_collected\normalspacing\zerocount}} % not yet -%setvalue{\??aligncommand\v!nospacing }{\t_spac_align_collected\expandafter{\the\t_spac_align_collected\normalspacing\plusone}} % not yet -\setvalue{\??aligncommand\v!hyphenated }{\t_spac_align_collected\expandafter{\the\t_spac_align_collected\dohyphens}} -\setvalue{\??aligncommand\v!nothyphenated }{\t_spac_align_collected\expandafter{\the\t_spac_align_collected\nohyphens}} - -\setvalue{\??aligncommand\v!tolerant }{\t_spac_align_collected\expandafter{\the\t_spac_align_collected\spac_align_set_tolerant}} -\setvalue{\??aligncommand\v!verytolerant }{\t_spac_align_collected\expandafter{\the\t_spac_align_collected\spac_align_set_very_tolerant}} -\setvalue{\??aligncommand\v!stretch }{\t_spac_align_collected\expandafter{\the\t_spac_align_collected\spac_align_set_stretch}} -\setvalue{\??aligncommand\v!extremestretch }{\t_spac_align_collected\expandafter{\the\t_spac_align_collected\spac_align_set_extreme_stretch}} +\setvalue{\??aligncommand\v!lesshyphenation}{\toksapp\t_spac_align_collected{\lesshyphens}} +\setvalue{\??aligncommand\v!morehyphenation}{\toksapp\t_spac_align_collected{\morehyphens}} + +\setvalue{\??aligncommand\v!hanging }{\toksapp\t_spac_align_collected{\font_protruding_enable }} +\setvalue{\??aligncommand\v!nothanging }{\toksapp\t_spac_align_collected{\font_protruding_disable}} +\setvalue{\??aligncommand\v!hz }{\toksapp\t_spac_align_collected{\font_expansion_enable }} +\setvalue{\??aligncommand\v!fullhz }{\toksapp\t_spac_align_collected{\font_expansion_enable_k}} +\setvalue{\??aligncommand\v!nohz }{\toksapp\t_spac_align_collected{\font_expansion_disable }} +%setvalue{\??aligncommand\v!spacing }{\toksapp\t_spac_align_collected{\normalspacing\zerocount}} % not yet +%setvalue{\??aligncommand\v!nospacing }{\toksapp\t_spac_align_collected{\normalspacing\plusone}} % not yet +\setvalue{\??aligncommand\v!hyphenated }{\toksapp\t_spac_align_collected{\dohyphens}} +\setvalue{\??aligncommand\v!nothyphenated }{\toksapp\t_spac_align_collected{\nohyphens}} + +\setvalue{\??aligncommand\v!tolerant }{\toksapp\t_spac_align_collected{\spac_align_set_tolerant}} +\setvalue{\??aligncommand\v!verytolerant }{\toksapp\t_spac_align_collected{\spac_align_set_very_tolerant}} +\setvalue{\??aligncommand\v!stretch }{\toksapp\t_spac_align_collected{\spac_align_set_stretch}} +\setvalue{\??aligncommand\v!extremestretch }{\toksapp\t_spac_align_collected{\spac_align_set_extreme_stretch}} + +\setvalue{\??aligncommand \v!final}{\c_spac_align_state_par_fill\plusone} +\setvalue{\??aligncommand2*\v!final}{\c_spac_align_state_par_fill\plustwo} % hardcoded multiplier +\setvalue{\??aligncommand3*\v!final}{\c_spac_align_state_par_fill\plusthree} +\setvalue{\??aligncommand4*\v!final}{\c_spac_align_state_par_fill\plusfour} + +\definehspace [\v!final] [\emspaceamount] + +\def\spac_align_flush_parfill + {\ifcase\c_spac_align_state_par_fill\else + \spac_align_flush_parfill_indeed{\number\c_spac_align_state_par_fill}% + \fi} + +\unexpanded\def\spac_align_flush_parfill_indeed#1% + {\parfillskip + #1\directhspaceamount\v!final + % plus \dimexpr\availablehsize-#1\directhspaceamount\v!final\relax + plus 1fill + \relax} %D For Wolfgang: diff --git a/tex/context/base/mkiv/spac-chr.lua b/tex/context/base/mkiv/spac-chr.lua index 3eb348586..97b32c366 100644 --- a/tex/context/base/mkiv/spac-chr.lua +++ b/tex/context/base/mkiv/spac-chr.lua @@ -34,12 +34,12 @@ local getfield = nuts.getfield local setfield = nuts.setfield local getnext = nuts.getnext local getprev = nuts.getprev -local getid = nuts.getid local getattr = nuts.getattr local setattr = nuts.setattr local getfont = nuts.getfont local getchar = nuts.getchar local setsubtype = nuts.setsubtype +local isglyph = nuts.isglyph local setcolor = nodes.tracers.colors.set @@ -181,32 +181,42 @@ local methods = { [0x001F] = function(head,current) local next = getnext(current) - if next and getid(next) == glyph_code then - local char = getchar(next) - head, current = remove_node(head,current,true) - if not is_punctuation[char] then - local p = fontparameters[getfont(next)] - head, current = insert_node_before(head,current,new_glue(p.space,p.space_stretch,p.space_shrink)) + if next then + local char = isglyph(next) + if char then + head, current = remove_node(head,current,true) + if not is_punctuation[char] then + local p = fontparameters[getfont(next)] + head, current = insert_node_before(head,current,new_glue(p.space,p.space_stretch,p.space_shrink)) + end end end end, [0x00A0] = function(head,current) -- nbsp local next = getnext(current) - if next and getid(next) == glyph_code then - local char = getchar(next) - if char == 0x200C or char == 0x200D then -- nzwj zwj + if next then + local char = isglyph(current) + if not char then + -- move on + elseif char == 0x200C or char == 0x200D then -- nzwj zwj next = getnext(next) - if next and nbsphash[getchar(next)] then - return false + if next then + char = isglyph(next) + if char and nbsphash[char] then + return false + end end elseif nbsphash[char] then return false end end local prev = getprev(current) - if prev and getid(prev) == glyph_code and nbsphash[getchar(prev)] then - return false + if prev then + local char = isglyph(prev) + if char and nbsphash[char] then + return false + end end return nbsp(head,current) end, @@ -280,10 +290,9 @@ function characters.handler(head) -- todo: use traverse_id local current = head local done = false while current do - local id = getid(current) - if id == glyph_code then - local next = getnext(current) - local char = getchar(current) + local char, id = isglyph(current) + if char then + local next = getnext(current) local method = methods[char] if method then if trace_characters then diff --git a/tex/context/base/mkiv/spac-hor.mkiv b/tex/context/base/mkiv/spac-hor.mkiv index 1ccd5ac9f..39ebcfa26 100644 --- a/tex/context/base/mkiv/spac-hor.mkiv +++ b/tex/context/base/mkiv/spac-hor.mkiv @@ -972,9 +972,10 @@ \fi} \def\hspaceamount#1#2% - {\csname\??hspace - \ifcsname\??hspace#1:#2\endcsname#1:#2\else:\v!none\fi - \endcsname} + {\dimexpr\ifcsname\??hspace#1:#2\endcsname\lastnamedcs\else\zeropoint\fi\relax} + +\def\directhspaceamount#1% + {\dimexpr\ifcsname\??hspace :#1\endcsname\lastnamedcs\else\zeropoint\fi\relax} % no installhspace here (this is already an old command) diff --git a/tex/context/base/mkiv/spac-ver.lua b/tex/context/base/mkiv/spac-ver.lua index 3095bbbd7..5d040db6f 100644 --- a/tex/context/base/mkiv/spac-ver.lua +++ b/tex/context/base/mkiv/spac-ver.lua @@ -1306,7 +1306,7 @@ local function collapser(head,where,what,trace,snap,a_snapmethod) -- maybe also end if glue_data then if force_glue then - if trace then trace_done("flushed due to " .. why,glue_data) end + if trace then trace_done("flushed due to forced " .. why,glue_data) end head = forced_skip(head,current,getfield(glue_data,"width") or 0,"before",trace) free_node(glue_data) else @@ -1320,9 +1320,12 @@ local function collapser(head,where,what,trace,snap,a_snapmethod) -- maybe also -- end local w = getfield(glue_data,"width") if w ~= 0 then - if trace then trace_done("flushed due to " .. why,glue_data) end + if trace then trace_done("flushed due to non zero " .. why,glue_data) end head = insert_node_before(head,current,glue_data) - else -- i really need to clean this up + elseif getfield(glue_data,"stretch") ~= 0 or getfield(glue_data,"shrink") ~= 0 then + if trace then trace_done("flushed due to stretch/shrink in" .. why,glue_data) end + head = insert_node_before(head,current,glue_data) + else -- report_vspacing("needs checking (%s): %p",skipcodes[getsubtype(glue_data)],w) free_node(glue_data) end diff --git a/tex/context/base/mkiv/spac-ver.mkiv b/tex/context/base/mkiv/spac-ver.mkiv index f2ddb16ea..4fe1012e9 100644 --- a/tex/context/base/mkiv/spac-ver.mkiv +++ b/tex/context/base/mkiv/spac-ver.mkiv @@ -1139,6 +1139,12 @@ % when enabled, sigstruts will remove themselves if nothing % goes inbetween +%D For poractical reasons we define some boundary characters here. + +\unexpanded\def\leftboundary {\boundary\plusone} +\unexpanded\def\rightboundary {\boundary\plustwo} +\unexpanded\def\signalcharacter{\boundary\plusone\char\zerocount\boundary\plustwo} % not the same as strut signals + \newsignal\strutsignal \setfalse\sigstruts \unexpanded\def\begstrut @@ -1162,9 +1168,17 @@ \hskip-\strutsignal \hskip\strutsignal} +% \def\spac_struts_beg_normal +% {\strut +% \penalty\plustenthousand +% \hskip\zeropoint} + \def\spac_struts_beg_normal - {\strut + {\boundary\plusone + \strut + %\boundary\plusone \penalty\plustenthousand + %\boundary\plusone \hskip\zeropoint} \unexpanded\def\endstrut @@ -1195,11 +1209,20 @@ \strut \fi} +% \def\spac_struts_end_normal +% {\removeunwantedspaces +% \penalty\plustenthousand +% \hskip\zeropoint +% \strut} + \def\spac_struts_end_normal {\removeunwantedspaces \penalty\plustenthousand + %\boundary\plustwo \hskip\zeropoint - \strut} + %\boundary\plustwo + \strut + \boundary\plustwo} % unsave: % diff --git a/tex/context/base/mkiv/status-files.pdf b/tex/context/base/mkiv/status-files.pdf Binary files differindex d83845a80..941bdeb48 100644 --- a/tex/context/base/mkiv/status-files.pdf +++ b/tex/context/base/mkiv/status-files.pdf diff --git a/tex/context/base/mkiv/status-lua.pdf b/tex/context/base/mkiv/status-lua.pdf Binary files differindex 59447fcec..a70cf80b6 100644 --- a/tex/context/base/mkiv/status-lua.pdf +++ b/tex/context/base/mkiv/status-lua.pdf diff --git a/tex/context/base/mkiv/strc-itm.mkvi b/tex/context/base/mkiv/strc-itm.mkvi index e43aeae45..506aec940 100644 --- a/tex/context/base/mkiv/strc-itm.mkvi +++ b/tex/context/base/mkiv/strc-itm.mkvi @@ -844,7 +844,7 @@ \ifinsidecolumns\else\ifcase\c_strc_itemgroups_column_depth \global\c_strc_itemgroups_column_depth\c_strc_itemgroups_nesting % global ? \strc_itemgroups_before_command - %\strc_itemgroups_tag_start_group + \strc_itemgroups_tag_start_group \strc_itemgroups_start_columns \fi\fi \fi diff --git a/tex/context/base/mkiv/strc-lst.mkvi b/tex/context/base/mkiv/strc-lst.mkvi index 19757aa61..e7ed0f1f2 100644 --- a/tex/context/base/mkiv/strc-lst.mkvi +++ b/tex/context/base/mkiv/strc-lst.mkvi @@ -116,6 +116,22 @@ % userdata : location=none % simple : location=here +\installcorenamespace {listlocations} + +\unexpanded\def\doifelseinlistentry#1% + {\ifcsname\??listlocations#1\endcsname + \ifnum\lastnamedcs=\structurelistlocation\relax + \doubleexpandafter\firstoftwoarguments + \else + \doubleexpandafter\secondoftwoarguments + \fi + \else + \expandafter\secondoftwoarguments + \fi} + +\unexpanded\def\doifelseincurrentlistentry + {\doifelseinlistentry\currentlist} + \unexpanded\def\structurelistinject {\dotripleempty\strc_lists_inject} @@ -150,6 +166,7 @@ userdata {\detokenize\expandafter{\normalexpanded{#userdata}}} \relax \edef\currentlistnumber{\the\scratchcounter}% +\setxvalue{\??listlocations\currentlist}{\nextinternalreference}% \ifx\p_location\v!here % this branch injects nodes ! \strc_lists_inject_enhance{\currentlistnumber}{\nextinternalreference}% @@ -381,8 +398,8 @@ \def\rawstructurelistuservariable#name% {\clf_listuserdata{\currentlist}\currentlistindex{#name}} -\unexpanded\def\structurelistfirst {\structurelistuservariable\s!first } % s! -\unexpanded\def\structurelistsecond{\structurelistuservariable\s!second} % s! +\unexpanded\def\structurelistfirst {\structurelistuservariable\s!first } % s! +\unexpanded\def\structurelistsecond {\structurelistuservariable\s!second} % s! \def\rawstructurelistfirst {\rawstructurelistuservariable\s!first } % s! % was \unexpanded \def\rawstructurelistsecond{\rawstructurelistuservariable\s!second} % s! % was \unexpanded @@ -718,10 +735,10 @@ % % \installlistfiller\v!space % {\hskip.25\emwidth\relax} -% -% \setuplistalternative -% [\c!command=\strictlistparameter\c!command, -% \c!symbol=.] + +\setuplistalternative + [\c!command=\strictlistparameter\c!command, + \c!symbol=.] \unexpanded\def\currentlistfiller {\checkedfiller{\listalternativeparameter\c!filler}} @@ -918,12 +935,16 @@ \unexpanded\def\strc_lists_apply_renderingsetup {\the\t_lists_every_renderingsetup + % now we group + \begingroup \ifx\m_strc_list_alternative\empty \edef\currentlistalternative{\listparameter\c!alternative}% \else \let\currentlistalternative\m_strc_list_alternative \fi \directsetup{\listalternativeparameter\c!renderingsetup}\relax + \endgroup + % till here, where we reset locals \the\t_lists_every_renderingcleanup} % todo: provide packager via attributes diff --git a/tex/context/base/mkiv/strc-not.mkvi b/tex/context/base/mkiv/strc-not.mkvi index e1107ff99..20bff7683 100644 --- a/tex/context/base/mkiv/strc-not.mkvi +++ b/tex/context/base/mkiv/strc-not.mkvi @@ -303,6 +303,7 @@ \startsetups[\??constructionrenderings:\v!note] \noindent + \leftboundary % experiment, to be done in more places \llap{\box\constructionheadbox\hskip\constructionparameter\c!distance}% \useconstructionstyleandcolor\c!style\c!color \ignorespaces diff --git a/tex/context/base/mkiv/syst-aux.lua b/tex/context/base/mkiv/syst-aux.lua index 0e7b2c2b6..98b92cef3 100644 --- a/tex/context/base/mkiv/syst-aux.lua +++ b/tex/context/base/mkiv/syst-aux.lua @@ -438,39 +438,77 @@ local function doifnotinset(a,b) firstofoneargument() end -interfaces.implement { +implement { name = "doifelsecommon", actions = doifelsecommon, arguments = { "string", "string" }, } -interfaces.implement { +implement { name = "doifcommon", actions = doifcommon, arguments = { "string", "string" }, } -interfaces.implement { +implement { name = "doifnotcommon", actions = doifnotcommon, arguments = { "string", "string" }, } -interfaces.implement { +implement { name = "doifelseinset", actions = doifelseinset, arguments = { "string", "string" }, } -interfaces.implement { +implement { name = "doifinset", actions = doifinset, arguments = { "string", "string" }, } -interfaces.implement { +implement { name = "doifnotinset", actions = doifnotinset, arguments = { "string", "string" }, } +-- implement { +-- name = "stringcompare", +-- arguments = { "string", "string" }, +-- actions = function(a,b) +-- context((a == b and 0) or (a > b and 1) or -1) +-- end +-- } +-- +-- implement { +-- name = "doifelsestringafter", +-- arguments = { "string", "string" }, +-- actions = function(a,b) +-- ctx_doifelse((a == b and 0) or (a > b and 1) or -1) +-- end +-- } +-- +-- implement { +-- name = "doifelsestringbefore", +-- arguments = { "string", "string" }, +-- actions = function(a,b) +-- ctx_doifelse((a == b and 0) or (a < b and -1) or 1) +-- end +-- } + +-- implement { -- not faster than addtocommalist +-- name = "additemtolist", -- unique +-- arguments = { "string", "string" }, +-- actions = function(l,s) +-- if l == "" or s == l then +-- -- s = s +-- elseif find("," .. l .. ",","," .. s .. ",") then +-- s = l +-- else +-- s = l .. "," .. s +-- end +-- context(s) +-- end +-- } diff --git a/tex/context/base/mkiv/syst-aux.mkiv b/tex/context/base/mkiv/syst-aux.mkiv index 8f8ba2024..825d18636 100644 --- a/tex/context/base/mkiv/syst-aux.mkiv +++ b/tex/context/base/mkiv/syst-aux.mkiv @@ -7148,7 +7148,7 @@ {\csname#1\ifcsname#1#2\endcsname#2\else#3\fi\endcsname} %D Signal. Some fonts have a char0 rendering so we need to make sure that it -%D is not set in the font! +%D is not set in the font! (THis will be overloaded) \unexpanded\def\signalcharacter{\char\zerocount} % \zwj @@ -7357,6 +7357,15 @@ %def\ntimes#1#2{\ifnum#2>\zerocount#1\ntimes{#1}{\numexpr#2-\plusone\relax}\fi} % 1.72 \def\ntimes#1#2{\clf_ntimes{#1}\numexpr#2\relax} % 0.33 +%D Not that useful: + +% \unexpanded\def\doifelsestringbefore{\clf_doifelsestringbefore} +% \unexpanded\def\doifelsestringafter {\clf_doifelsestringafter} + +% Could have been useful but not faster that addtocommalist and also expansion mess: +% +% \def\additemtolist#1#2{\normalexpanded{\noexpand\clf_additemtolist{#1}{#2}}} + \protect \endinput % \edef\choicetokenyes{+} diff --git a/tex/context/base/mkiv/syst-ini.mkiv b/tex/context/base/mkiv/syst-ini.mkiv index e3053adfb..fa8fd1162 100644 --- a/tex/context/base/mkiv/syst-ini.mkiv +++ b/tex/context/base/mkiv/syst-ini.mkiv @@ -957,30 +957,45 @@ % module after which the official interfaces have to be used. This is needed for % modules not made by ctx developers. -\normalprotected\def\pdfliteral {\pdfextension literal } -\normalprotected\def\pdfcolorstack {\pdfextension colorstack } -\normalprotected\def\pdfsetmatrix {\pdfextension setmatrix } -\normalprotected\def\pdfsave {\pdfextension save\relax} -\normalprotected\def\pdfrestore {\pdfextension restore\relax} -\normalprotected\def\pdfobj {\pdfextension obj } -\normalprotected\def\pdfrefobj {\pdfextension refobj } -\normalprotected\def\pdfannot {\pdfextension annot } -\normalprotected\def\pdfstartlink {\pdfextension startlink } -\normalprotected\def\pdfendlink {\pdfextension endlink\relax} -\normalprotected\def\pdfoutline {\pdfextension outline } -\normalprotected\def\pdfdest {\pdfextension dest } -\normalprotected\def\pdfthread {\pdfextension thread } -\normalprotected\def\pdfstartthread {\pdfextension startthread } -\normalprotected\def\pdfendthread {\pdfextension endthread\relax} -\normalprotected\def\pdfinfo {\pdfextension info } -\normalprotected\def\pdfcatalog {\pdfextension catalog } -\normalprotected\def\pdfnames {\pdfextension names } -\normalprotected\def\pdfincludechars {\pdfextension includechars } -\normalprotected\def\pdffontattr {\pdfextension fontattr } -\normalprotected\def\pdfmapfile {\pdfextension mapfile } -\normalprotected\def\pdfmapline {\pdfextension mapline } -\normalprotected\def\pdftrailer {\pdfextension trailer } -\normalprotected\def\pdfglyphtounicode {\pdfextension glyphtounicode } +\normalprotected\def\pdfliteral {\pdfextension literal } +\normalprotected\def\pdfcolorstack {\pdfextension colorstack } +\normalprotected\def\pdfsetmatrix {\pdfextension setmatrix } +\normalprotected\def\pdfsave {\pdfextension save\relax} +\normalprotected\def\pdfrestore {\pdfextension restore\relax} +\normalprotected\def\pdfobj {\pdfextension obj } +\normalprotected\def\pdfrefobj {\pdfextension refobj } +\normalprotected\def\pdfannot {\pdfextension annot } +\normalprotected\def\pdfstartlink {\pdfextension startlink } +\normalprotected\def\pdfendlink {\pdfextension endlink\relax} +\normalprotected\def\pdfoutline {\pdfextension outline } +\normalprotected\def\pdfdest {\pdfextension dest } +\normalprotected\def\pdfthread {\pdfextension thread } +\normalprotected\def\pdfstartthread {\pdfextension startthread } +\normalprotected\def\pdfendthread {\pdfextension endthread\relax} +\normalprotected\def\pdfinfo {\pdfextension info } +\normalprotected\def\pdfcatalog {\pdfextension catalog } +\normalprotected\def\pdfnames {\pdfextension names } +\normalprotected\def\pdfincludechars {\pdfextension includechars } +\normalprotected\def\pdffontattr {\pdfextension fontattr } +\normalprotected\def\pdfmapfile {\pdfextension mapfile } +\normalprotected\def\pdfmapline {\pdfextension mapline } +\normalprotected\def\pdftrailer {\pdfextension trailer } +\normalprotected\def\pdfglyphtounicode {\pdfextension glyphtounicode } +\normalprotected\gdef\pdfsuppressoptionalinfo {\pdfextension suppressoptionalinfo } +\global \let\pdfsuppressptexinfo \pdfsuppressoptionalinfo +\normalprotected\gdef\pdfinfoid {\pdfextension infoid } +\normalprotected\gdef\pdfinfoomitdate {\pdfextension suppressoptionalinfo \numexpr32+64\relax} + +% \chardef\pdfnofullbanner = 1 +% \chardef\pdfnofilename = 2 +% \chardef\pdfnopagenumber = 4 +% \chardef\pdfnoinfodict = 8 +% \chardef\pdfnocreator = 16 +% \chardef\pdfnocreationdate = 32 +% \chardef\pdfnomoddate = 64 +% \chardef\pdfnoproducer = 128 +% \chardef\pdfnotrapped = 256 +% \chardef\pdfnoid = 512 \def\pdftexversion {\numexpr\pdffeedback version} \def\pdftexrevision {\pdffeedback revision} diff --git a/tex/context/base/mkiv/tabl-tbl.mkiv b/tex/context/base/mkiv/tabl-tbl.mkiv index 23d8002d6..58e6b7108 100644 --- a/tex/context/base/mkiv/tabl-tbl.mkiv +++ b/tex/context/base/mkiv/tabl-tbl.mkiv @@ -1650,8 +1650,6 @@ \global\c_tabl_tabulate_max_colorcolumn\c_tabl_tabulate_column \fi \setxvalue{\??tabulatecolor\the\c_tabl_tabulate_column}{#1}% - %\attribute\alignbackgroundattribute\plusone - %\dousecolorparameter{#1}\char\zerocount\strut % hack \hbox \thealignbackgroundcolorattr{#1}{}% pack ? \endgroup} diff --git a/tex/context/base/mkiv/tabl-xtb.mkvi b/tex/context/base/mkiv/tabl-xtb.mkvi index 06a5318e1..851b6e80f 100644 --- a/tex/context/base/mkiv/tabl-xtb.mkvi +++ b/tex/context/base/mkiv/tabl-xtb.mkvi @@ -86,7 +86,7 @@ \numexpr\tablecellcolumns\relax \numexpr\raggedstatus\relax}% \def\dotagxtablesignal - {\char\zerocount}% not used + {\signalcharacter}% not used \to \everyenableelements \newdimen\d_tabl_x_width diff --git a/tex/context/base/mkiv/trac-vis.lua b/tex/context/base/mkiv/trac-vis.lua index f77a10364..061cef8ba 100644 --- a/tex/context/base/mkiv/trac-vis.lua +++ b/tex/context/base/mkiv/trac-vis.lua @@ -293,6 +293,10 @@ function nuts.setvisual(n,mode) setattr(n,a_visual,setvisual(mode,getattr(n,a_visual),true)) end +function nuts.copyvisual(n,m) + setattr(n,a_visual,getattr(m,a_visual)) +end + function visualizers.setvisual(n) texsetattribute(a_visual,setvisual(n,texgetattribute(a_visual))) end @@ -309,6 +313,10 @@ for mode, value in next, modes do trackers.register(formatters["visualizers.%s"](mode), function(v) set(mode,v) end) end +local raisepenalties = false + +directives.register("visualizers.raisepenalties",function(v) raisepenalties = v end) + local fraction = 10 trackers .register("visualizers.reset", function(v) set("reset", v) end) @@ -828,6 +836,8 @@ local function ruledpenalty(head,current,vertical) info = copy_list(info) if vertical then info = vpack_nodes(info) + elseif raisepenalties then + setfield(info,"shift",-65536*4) end head, current = insert_node_before(head,current,info) return head, getnext(current) @@ -973,21 +983,21 @@ local function visualize(head,vertical,forced,parent) return head end -local function freed(cache) - local n = 0 - for k, v in next, cache do - free_node_list(v) - n = n + 1 - end - if n == 0 then - return 0, cache - else - return n, { } - end -end - do + local function freed(cache) + local n = 0 + for k, v in next, cache do + free_node_list(v) + n = n + 1 + end + if n == 0 then + return 0, cache + else + return n, { } + end + end + local function cleanup() local hf, nw, nb, ng_v, ng_h, np_v, np_h, nk_v, nk_h nf, f_cache = freed(f_cache) diff --git a/tex/context/base/mkiv/typo-brk.lua b/tex/context/base/mkiv/typo-brk.lua index 2f97f1869..9bccf91ea 100644 --- a/tex/context/base/mkiv/typo-brk.lua +++ b/tex/context/base/mkiv/typo-brk.lua @@ -29,11 +29,11 @@ local getnext = nuts.getnext local getprev = nuts.getprev local getboth = nuts.getboth local getsubtype = nuts.getsubtype -local getchar = nuts.getchar local getfont = nuts.getfont local getid = nuts.getid local getfield = nuts.getfield local getattr = nuts.getattr +local isglyph = nuts.isglyph local setfield = nuts.setfield local setattr = nuts.setattr @@ -209,8 +209,8 @@ function breakpoints.handler(head) local map = nil local current = nead while current do - local id = getid(current) - if id == glyph_code then + local char, id = isglyph(current) + if char then local a = getattr(current,a_breakpoints) if a and a > 0 then if a ~= attr then @@ -223,7 +223,7 @@ function breakpoints.handler(head) attr = a end if map then - local cmap = map[getchar(current)] + local cmap = map[char] if cmap then -- for now we collect but when found ok we can move the handler here -- although it saves nothing in terms of performance @@ -291,9 +291,9 @@ function breakpoints.handler(head) local cright = 0 local next = getnext(current) while next and nright ~= cright do - local id = getid(next) - if id == glyph_code then - if cright == 1 and cmap[getchar(next)] then + local char, id = isglyph(next) + if char then + if cright == 1 and cmap[char] then -- let's not make it too messy break end diff --git a/tex/context/base/mkiv/typo-cap.lua b/tex/context/base/mkiv/typo-cap.lua index 0eae3b2d9..ec6326042 100644 --- a/tex/context/base/mkiv/typo-cap.lua +++ b/tex/context/base/mkiv/typo-cap.lua @@ -51,7 +51,6 @@ local disc_code = nodecodes.disc local math_code = nodecodes.math local kerning_code = kerncodes.kerning -local userskip_code = skipcodes.userskip local tasks = nodes.tasks diff --git a/tex/context/base/mkiv/typo-dha.lua b/tex/context/base/mkiv/typo-dha.lua index 30984a26c..b1ce6ffbf 100644 --- a/tex/context/base/mkiv/typo-dha.lua +++ b/tex/context/base/mkiv/typo-dha.lua @@ -53,13 +53,13 @@ local nutstring = nuts.tostring local getnext = nuts.getnext local getprev = nuts.getprev local getfont = nuts.getfont -local getchar = nuts.getchar local getid = nuts.getid local getsubtype = nuts.getsubtype local getlist = nuts.getlist local getfield = nuts.getfield local getattr = nuts.getattr local getprop = nuts.getprop +local isglyph = nuts.isglyph -- or ischar local setfield = nuts.setfield local setprop = nuts.setprop @@ -124,9 +124,8 @@ end local function nextisright(current) current = getnext(current) - local id = getid(current) + local character, id = isglyph(current) if id == glyph_code then - local character = getchar(current) local direction = chardirections[character] return direction == "r" or direction == "al" or direction == "an" end @@ -134,9 +133,8 @@ end local function previsright(current) current = getprev(current) - local id = getid(current) + local character, id = isglyph(current) if id == glyph_code then - local character = getchar(current) local direction = chardirections[character] return direction == "r" or direction == "al" or direction == "an" end @@ -161,7 +159,7 @@ local function process(start) local fences = { } while current do - local id = getid(current) + local character, id = isglyph(current) local next = getnext(current) if id == math_code then current = getnext(end_of_math(next)) @@ -179,9 +177,8 @@ local function process(start) prevattr = attr end end - if id == glyph_code then + if character then if attr and attr > 0 then - local character = getchar(current) if character == 0 then -- skip signals setprop(current,"direction",true) diff --git a/tex/context/base/mkiv/typo-drp.lua b/tex/context/base/mkiv/typo-drp.lua index 9d6d645d0..bddcc008e 100644 --- a/tex/context/base/mkiv/typo-drp.lua +++ b/tex/context/base/mkiv/typo-drp.lua @@ -9,6 +9,8 @@ if not modules then modules = { } end modules ['typo-drp'] = { -- This ons is sensitive for order (e.g. when combined with first line -- processing. +-- todo: use isglyph + local tonumber, type, next = tonumber, type, next local ceil = math.ceil local settings_to_hash = utilities.parsers.settings_to_hash diff --git a/tex/context/base/mkiv/typo-dua.lua b/tex/context/base/mkiv/typo-dua.lua index bbb071f55..867d7f04c 100644 --- a/tex/context/base/mkiv/typo-dua.lua +++ b/tex/context/base/mkiv/typo-dua.lua @@ -72,12 +72,12 @@ local tonode = nuts.tonode local nutstring = nuts.tostring local getnext = nuts.getnext -local getchar = nuts.getchar local getid = nuts.getid local getsubtype = nuts.getsubtype local getlist = nuts.getlist local getfield = nuts.getfield local getprop = nuts.getprop +local isglyph = nuts.isglyph -- or ischar local setfield = nuts.setfield local setprop = nuts.setprop @@ -205,7 +205,7 @@ local function build_list(head) -- todo: store node pointer ... saves loop local size = 0 while current do size = size + 1 - local id = getid(current) + local chr, id = isglyph(current) if getprop(current,"directions") then local skip = 0 local last = id @@ -226,7 +226,6 @@ local function build_list(head) -- todo: store node pointer ... saves loop list[size] = { char = 0xFFFC, direction = "on", original = "on", level = 0, skip = skip, id = id, last = last } end elseif id == glyph_code then - local chr = getchar(current) local dir = directiondata[chr] list[size] = { char = chr, direction = dir, original = dir, level = 0 } current = getnext(current) diff --git a/tex/context/base/mkiv/typo-dub.lua b/tex/context/base/mkiv/typo-dub.lua index 2ee85ad7d..e6a092568 100644 --- a/tex/context/base/mkiv/typo-dub.lua +++ b/tex/context/base/mkiv/typo-dub.lua @@ -60,13 +60,13 @@ local tonode = nuts.tonode local nutstring = nuts.tostring local getnext = nuts.getnext -local getchar = nuts.getchar local getid = nuts.getid local getsubtype = nuts.getsubtype local getlist = nuts.getlist local getattr = nuts.getattr local getfield = nuts.getfield local getprop = nuts.getprop +local isglyph = nuts.isglyph -- or ischar local setfield = nuts.setfield local setprop = nuts.setprop @@ -260,7 +260,7 @@ local function build_list(head) -- todo: store node pointer ... saves loop local size = 0 while current do size = size + 1 - local id = getid(current) + local chr, id = isglyph(current) if getprop(current,"directions") then local skip = 0 local last = id @@ -281,7 +281,6 @@ local function build_list(head) -- todo: store node pointer ... saves loop list[size] = { char = 0xFFFC, direction = "on", original = "on", level = 0, skip = skip, id = id, last = last } end elseif id == glyph_code then - local chr = getchar(current) local dir = directiondata[chr] list[size] = { char = chr, direction = dir, original = dir, level = 0 } current = getnext(current) diff --git a/tex/context/base/mkiv/typo-itc.lua b/tex/context/base/mkiv/typo-itc.lua index 62fea3e2e..a46f3e8a0 100644 --- a/tex/context/base/mkiv/typo-itc.lua +++ b/tex/context/base/mkiv/typo-itc.lua @@ -37,9 +37,12 @@ local getnext = nuts.getnext local getid = nuts.getid local getfont = nuts.getfont local getchar = nuts.getchar +local getdisc = nuts.getdisc local getattr = nuts.getattr local setattr = nuts.setattr local setfield = nuts.setfield +local setdisc = nuts.setdisc +local isglyph = nuts.isglyph local insert_node_after = nuts.insert_after local delete_node = nuts.delete @@ -173,28 +176,32 @@ function italics.handler(head) local previtalic = 0 local previnserted = nil - local replace = nil - local replacechar = nil - local replacehead = nil - local replaceitalic = 0 - local replaceinserted = nil + local pre = nil + local pretail = nil local post = nil + local posttail = nil local postchar = nil local posthead = nil local postitalic = 0 local postinserted = nil + local replace = nil + local replacetail = nil + local replacechar = nil + local replacehead = nil + local replaceitalic = 0 + local replaceinserted = nil + local current = prevhead local done = false local lastfont = nil local lastattr = nil while current do - local id = getid(current) - if id == glyph_code then + local char, id = isglyph(current) + if char then local font = getfont(current) - local char = getchar(current) local data = italicsdata[font] if font ~= lastfont then if previtalic ~= 0 then @@ -275,95 +282,84 @@ function italics.handler(head) replaceitalic = 0 postinserted = nil postitalic = 0 - replace = getfield(current,"replace") + updated = false + pre, post, replace, pretail, posttail, replacetail = getdisc(current) if replace then - local current = find_tail(replace) - if getid(current) ~= glyph_code then - current = getprev(current) - end - if current and getid(current) == glyph_code then - local font = getfont(current) - local char = getchar(current) - local data = italicsdata[font] - if data then - local attr = forcedvariant or getattr(current,a_italics) - if attr and attr > 0 then - local cd = data[char] - if not cd then - -- this really can happen - replaceitalic = 0 - else - replaceitalic = cd.italic - if not replaceitalic then - replaceitalic = setitalicinfont(font,char) -- calculated once - -- replaceitalic = 0 - end - if replaceitalic ~= 0 then - lastfont = font - lastattr = attr - replacechar = char - replacehead = replace - replace = current + local current = replacetail + while current do + local char, id = isglyph(current) + if char then + local font = getfont(current) + local data = italicsdata[font] + if data then + local attr = forcedvariant or getattr(current,a_italics) + if attr and attr > 0 then + local cd = data[char] + if not cd then + -- this really can happen + replaceitalic = 0 + else + replaceitalic = cd.italic + if not replaceitalic then + replaceitalic = setitalicinfont(font,char) -- calculated once + -- replaceitalic = 0 + end + if replaceitalic ~= 0 then + lastfont = font + lastattr = attr + replacechar = char + replacehead = replace + replace = current + updated = true + end end end --- else --- replaceitalic = 0 end --- else --- replaceitalic = 0 + break + else + current = getprev(current) end --- else --- replaceitalic = 0 end --- replaceinserted = nil --- else --- replaceitalic = 0 --- replaceinserted = nil end - post = getfield(current,"post") if post then - local current = find_tail(post) - if getid(current) ~= glyph_code then - current = getprev(current) - end - if current and getid(current) == glyph_code then - local font = getfont(current) - local char = getchar(current) - local data = italicsdata[font] - if data then - local attr = forcedvariant or getattr(current,a_italics) - if attr and attr > 0 then - local cd = data[char] - if not cd then - -- this really can happen --- postitalic = 0 - else - postitalic = cd.italic - if not postitalic then - postitalic = setitalicinfont(font,char) -- calculated once - -- postitalic = 0 - end - if postitalic ~= 0 then - lastfont = font - lastattr = attr - postchar = char - posthead = post - post = current + local current = posttail + while current do + local char, id = isglyph(current) + if char then + local font = getfont(current) + local data = italicsdata[font] + if data then + local attr = forcedvariant or getattr(current,a_italics) + if attr and attr > 0 then + local cd = data[char] + if not cd then + -- this really can happen + -- postitalic = 0 + else + postitalic = cd.italic + if not postitalic then + postitalic = setitalicinfont(font,char) -- calculated once + -- postitalic = 0 + end + if postitalic ~= 0 then + lastfont = font + lastattr = attr + postchar = char + posthead = post + post = current + updated = true + end end end --- else --- postitalic = 0 end --- else --- postitalic = 0 + break + else + current = getprev(current) end --- else --- postitalic = 0 end --- postinserted = nil --- else --- postitalic = 0 --- postinserted = nil + end + if updated then + setdisc(current,pre,post,replace) end elseif id == kern_code then -- how about fontkern ? previnserted = nil @@ -410,9 +406,9 @@ function italics.handler(head) postinserted = nil postitalic = 0 local next = getnext(current) - if next and getid(next) == glyph_code then - local char = getchar(next) - if is_punctuation[char] then + if next then + local char, id = isglyph(next) + if char and is_punctuation[char] then local kern = getprev(current) if kern and getid(kern) == kern_code then local glyph = getprev(kern) diff --git a/tex/context/base/mkiv/typo-krn.lua b/tex/context/base/mkiv/typo-krn.lua index ddb7abd86..a245fec41 100644 --- a/tex/context/base/mkiv/typo-krn.lua +++ b/tex/context/base/mkiv/typo-krn.lua @@ -7,6 +7,7 @@ if not modules then modules = { } end modules ['typo-krn'] = { } -- glue is still somewhat suboptimal +-- components: better split on tounicode local next, type, tonumber = next, type, tonumber local utfchar = utf.char @@ -38,6 +39,7 @@ local getfont = nuts.getfont local getsubtype = nuts.getsubtype local getchar = nuts.getchar local getdisc = nuts.getdisc +local isglyph = nuts.isglyph local setfield = nuts.setfield local getattr = nuts.getattr @@ -222,7 +224,7 @@ end -- sublists .. beware: we can have char -1 local function inject_begin(boundary,prev,keeptogether,krn,ok) -- prev is a glyph - local id = getid(boundary) + local char, id = isglyph(boundary) if id == kern_code then if getsubtype(boundary) == kerning_code or getattr(boundary,a_fontkern) then local inject = true @@ -239,17 +241,16 @@ local function inject_begin(boundary,prev,keeptogether,krn,ok) -- prev is a glyp return boundary, true end end - elseif id == glyph_code then + elseif char then if keeptogether and keeptogether(boundary,prev) then -- keep 'm else - local charone = getchar(prev) - if charone > 0 then - local font = getfont(boundary) - local chartwo = getchar(boundary) - local data = chardata[font][charone] - local kerns = data and data.kerns - local kern = new_kern((kerns and kerns[chartwo] or 0) + quaddata[font]*krn) + local prevchar = isglyph(prev) + if prevchar and prevchar > 0 then + local font = getfont(boundary) + local data = chardata[font][prevchar] + local kerns = data and data.kerns + local kern = new_kern((kerns and kerns[char] or 0) + quaddata[font]*krn) setlink(kern,boundary) return kern, true end @@ -260,7 +261,7 @@ end local function inject_end(boundary,next,keeptogether,krn,ok) local tail = find_node_tail(boundary) - local id = getid(tail) + local char, id = getid(tail) if id == kern_code then if getsubtype(tail) == kerning_code or getattr(tail,a_fontkern) then local inject = true @@ -277,17 +278,16 @@ local function inject_end(boundary,next,keeptogether,krn,ok) return boundary, true end end - elseif id == glyph_code then + elseif char then if keeptogether and keeptogether(tail,two) then -- keep 'm else - local charone = getchar(tail) - if charone > 0 then - local font = getfont(tail) - local chartwo = getchar(next) - local data = chardata[font][charone] - local kerns = data and data.kerns - local kern = (kerns and kerns[chartwo] or 0) + quaddata[font]*krn + local nextchar = isglyph(tail) + if nextchar and nextchar > 0 then + local font = getfont(tail) + local data = chardata[font][nextchar] + local kerns = data and data.kerns + local kern = (kerns and kerns[char] or 0) + quaddata[font]*krn insert_node_after(boundary,tail,new_kern(kern)) return boundary, true end @@ -303,15 +303,14 @@ local function process_list(head,keeptogether,krn,font,okay) local kern = 0 local mark = font and markdata[font] while start do - local id = getid(start) - if id == glyph_code then + local char, id = isglyph(start) + if char then if not font then font = getfont(start) mark = markdata[font] kern = quaddata[font]*krn end if prev then - local char = getchar(start) if mark[char] then -- skip elseif pid == kern_code then diff --git a/tex/context/base/mkiv/typo-lin.lua b/tex/context/base/mkiv/typo-lin.lua index e405d6c21..b794ed13c 100644 --- a/tex/context/base/mkiv/typo-lin.lua +++ b/tex/context/base/mkiv/typo-lin.lua @@ -66,7 +66,6 @@ local glue_code = nodecodes.glue local kern_code = nodecodes.kern local line_code = listcodes.line local localpar_code = nodecodes.localpar -local userskip_code = gluecodes.userskip local leftskip_code = gluecodes.leftskip local rightskip_code = gluecodes.rightskip local parfillskip_code = gluecodes.parfillskip diff --git a/tex/context/base/mkiv/typo-rep.lua b/tex/context/base/mkiv/typo-rep.lua index d95eff68e..a8925a2ce 100644 --- a/tex/context/base/mkiv/typo-rep.lua +++ b/tex/context/base/mkiv/typo-rep.lua @@ -26,7 +26,7 @@ local tonode = nuts.tonode local getnext = nuts.getnext local getchar = nuts.getchar -local getid = nuts.getid +local isglyph = nuts.isglyph local getattr = nuts.getattr @@ -89,11 +89,11 @@ function nodes.handlers.stripping(head) head = tonut(head) local current, done = head, false while current do - if getid(current) == glyph_code then + local char, id = isglyph(current) + if char then -- it's more efficient to keep track of what needs to be kept local todo = getattr(current,a_stripping) if todo == 1 then - local char = getchar(current) local what = glyphs[char] if what then head, current = process(what,head,current,char) diff --git a/tex/context/base/mkiv/typo-spa.lua b/tex/context/base/mkiv/typo-spa.lua index 519ba3f34..f00e3ae6b 100644 --- a/tex/context/base/mkiv/typo-spa.lua +++ b/tex/context/base/mkiv/typo-spa.lua @@ -32,11 +32,10 @@ local tonode = nuts.tonode local getnext = nuts.getnext local getprev = nuts.getprev -local getchar = nuts.getchar -local getid = nuts.getid local getfont = nuts.getfont local getattr = nuts.getattr local setattr = nuts.setattr +local isglyph = nuts.isglyph local insert_node_before = nuts.insert_before local insert_node_after = nuts.insert_after @@ -84,13 +83,12 @@ function spacings.handler(head) -- head is always begin of par (whatsit), so we have at least two prev nodes -- penalty followed by glue while start do - local id = getid(start) - if id == glyph_code then + local char, id = isglyph(start) + if char then local attr = getattr(start,a_spacings) if attr and attr > 0 then local data = mapping[attr] if data then - local char = getchar(start) local map = data.characters[char] setattr(start,a_spacings,unsetvalue) -- needed? if map then diff --git a/tex/context/base/mkiv/typo-sus.lua b/tex/context/base/mkiv/typo-sus.lua index 2f1949ff0..ce1933330 100644 --- a/tex/context/base/mkiv/typo-sus.lua +++ b/tex/context/base/mkiv/typo-sus.lua @@ -42,13 +42,13 @@ local tonut = nodes.tonut local tonode = nodes.tonode local getid = nuts.getid -local getchar = nuts.getchar local getprev = nuts.getprev local getnext = nuts.getnext local getfield = nuts.getfield local getattr = nuts.getattr local getfont = nuts.getfont local getlist = nuts.getlist +local isglyph = nuts.isglyph local setfield = nuts.setfield local setattr = nuts.setattr @@ -166,9 +166,8 @@ function typesetters.marksuspects(head) local lastdone = nil while current do if getattr(current,a_suspecting) then - local id = getid(current) - if id == glyph_code then - local char = getchar(current) + local char, id = isglyph(current) + if char then local code = categories[char] local done = false if punctuation[code] then diff --git a/tex/context/base/mkiv/typo-tal.lua b/tex/context/base/mkiv/typo-tal.lua index 2594b7298..c7efc0f28 100644 --- a/tex/context/base/mkiv/typo-tal.lua +++ b/tex/context/base/mkiv/typo-tal.lua @@ -43,6 +43,7 @@ local getfont = nuts.getfont local getchar = nuts.getchar local getfield = nuts.getfield local getattr = nuts.getattr +local isglyph = nuts.isglyph local setfield = nuts.setfield local setattr = nuts.setattr @@ -196,9 +197,8 @@ function characteralign.handler(originalhead,where) -- we can think of constraints if method == v_number then while current do - local id = getid(current) - if id == glyph_code then - local char = getchar(current) + local char, id = isglyph(current) + if char then local font = getfont(current) -- local unicode = unicodes[font][char] local unicode = fontcharacters[font][char].unicode or char -- ignore tables @@ -273,9 +273,8 @@ function characteralign.handler(originalhead,where) end else while current do - local id = getid(current) - if id == glyph_code then - local char = getchar(current) + local char, id = isglyph(current) + if char then local font = getfont(current) -- local unicode = unicodes[font][char] local unicode = fontcharacters[font][char].unicode or char -- ignore tables diff --git a/tex/context/fonts/mkiv/type-imp-lato.mkiv b/tex/context/fonts/mkiv/type-imp-lato.mkiv index 8fb8647fc..11a386b3f 100644 --- a/tex/context/fonts/mkiv/type-imp-lato.mkiv +++ b/tex/context/fonts/mkiv/type-imp-lato.mkiv @@ -26,7 +26,7 @@ \setups[\s!font:\s!fallback:\s!sans] \definefontsynonym [\s!Sans] [\s!file:lato-reg] [\s!features=\s!default] \definefontsynonym [\s!SansBold] [\s!file:lato-bol] [\s!features=\s!default] - \definefontsynonym [\s!SansItalic] [\s!file:lato-reglta] [\s!features=\s!default] + \definefontsynonym [\s!SansItalic] [\s!file:lato-regita] [\s!features=\s!default] \definefontsynonym [\s!SansBoldItalic] [\s!file:lato-bollta] [\s!features=\s!default] \stoptypescript @@ -35,7 +35,7 @@ \definefontsynonym [\s!Sans] [\s!file:lato-lig] [\s!features=\s!default] \definefontsynonym [\s!SansBold] [\s!file:lato-reg] [\s!features=\s!default] \definefontsynonym [\s!SansItalic] [\s!file:lato-liglta] [\s!features=\s!default] - \definefontsynonym [\s!SansBoldItalic] [\s!file:lato-reglta] [\s!features=\s!default] + \definefontsynonym [\s!SansBoldItalic] [\s!file:lato-regita] [\s!features=\s!default] \stoptypescript \starttypescript [\s!sans] [lato-dark] [\s!name] diff --git a/tex/context/fonts/mkiv/type-imp-texgyre.mkiv b/tex/context/fonts/mkiv/type-imp-texgyre.mkiv index ca5d456e5..86db8c603 100644 --- a/tex/context/fonts/mkiv/type-imp-texgyre.mkiv +++ b/tex/context/fonts/mkiv/type-imp-texgyre.mkiv @@ -52,7 +52,7 @@ \definetypescriptprefix [n:courier] [TeXGyreCursor] \definetypescriptprefix [n:chancery] [TeXGyreChorus] - \starttypescript [\s!serif,\s!sans] [adventor,bonum,bookman,heros,helvetica,pagella,palatino,bonum,bookman,schola,schoolbook,termes,times] + \starttypescript [\s!serif,\s!sans] [adventor,bonum,bookman,heros,helvetica,pagella,palatino,schola,schoolbook,termes,times] \definefontsynonym [\typescriptprefix{n:\typescripttwo}-Regular] [\s!file:texgyre\typescriptprefix{f:\typescripttwo}-regular] [\s!features=\s!default] \definefontsynonym [\typescriptprefix{n:\typescripttwo}-Italic] [\s!file:texgyre\typescriptprefix{f:\typescripttwo}-italic] [\s!features=\s!default] \definefontsynonym [\typescriptprefix{n:\typescripttwo}-Bold] [\s!file:texgyre\typescriptprefix{f:\typescripttwo}-bold] [\s!features=\s!default] diff --git a/tex/context/interface/common/keys-cs.xml b/tex/context/interface/common/keys-cs.xml index ea492e3d0..01504609a 100644 --- a/tex/context/interface/common/keys-cs.xml +++ b/tex/context/interface/common/keys-cs.xml @@ -1090,6 +1090,7 @@ <cd:constant name='resources' value='resources'/> <cd:constant name='reverse' value='reverse'/> <cd:constant name='right' value='vpravo'/> + <cd:constant name='rightchars' value='rightchars'/> <cd:constant name='rightcolor' value='barvavpravo'/> <cd:constant name='rightcompoundhyphen' value='rightcompoundhyphen'/> <cd:constant name='rightedge' value='pravahrana'/> diff --git a/tex/context/interface/common/keys-de.xml b/tex/context/interface/common/keys-de.xml index 26c226166..97a8ef09b 100644 --- a/tex/context/interface/common/keys-de.xml +++ b/tex/context/interface/common/keys-de.xml @@ -1090,6 +1090,7 @@ <cd:constant name='resources' value='resources'/> <cd:constant name='reverse' value='reverse'/> <cd:constant name='right' value='rechts'/> + <cd:constant name='rightchars' value='rightchars'/> <cd:constant name='rightcolor' value='rechterfarbe'/> <cd:constant name='rightcompoundhyphen' value='rightcompoundhyphen'/> <cd:constant name='rightedge' value='rechtekante'/> diff --git a/tex/context/interface/common/keys-en.xml b/tex/context/interface/common/keys-en.xml index 709e393a7..c22ee2820 100644 --- a/tex/context/interface/common/keys-en.xml +++ b/tex/context/interface/common/keys-en.xml @@ -1090,6 +1090,7 @@ <cd:constant name='resources' value='resources'/> <cd:constant name='reverse' value='reverse'/> <cd:constant name='right' value='right'/> + <cd:constant name='rightchars' value='rightchars'/> <cd:constant name='rightcolor' value='rightcolor'/> <cd:constant name='rightcompoundhyphen' value='rightcompoundhyphen'/> <cd:constant name='rightedge' value='rightedge'/> diff --git a/tex/context/interface/common/keys-fr.xml b/tex/context/interface/common/keys-fr.xml index 442d9c91d..b03d55d6d 100644 --- a/tex/context/interface/common/keys-fr.xml +++ b/tex/context/interface/common/keys-fr.xml @@ -1090,6 +1090,7 @@ <cd:constant name='resources' value='resources'/> <cd:constant name='reverse' value='inverse'/> <cd:constant name='right' value='droite'/> + <cd:constant name='rightchars' value='rightchars'/> <cd:constant name='rightcolor' value='couleurdroite'/> <cd:constant name='rightcompoundhyphen' value='rightcompoundhyphen'/> <cd:constant name='rightedge' value='borddroit'/> diff --git a/tex/context/interface/common/keys-it.xml b/tex/context/interface/common/keys-it.xml index 0860dc302..622e73f4a 100644 --- a/tex/context/interface/common/keys-it.xml +++ b/tex/context/interface/common/keys-it.xml @@ -1090,6 +1090,7 @@ <cd:constant name='resources' value='resources'/> <cd:constant name='reverse' value='invertito'/> <cd:constant name='right' value='destra'/> + <cd:constant name='rightchars' value='rightchars'/> <cd:constant name='rightcolor' value='coloredestra'/> <cd:constant name='rightcompoundhyphen' value='rightcompoundhyphen'/> <cd:constant name='rightedge' value='bordodestro'/> diff --git a/tex/context/interface/common/keys-nl.xml b/tex/context/interface/common/keys-nl.xml index 50d18abb5..21040d080 100644 --- a/tex/context/interface/common/keys-nl.xml +++ b/tex/context/interface/common/keys-nl.xml @@ -1090,6 +1090,7 @@ <cd:constant name='resources' value='resources'/> <cd:constant name='reverse' value='omgekeerd'/> <cd:constant name='right' value='rechts'/> + <cd:constant name='rightchars' value='rightchars'/> <cd:constant name='rightcolor' value='rechterkleur'/> <cd:constant name='rightcompoundhyphen' value='rechterkoppelteken'/> <cd:constant name='rightedge' value='rechterrand'/> diff --git a/tex/context/interface/common/keys-pe.xml b/tex/context/interface/common/keys-pe.xml index 297b22ce4..adf7c3e23 100644 --- a/tex/context/interface/common/keys-pe.xml +++ b/tex/context/interface/common/keys-pe.xml @@ -1090,6 +1090,7 @@ <cd:constant name='resources' value='resources'/> <cd:constant name='reverse' value='برعکس'/> <cd:constant name='right' value='راست'/> + <cd:constant name='rightchars' value='rightchars'/> <cd:constant name='rightcolor' value='رنگراست'/> <cd:constant name='rightcompoundhyphen' value='rightcompoundhyphen'/> <cd:constant name='rightedge' value='لبهراست'/> diff --git a/tex/context/interface/common/keys-ro.xml b/tex/context/interface/common/keys-ro.xml index 21a10c7c2..474a2ade5 100644 --- a/tex/context/interface/common/keys-ro.xml +++ b/tex/context/interface/common/keys-ro.xml @@ -1090,6 +1090,7 @@ <cd:constant name='resources' value='resources'/> <cd:constant name='reverse' value='reverse'/> <cd:constant name='right' value='dreapta'/> + <cd:constant name='rightchars' value='rightchars'/> <cd:constant name='rightcolor' value='culoaredreapta'/> <cd:constant name='rightcompoundhyphen' value='rightcompoundhyphen'/> <cd:constant name='rightedge' value='borduradreapta'/> diff --git a/tex/context/modules/mkiv/m-json.mkiv b/tex/context/modules/mkiv/m-json.mkiv index 329aa0f31..095b49558 100644 --- a/tex/context/modules/mkiv/m-json.mkiv +++ b/tex/context/modules/mkiv/m-json.mkiv @@ -27,4 +27,6 @@ \registerctxluafile{util-jsn}{} +% \def\u#1#2#3#4{\cldcontext{utf.char(0x#1#2#3#4)}} + \stopmodule diff --git a/tex/context/modules/mkiv/m-visual.mkiv b/tex/context/modules/mkiv/m-visual.mkiv index ee48836ed..01fae49e2 100644 --- a/tex/context/modules/mkiv/m-visual.mkiv +++ b/tex/context/modules/mkiv/m-visual.mkiv @@ -90,7 +90,7 @@ \def\dofakewords#1% {\bgroup \dorecurse{#1} - {\iffaketrigger\char\zerocount\fi % so that e.g. line numbering works + {\iffaketrigger\signalcharacter\fi % so that e.g. line numbering works \getrandomcount\scratchcounter{1}{5}% \dorecurse\scratchcounter {\getrandomdimen\scratchdimen{.5em}{1.25em}% diff --git a/tex/context/modules/mkiv/x-set-11.mkiv b/tex/context/modules/mkiv/x-set-11.mkiv index 661f3fb4f..ce14b0619 100644 --- a/tex/context/modules/mkiv/x-set-11.mkiv +++ b/tex/context/modules/mkiv/x-set-11.mkiv @@ -13,7 +13,7 @@ %C details. % we can make this module a bit cleaner using more recent features -% like sorting the xml directly +% like sorting the xml directly .. will happen stepwise % \startluacode % collectgarbage("stop") @@ -506,25 +506,25 @@ \installsetuponlycommandhandler \??interfacesetup {setup} % \??interfacesetup -\unexpanded\def\c!setup!definereserved#1#2% +\unexpanded\def\cmd_define_reserved#1#2% {\setvalue{\??interfacesetupreserved#1}{#2}} -\unexpanded\def\c!setup!reserved!#1% +\unexpanded\def\cmd_reserved_value#1% {\executeifdefined{\??interfacesetupreserved#1}{#1}} -\unexpanded\def\c!setup!internal!#1% +\unexpanded\def\cmd_internal_value#1% {\dontleavehmode \begingroup \setupintfont{#1}% \endgroup} -\unexpanded\def\c!setup!text!#1% +\unexpanded\def\cmd_text_value#1% {\dontleavehmode \begingroup \setupvarfont{#1}% \endgroup} -\unexpanded\def\c!setup!command!#1% +\unexpanded\def\cmd_command_value#1% {{\setupvarfont{\texescape...#1}}} \defineregister @@ -674,36 +674,42 @@ \newconstant\kindofsetup -\unexpanded\def\basicsetup{\kindofsetup\zerocount\doshowsetup} -\unexpanded\def\shortsetup{\kindofsetup\plusone \doshowsetup} -\unexpanded\def\setup {\kindofsetup\plustwo \doshowsetup} -\unexpanded\def\showsetup {\kindofsetup\plustwo \doshowsetup} +\unexpanded\def\basicsetup{\kindofsetup\zerocount\cmd_show_setup} +\unexpanded\def\shortsetup{\kindofsetup\plusone \cmd_show_setup} +\unexpanded\def\setup {\kindofsetup\plustwo \cmd_show_setup} +\unexpanded\def\showsetup {\kindofsetup\plustwo \cmd_show_setup} -%unexpanded\def\showsetupinlist#1#2#3{\kindofsetup\plustwo\showsetupindeed{#3}\par} -\unexpanded\def\showsetupinlist#1#2#3{\kindofsetup\plustwo\xmlsetup{#3}{xml:setups:typeset}\par} +\unexpanded\def\showsetupinlist#1#2#3% + {\kindofsetup\plustwo\xmlsetup{#3}{xml:setups:typeset}\par} % todo: only references in lists -\unexpanded\def\doshowsetup - {\dosingleempty\dodoshowsetup} +\newconditional\c_cmd_showsetup -\def\dodoshowsetup[#1]% +\installtextracker + {cmd.showsetup} + {\settrue\c_cmd_showsetup} + {\setfalse\c_cmd_showsetup} + +\unexpanded\def\cmd_show_setup + {\doifelsenextoptionalcs\cmd_show_setup_yes\cmd_show_setup_nop} + +\def\cmd_show_setup_yes[#1]% {\iffirstargument - \dododoshowsetup{#1}% + \cmd_show_setup_nop{#1}% \else - \expandafter\dododoshowsetup + \expandafter\cmd_show_setup_nop \fi} -\def\dododoshowsetup#1% this will trigger 'used' +\def\cmd_show_setup_nop#1% this will trigger 'used' {\registersort[texcommand][stp:x:#1]% - \showsetupindeed{#1}} - -\def\showsetupindeed#1% - {\startelement[setup][name=#1]% + \ifconditional\c_cmd_showsetup + \writestatus{setup}{#1 / \rawsynonymname{texcommand}{stp:x:#1}}% + \fi + \startelement[setup][name=#1]% \startelement[noexport][comment={setup definition #1}]% -% \nospaces\plusone \xmlsetup{\rawsynonymname{texcommand}{stp:x:#1}}{xml:setups:typeset} - % \xmlfilterlist{\loadedsetups}{/interface/command['#1' == (@type=='environment' and '\e!start' or '') .. @name]/command(xml:setups:typeset)}% + % \xmlfilterlist{\loadedsetups}{/interface/command['#1' == (@type=='environment' and '\e!start' or '') .. @name]/command(xml:setups:typeset)}% \stopelement \stopelement} @@ -1006,9 +1012,9 @@ \startxmlsetups xml:setups:parameter \doifmodeelse {setups-measure} { - \c!setup!reserved!{\xmlatt{#1}{name}}\par + \cmd_reserved_value{\xmlatt{#1}{name}}\par } { - \startsecondSETUPcolumn{\c!setup!reserved!{\xmlatt{#1}{name}}}{=} + \startsecondSETUPcolumn{\cmd_reserved_value{\xmlatt{#1}{name}}}{=} \ignorespaces \xmlflush{#1} \doifmode{interface:setup:defaults} { @@ -1037,21 +1043,21 @@ \xmlmapvalue{setups:method}{none} {} \startxmlsetups xml:setups:constant:value - \c!setup!reserved!{\xmlatt{#1}{type}} + \cmd_reserved_value{\xmlatt{#1}{type}} \stopxmlsetups \startxmlsetups xml:setups:constant \doifelsemode {setups-pass-one} { } { \doifsomethingelse{\xmlatt{#1}{prefix}} { - \c!setup!reserved!{\xmllastatt} + \cmd_reserved_value{\xmllastatt} \xmlmappedvalue{setups:method}{\xmlatt{#1}{method}}{none} } { \doif {\xmlatt{#1}{default}} {yes} { \underbar % next needs to be {braced} } } - {\c!setup!reserved!{\xmlatt{#1}{type}}} + {\cmd_reserved_value{\xmlatt{#1}{type}}} \space \ignorespaces } @@ -1061,7 +1067,7 @@ \doifelsemode {setups-pass-one} { \expanded{\setupintfont{\xmlatt{#1}{value}}}\ignorespaces } { - \c!setup!reserved!{\xmlatt{#1}{value}} + \cmd_reserved_value{\xmlatt{#1}{value}} \space \ignorespaces } @@ -1069,7 +1075,7 @@ \startxmlsetups xml:setups:inherit \secondSETUPcolumn { - \c!setup!text!{\getmessage{setup}{inherits}} + \cmd_text_value{\getmessage{setup}{inherits}} \enspace \letterbackslash \xmlatt{#1}{name} @@ -1079,64 +1085,64 @@ \unexpanded\def\simpleSETUPargument#1% {\startfirstSETUPcolumn{\showSETUPnumber}% - \c!setup!internal!{#1}% + \cmd_internal_value{#1}% \stopfirstSETUPcolumn \blank[\v!halfline] \ignorespaces} -\c!setup!definereserved {cd:command} {\c!setup!internal!{\getmessage{setup}{command}}} -\c!setup!definereserved {cd:dimension} {\c!setup!internal!{\getmessage{setup}{dimension}}} -\c!setup!definereserved {cd:file} {\c!setup!internal!{\getmessage{setup}{file}}} -\c!setup!definereserved {cd:buffer} {\c!setup!internal!{\getmessage{setup}{buffer}}} -\c!setup!definereserved {cd:name} {\c!setup!internal!{\getmessage{setup}{identifier}}} -\c!setup!definereserved {cd:character} {\c!setup!internal!{\getmessage{setup}{character}}} -\c!setup!definereserved {cd:mark} {\c!setup!internal!{\getmessage{setup}{mark}}} -\c!setup!definereserved {cd:number} {\c!setup!internal!{\getmessage{setup}{number}}} -\c!setup!definereserved {cd:first} {\c!setup!internal!{\getmessage{setup}{first}}} -\c!setup!definereserved {cd:last} {\c!setup!internal!{\getmessage{setup}{last}}} -\c!setup!definereserved {cd:reference} {\c!setup!internal!{\getmessage{setup}{reference}}} -\c!setup!definereserved {cd:plural} {\c!setup!internal!{\getmessage{setup}{plural}}} -\c!setup!definereserved {cd:singular} {\c!setup!internal!{\getmessage{setup}{singular}}} -\c!setup!definereserved {cd:text} {\c!setup!internal!{\getmessage{setup}{text}}} -\c!setup!definereserved {cd:formula} {\c!setup!internal!{\getmessage{setup}{formula}}} -\c!setup!definereserved {cd:file} {\c!setup!internal!{\getmessage{setup}{file}}} -\c!setup!definereserved {cd:matrix} {\c!setup!internal!{\getmessage{setup}{matrix}}} -\c!setup!definereserved {cd:list} {\c!setup!internal!{\getmessage{setup}{list}}} -\c!setup!definereserved {cd:section} {\c!setup!internal!{\getmessage{setup}{section}}} -\c!setup!definereserved {cd:language} {\c!setup!internal!{\getmessage{setup}{language}}} -\c!setup!definereserved {cd:section} {\c!setup!internal!{\getmessage{setup}{section}}} -\c!setup!definereserved {cd:language} {\c!setup!internal!{\getmessage{setup}{language}}} -\c!setup!definereserved {cd:processor} {\c!setup!internal!{\getmessage{setup}{processor}}} -\c!setup!definereserved {cd:style} {\c!setup!internal!{\getmessage{setup}{style}}} -\c!setup!definereserved {cd:font} {\c!setup!internal!{\getmessage{setup}{font}}} -\c!setup!definereserved {cd:character} {\c!setup!internal!{\getmessage{setup}{character}}} -\c!setup!definereserved {cd:userdata} {\c!setup!internal!{\getmessage{setup}{userdata}}} -\c!setup!definereserved {cd:key} {\c!setup!internal!{\getmessage{setup}{key}}} -\c!setup!definereserved {cd:value} {\c!setup!internal!{\getmessage{setup}{value}}} -\c!setup!definereserved {cd:color} {\c!setup!internal!{\getmessage{setup}{color}}} -\c!setup!definereserved {cd:template} {\c!setup!internal!{\getmessage{setup}{template}}} -\c!setup!definereserved {cd:node} {\c!setup!internal!{\getmessage{setup}{node}}} -\c!setup!definereserved {cd:lpath} {\c!setup!internal!{\getmessage{setup}{lpath}}} -\c!setup!definereserved {cd:setup} {\c!setup!internal!{\getmessage{setup}{setup}}} -\c!setup!definereserved {cd:xmlsetup} {\c!setup!internal!{\getmessage{setup}{xmlsetup}}} -\c!setup!definereserved {cd:luafunction} {\c!setup!internal!{\getmessage{setup}{luafunction}}} -\c!setup!definereserved {cd:marking} {\c!setup!internal!{\getmessage{setup}{marking}}} -\c!setup!definereserved {cd:sectionblock} {\c!setup!internal!{\getmessage{setup}{sectionblock}}} -\c!setup!definereserved {cd:row} {\c!setup!internal!{\getmessage{setup}{row}}} -\c!setup!definereserved {cd:column} {\c!setup!internal!{\getmessage{setup}{column}}} -\c!setup!definereserved {cd:url} {\c!setup!internal!{\getmessage{setup}{url}}} -\c!setup!definereserved {cd:true} {\c!setup!internal!{\getmessage{setup}{true}}} -\c!setup!definereserved {cd:false} {\c!setup!internal!{\getmessage{setup}{false}}} -\c!setup!definereserved {cd:category} {\c!setup!internal!{\getmessage{setup}{category}}} -\c!setup!definereserved {cd:csname} {\c!setup!internal!{\getmessage{setup}{csname}}} -\c!setup!definereserved {cd:content} {\c!setup!internal!{\getmessage{setup}{content}}} - -%c!setup!definereserved {cd:noargument} {\c!setup!command! {}} -\c!setup!definereserved {cd:oneargument} {\c!setup!command! {\texthash1}} -\c!setup!definereserved {cd:twoarguments} {\c!setup!command! {\texthash1\texthash2}} -\c!setup!definereserved {cd:threearguments} {\c!setup!command! {\texthash1\texthash2\texthash3}} - -\c!setup!definereserved {cd:sign} {[-+]} +\cmd_define_reserved {cd:command} {\cmd_internal_value{\getmessage{setup}{command}}} +\cmd_define_reserved {cd:dimension} {\cmd_internal_value{\getmessage{setup}{dimension}}} +\cmd_define_reserved {cd:file} {\cmd_internal_value{\getmessage{setup}{file}}} +\cmd_define_reserved {cd:buffer} {\cmd_internal_value{\getmessage{setup}{buffer}}} +\cmd_define_reserved {cd:name} {\cmd_internal_value{\getmessage{setup}{identifier}}} +\cmd_define_reserved {cd:character} {\cmd_internal_value{\getmessage{setup}{character}}} +\cmd_define_reserved {cd:mark} {\cmd_internal_value{\getmessage{setup}{mark}}} +\cmd_define_reserved {cd:number} {\cmd_internal_value{\getmessage{setup}{number}}} +\cmd_define_reserved {cd:first} {\cmd_internal_value{\getmessage{setup}{first}}} +\cmd_define_reserved {cd:last} {\cmd_internal_value{\getmessage{setup}{last}}} +\cmd_define_reserved {cd:reference} {\cmd_internal_value{\getmessage{setup}{reference}}} +\cmd_define_reserved {cd:plural} {\cmd_internal_value{\getmessage{setup}{plural}}} +\cmd_define_reserved {cd:singular} {\cmd_internal_value{\getmessage{setup}{singular}}} +\cmd_define_reserved {cd:text} {\cmd_internal_value{\getmessage{setup}{text}}} +\cmd_define_reserved {cd:formula} {\cmd_internal_value{\getmessage{setup}{formula}}} +\cmd_define_reserved {cd:file} {\cmd_internal_value{\getmessage{setup}{file}}} +\cmd_define_reserved {cd:matrix} {\cmd_internal_value{\getmessage{setup}{matrix}}} +\cmd_define_reserved {cd:list} {\cmd_internal_value{\getmessage{setup}{list}}} +\cmd_define_reserved {cd:section} {\cmd_internal_value{\getmessage{setup}{section}}} +\cmd_define_reserved {cd:language} {\cmd_internal_value{\getmessage{setup}{language}}} +\cmd_define_reserved {cd:section} {\cmd_internal_value{\getmessage{setup}{section}}} +\cmd_define_reserved {cd:language} {\cmd_internal_value{\getmessage{setup}{language}}} +\cmd_define_reserved {cd:processor} {\cmd_internal_value{\getmessage{setup}{processor}}} +\cmd_define_reserved {cd:style} {\cmd_internal_value{\getmessage{setup}{style}}} +\cmd_define_reserved {cd:font} {\cmd_internal_value{\getmessage{setup}{font}}} +\cmd_define_reserved {cd:character} {\cmd_internal_value{\getmessage{setup}{character}}} +\cmd_define_reserved {cd:userdata} {\cmd_internal_value{\getmessage{setup}{userdata}}} +\cmd_define_reserved {cd:key} {\cmd_internal_value{\getmessage{setup}{key}}} +\cmd_define_reserved {cd:value} {\cmd_internal_value{\getmessage{setup}{value}}} +\cmd_define_reserved {cd:color} {\cmd_internal_value{\getmessage{setup}{color}}} +\cmd_define_reserved {cd:template} {\cmd_internal_value{\getmessage{setup}{template}}} +\cmd_define_reserved {cd:node} {\cmd_internal_value{\getmessage{setup}{node}}} +\cmd_define_reserved {cd:lpath} {\cmd_internal_value{\getmessage{setup}{lpath}}} +\cmd_define_reserved {cd:setup} {\cmd_internal_value{\getmessage{setup}{setup}}} +\cmd_define_reserved {cd:xmlsetup} {\cmd_internal_value{\getmessage{setup}{xmlsetup}}} +\cmd_define_reserved {cd:luafunction} {\cmd_internal_value{\getmessage{setup}{luafunction}}} +\cmd_define_reserved {cd:marking} {\cmd_internal_value{\getmessage{setup}{marking}}} +\cmd_define_reserved {cd:sectionblock} {\cmd_internal_value{\getmessage{setup}{sectionblock}}} +\cmd_define_reserved {cd:row} {\cmd_internal_value{\getmessage{setup}{row}}} +\cmd_define_reserved {cd:column} {\cmd_internal_value{\getmessage{setup}{column}}} +\cmd_define_reserved {cd:url} {\cmd_internal_value{\getmessage{setup}{url}}} +\cmd_define_reserved {cd:true} {\cmd_internal_value{\getmessage{setup}{true}}} +\cmd_define_reserved {cd:false} {\cmd_internal_value{\getmessage{setup}{false}}} +\cmd_define_reserved {cd:category} {\cmd_internal_value{\getmessage{setup}{category}}} +\cmd_define_reserved {cd:csname} {\cmd_internal_value{\getmessage{setup}{csname}}} +\cmd_define_reserved {cd:content} {\cmd_internal_value{\getmessage{setup}{content}}} + +%cmd_define_reserved {cd:noargument} {\cmd_command_value {}} +\cmd_define_reserved {cd:oneargument} {\cmd_command_value {\texthash1}} +\cmd_define_reserved {cd:twoarguments} {\cmd_command_value {\texthash1\texthash2}} +\cmd_define_reserved {cd:threearguments} {\cmd_command_value {\texthash1\texthash2\texthash3}} + +\cmd_define_reserved {cd:sign} {[-+]} %D Auxiliary. @@ -1148,7 +1154,7 @@ \setbox2=\hbox to \wd0 {\hss \raise1.25\exheight\hbox - {\tx\ifcase\maximumSETUPargument\relax + {\txx\ifcase\maximumSETUPargument\relax \or*\else\currentSETUPargument \fi}% \hss}% @@ -1158,7 +1164,7 @@ \bgroup \txx \doif {\xmlatt{#1}{optional}} {yes} - {\c!setup!internal!{\getmessage{setup}{optional}}}% + {\cmd_internal_value{\getmessage{setup}{optional}}}% \egroup \hss}% \ht2\ht\strutbox @@ -1195,6 +1201,9 @@ \unexpanded\def\setupEQsymbol % we raise the number already {.\lower.25\exheight\hpack{=}.} +\unexpanded\def\setupAPPLYsymbol % we raise the number already + {..\lower.25\exheight\hpack{=>}..} + \starttexdefinition unexpanded showSETUPassignmentbraces #1 \ifcase\kindofsetup \showSETUPline{\letterleftbrace\setupEQsymbol\letterrightbrace} @@ -1341,8 +1350,8 @@ \unexpanded\def\showSETUPapply#1% {\showSETUP{#1} - {[..=>..]} - {[..,..=>..,...]}} + {[\setupAPPLYsymbol]} + {[..,\setupAPPLYsymbol,...]}} \unexpanded\def\showSETUPtwowords#1% {\showSETUP{#1} @@ -1356,7 +1365,7 @@ \unexpanded\def\showSETUPcsname#1% {\showSETUP{#1} - {{\c!setup!command!{}}} + {{\cmd_command_value{}}} {}} \unexpanded\def\showSETUPdestination#1% @@ -1477,7 +1486,7 @@ % official interface \unexpanded\def\cmdinternal#1% - {{\tttf\c!setup!reserved!{#1}}} % todo color .. highlight + {{\tttf\cmd_reserved_value{#1}}} % todo color .. highlight \let\cmdbasicsetup\basicsetup \let\cmdshortsetup\shortsetup |