patch: fix character alignment on long tables
Hi, here is a patch for consideration. The character alignment code would fail on tables with more than 100 rows, as it was encoding the row/column number into a single integer 100*column+row. I modified the code to pass in the row and column using separate attributes. Thanks, Brian diff --git a/tex/texmf-context/tex/context/base/typo-tal.lua b/tex/texmf-context/tex/context/base/typo-tal.lua index 5d62d4e..51a8c52 100644 --- a/tex/texmf-context/tex/context/base/typo-tal.lua +++ b/tex/texmf-context/tex/context/base/typo-tal.lua @@ -65,8 +65,9 @@ typesetters.characteralign = characteralign local trace_split = false trackers.register("typesetters.characteralign", function(v) trace_split = true end) local report = logs.reporter("aligning") -local a_characteralign = attributes.private("characteralign") -local a_character = attributes.private("characters") +local a_characteralignrow = attributes.private("characteralignrow") +local a_characteraligncolumn = attributes.private("characteraligncolumn") +local a_character = attributes.private("characters") local enabled = false @@ -108,12 +109,11 @@ function characteralign.handler(originalhead,where) if not first then return originalhead, false end - local a = getattr(first,a_characteralign) - if not a or a == 0 then + local row = getattr(first,a_characteralignrow) + local column = getattr(first,a_characteraligncolumn) + if not row or row == 0 or not column or column==0 then return originalhead, false end - local column = div(a,100) - local row = a % 100 local dataset = datasets and datasets[column] or setcharacteralign(column) local separator = dataset.separator local list = dataset.list diff --git a/tex/texmf-context/tex/context/base/typo-tal.mkiv b/tex/texmf-context/tex/context/base/typo-tal.mkiv index 32b99ff..a9606ac 100644 --- a/tex/texmf-context/tex/context/base/typo-tal.mkiv +++ b/tex/texmf-context/tex/context/base/typo-tal.mkiv @@ -24,7 +24,8 @@ \registerctxluafile{typo-tal}{1.001} -\definesystemattribute[characteralign][public] +\definesystemattribute[characteralignrow][public] +\definesystemattribute[characteraligncolumn][public] %D This mechanism is mostly meant for tables: %D @@ -56,10 +57,10 @@ % D % D \typebuffer \blank \getbuffer \blank -\unexpanded\def\signalcharacteralign#1#2{\attribute\characteralignattribute=\numexpr#1*\plushundred+#2\relax} +\unexpanded\def\signalcharacteralign#1#2{\attribute\characteraligncolumnattribute=#1\attribute\characteralignrowattribute=#2} \unexpanded\def\setcharacteralign #1#2{\ctxcommand{setcharacteralign(\number#1,"#2")}} \unexpanded\def\resetcharacteralign {\ctxcommand{resetcharacteralign()}} -\unexpanded\def\nocharacteralign {\attribute\characteralignattribute\attributeunsetvalue} +\unexpanded\def\nocharacteralign {\attribute\characteralignrowattribute\attributeunsetvalue\attribute\characteraligncolumnattribute\attributeunsetvalue} %D Mostly downward compatible: %D
On 8/12/2014 5:12 AM, Brian Landy wrote:
Hi, here is a patch for consideration. The character alignment code would fail on tables with more than 100 rows, as it was encoding the row/column number into a single integer 100*column+row. I modified the code to pass in the row and column using separate attributes.
100 => 0xFFFF is easier
Thanks, Brian
diff --git a/tex/texmf-context/tex/context/base/typo-tal.lua b/tex/texmf-context/tex/context/base/typo-tal.lua index 5d62d4e..51a8c52 100644 --- a/tex/texmf-context/tex/context/base/typo-tal.lua +++ b/tex/texmf-context/tex/context/base/typo-tal.lua @@ -65,8 +65,9 @@ typesetters.characteralign = characteralign local trace_split = false trackers.register("typesetters.characteralign", function(v) trace_split = true end) local report = logs.reporter("aligning")
-local a_characteralign = attributes.private("characteralign") -local a_character = attributes.private("characters") +local a_characteralignrow = attributes.private("characteralignrow") +local a_characteraligncolumn = attributes.private("characteraligncolumn") +local a_character = attributes.private("characters")
local enabled = false
@@ -108,12 +109,11 @@ function characteralign.handler(originalhead,where) if not first then return originalhead, false end - local a = getattr(first,a_characteralign) - if not a or a == 0 then + local row = getattr(first,a_characteralignrow) + local column = getattr(first,a_characteraligncolumn) + if not row or row == 0 or not column or column==0 then return originalhead, false end - local column = div(a,100) - local row = a % 100 local dataset = datasets and datasets[column] or setcharacteralign(column) local separator = dataset.separator local list = dataset.list diff --git a/tex/texmf-context/tex/context/base/typo-tal.mkiv b/tex/texmf-context/tex/context/base/typo-tal.mkiv index 32b99ff..a9606ac 100644 --- a/tex/texmf-context/tex/context/base/typo-tal.mkiv +++ b/tex/texmf-context/tex/context/base/typo-tal.mkiv @@ -24,7 +24,8 @@
\registerctxluafile{typo-tal}{1.001}
-\definesystemattribute[characteralign][public] +\definesystemattribute[characteralignrow][public] +\definesystemattribute[characteraligncolumn][public]
%D This mechanism is mostly meant for tables: %D @@ -56,10 +57,10 @@ % D % D \typebuffer \blank \getbuffer \blank
-\unexpanded\def\signalcharacteralign#1#2{\attribute\characteralignattribute=\numexpr#1*\plushundred+#2\relax} +\unexpanded\def\signalcharacteralign#1#2{\attribute\characteraligncolumnattribute=#1\attribute\characteralignrowattribute=#2} \unexpanded\def\setcharacteralign #1#2{\ctxcommand{setcharacteralign(\number#1,"#2")}} \unexpanded\def\resetcharacteralign {\ctxcommand{resetcharacteralign()}} -\unexpanded\def\nocharacteralign {\attribute\characteralignattribute\attributeunsetvalue} +\unexpanded\def\nocharacteralign {\attribute\characteralignrowattribute\attributeunsetvalue\attribute\characteraligncolumnattribute\attributeunsetvalue}
%D Mostly downward compatible: %D
_______________________________________________ dev-context mailing list dev-context@ntg.nl http://www.ntg.nl/mailman/listinfo/dev-context
-- ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com | www.pragma-pod.nl -----------------------------------------------------------------
participants (2)
-
Brian Landy
-
Hans Hagen