From aa320cf8072497abb9b714886e1f9279c525c392 Mon Sep 17 00:00:00 2001 From: zzo38 Date: Mon, 19 Mar 2012 22:41:21 -0700 Subject: [PATCH] Horizontal and vertical packaging. --- compile | 6 +++--- texnicard.w | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++++------ 2 files changed, 57 insertions(+), 9 deletions(-) diff --git a/compile b/compile index 05c5597..d27e2d6 100755 --- a/compile +++ b/compile @@ -1,8 +1,8 @@ #!/usr/bin/env bash -# Type -g to compile with debug +# Type -g to compile with debug # For production book, use -n option to cweave (omit line numbers) -cweave texnicard;tex texnicard -[ $# -eq 2 ] || ctangle texnicard +cweave +s texnicard;tex texnicard +[ $# -eq 2 ] || ctangle +s texnicard echo ------ [ $# -eq 2 ] || gcc -std=gnu89 -Winline -Wundef -Wfloat-equal \ -Wunused-function -Wno-long-long -Wno-parentheses \ diff --git a/texnicard.w b/texnicard.w index 5dc5e42..4bea20b 100755 --- a/texnicard.w +++ b/texnicard.w @@ -5669,7 +5669,7 @@ the letters in the box. } @ @= { - for(this=first;*this;this=this->next) { + for(this=first;this;this=this->next) { switch(type_of(this)) { case chars_node: @; @+break; case hlist_node: case vlist_node: case rule_node: @@ -5706,7 +5706,10 @@ the letters in the box. shrinkability[subtype_of(this)>>2]+=this->shrink; } -@ +@ When packing a special node that has a code to run during packing, it +can read and affect the current width and the intended width; it could +also do other things, such as accumulating boxes for adjustments and so +on. @= { push_num(at_size); @@ -5786,6 +5789,53 @@ at the top instead of at the bottom. scaled bonnet=0; // Height of first item scaled boot=0; // Depth of last item box_node*this; // Current node + @; + @; + box->height=bonnet; @+ box->depth=boot; +#define @!actual @, (*(align_top?&(box->depth):&(box->height))) + natural-=align_top?bonnet:boot; + actual=(factor*natural)/8+at_size; + @; +#undef actual + @; + return box; +} + +@ @= { + int o; + box->list=first; + box->width=box->shift_amount=0; + box->glue_set=0; + for(o=0;o<4;o++) stretchability[o]=shrinkability[o]=0; +} + +@ @= { + for(this=first;this;this=this->next) { + switch(type_of(this)) { + case hlist_node: case vlist_node: case rule_node: + @; @+break; + case kern_node: natural+=this->distance; @+boot=0; @+break; + case glue_node: @; @+break; + case special_node: + if(subtype_of(this)==spec_pack) @; + @+break; + default: break; // All other nodes are ignored + } + if(this==first) bonnet=natural-boot; + } +} + +@ @= { + natural+=this->height+(boot=this->depth); + if(this->width+this->shift_amount>box->width) + box->width=this->width+this->width; +} + +@ @= { + if(box->depth>max_dp) { + box->height+=box->depth-max_dp; + box->depth=max_dp; + } } @*Typesetting Commands. There are various commands available in \TeX @@ -5821,6 +5871,8 @@ to enter distances using units. int num,den; // Numerator and denominator to scale the units } +@*Internal Image Rendering. + @*Main Program. This is where the program starts and ends. Everything else in the other chapters is started from here. @@ -5964,10 +6016,6 @@ $\bullet$ Built-in typesetting (using some of the algorithms of \TeX) and image manipulation, so that there is no dependence on external programs, and everything can be done in one pass. -$\bullet$ Big spider! -@^arachnids@> -@^spider@> - @*Bibliography. \count255=0 % -- 2.11.4.GIT