Skip to content

Instantly share code, notes, and snippets.

@reffort
Created July 31, 2015 01:02
Show Gist options
  • Save reffort/ef857c786a4c35b33c38 to your computer and use it in GitHub Desktop.
Save reffort/ef857c786a4c35b33c38 to your computer and use it in GitHub Desktop.
Marks word space size categories in the margin
/*
To obtain a quantitative measure of the word space sizes, this code prints a character in the margin indicating a size category
for the word spaces of that line. It hijacks the margin character functionality.
At line 427 of n7.c, replace these two lines
else if (admod == 0 && spreadwarn && adsp >= spreadlimit)
errprint("spreadlimit exceeded, %gm", (double)adsp/EM);
with
*/
else {
if (admod == 0 && spreadwarn && adsp >= spreadlimit)
errprint("spreadlimit exceeded, %gm", (double)adsp/EM);
if (admod == 0) {
double adratiom ;
adratiom = ((double) (adsp+minsps) / (double) sps) ;
/*
// These are the TeX fitness classes described for word spaces in KP-81 p.1155
// with max stretch = 1.5 and max shrink = 0.667
// The order of the class numbers is reversed in TeX82.pdf, section 817
// < 0.666 not allowed
if (adratiom <= 0.835) ic = '0' ; // tight
else if (adratiom <= 1.25) ic = '1' ; // normal ("decent" in TeX82)
else if (adratiom <= 1.5) ic = '2' ; // loose
else ic = '3' ; // very loose
*/
if (adratiom < 0.0833) ic = 'f' ; // ss < 1
else if (adratiom < 0.1667) ic = 'e' ;
else if (adratiom < 0.2500) ic = 'd' ; // ss 3
else if (adratiom < 0.3333) ic = 'c' ;
else if (adratiom < 0.4167) ic = 'b' ; // ss 4
else if (adratiom < 0.5000) ic = 'a' ; // extra tight
else if (adratiom < 0.5833) ic = '0' ; // very tight, minss 6
else if (adratiom < 0.6660) ic = '1' ; // very tight
else if (adratiom < 0.7500) ic = '2' ; // tight, minss 8, smallest allowable TeX space
else if (adratiom < 0.8333) ic = '3' ; // tight
else if (adratiom < 0.9167) ic = '4' ; // normal
else if (adratiom <= 1.1250) ic = '5' ; // very close to nominal
else if (adratiom <= 1.2500) ic = '6' ; // normal
else if (adratiom <= 1.3750) ic = '7' ; // loose
else if (adratiom <= 1.5000) ic = '8' ; // loose, largest desirable TeX space
else if (adratiom <= 1.6250) ic = '9' ; // very loose
else if (adratiom <= 1.7500) ic = 'A' ; // ... and looser
else if (adratiom <= 1.8750) ic = 'B' ;
else if (adratiom <= 2.0000) ic = 'C' ;
else ic = 'X' ;
}
}
// end of temporary space category code
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment