ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: Sanjoy Mahajan <sanjoy@MIT.EDU>
To: Hans Hagen <pragma@wxs.nl>,
	Wolfgang Schuster <schuster.wolfgang@gmail.com>,
	mailing list for ConTeXt users <ntg-context@ntg.nl>
Subject: Re: underbraces get progressively more misaligned	(w/ minimal example)
Date: Thu, 03 Jul 2014 18:37:41 -0400	[thread overview]
Message-ID: <871tu23w7e.fsf@approx.mit.edu> (raw)
In-Reply-To: <53B5D497.1040108@wxs.nl>

[-- Attachment #1: Type: text/plain, Size: 2480 bytes --]

> context --make does a --generate so you can skip that and the luatools 
> run is not needed either (selfupdate is seldom needed too)

So 'context --make' is all one needs?  I'll update the wiki.

> we get a .5pt height difference somewhere (nothing else different in a 
> trace) ... smells like a luatex bug (testing that now)

That is my suspicion as well.  But I couldn't reproduce it with plain
luatex.  Though maybe I needed to use equation numbers, however that is
done in plain tex (the context run doesn't show the problem without the
\placeformula).

I suspect some internal state is getting slightly corrupted and getting
progressively worse with the 30,000 repetitions.

I've been finding many unexplained 0.5pt or so differences, which may be
related to the underbrace problem.  The context, so to speak, is that I
am putting in the last edits to the book, after having gone through and
checked every page many times.  So I want to ensure that none of the
small changes has a big effect, but I don't want to check every page
again (or I'll vomit).

Thus, I run my compare-pdfs.sh script on the previous and the latest
pdf. It renders each page to a B/W png (using mupdf) and then compares
corresponding pages using 'compare' (one of the ImageMagick tools).  Any
differing pixels are in red, and the shared pixels are in very light
gray.  Then all the pages with enough differences are viewed with 'feh',
in order of most-to-least differences.  And I check that nothing major
has changed.

What I keep finding is that pages long after where I make a small change
somehow get changed, with roughly one-pixel shifts to parts of the page.
I'm attaching an example pixel diff.  It shows changes on p.72 of the
mss.  However, the only change to the source code was on p.58 (and was
designed not to change any page breaks, which it didn't).  That same
page (p.72) often gets similar changes with all kinds of small changes.

[Note to me: In case I need to recreate the source for debugging
purposes, it's the change from rev 41ff54 to 2467d5]

In case the script is useful to others (earlier versions are in the
contexttest repository somewhere), I am attaching it.  I use it as
follows with a bash command line.  (The awk in the pipeline makes sure
that only pages with some difference make it to the viewer.)

DPI=72 compare-pdfs.sh old.pdf new.pdf | tee book-print.compare72dpi | awk '{if (($3 > 0.02)) print;}' | sort -nr -k3 | awk '{print $1}' | xargs -r feh

-Sanjoy


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: compare script --]
[-- Type: text/x-sh, Size: 1210 bytes --]

#! /bin/bash

# Usage: $0 file1.pdf file2.pdf
#
#   compares file1.pdf and file2.pdf by rendering each page and using
#   the 'compare' ImageMagick utility
#
# Copyright 2007-2014 Sanjoy Mahajan.  Licensed under the GNU GPL version 3
# or (at your option) any later version.
#
# HISTORY
#   2014-06-22: Use mudraw instead of pdftoppm.  GPL v3+
#   2009-09-30: Fix capture of dB output; don't use a viewer; use pdftoppm
#   2007-01-15: First version
#

if [ -z "$DPI" ]; then
    DPI=72
fi
ext=png

if [ -z "$1" -o -z "$2" ]; then
  echo "Usage: $0 file1.pdf file2.pdf"
  exit 3
fi

# generate the many page images in a temporary directory
d=`mktemp -d`
mkdir -p $d/a $d/b
mudraw -r $DPI -g -o $d/a/%03d.$ext $1
mudraw -r $DPI -g -o $d/b/%03d.$ext $2
wait

# find the union of the page numbers (in case one pdf has more pages)
pages=`ls $d/{a,b}/*.$ext | sed "s%.*/\([0-9][0-9]*\).$ext%\1%" | sort -un`
# compare each page
for p in $pages ; do
  if ! [ -e "$d/a/$p.$ext" ] ; then
    echo "$p: missing from $1"
    continue
  fi
  if ! [ -e "$d/b/$p.$ext" ] ; then
    echo "$p: missing from $2"
    continue
  fi
  echo -n "$d/diff-$p.$ext $p "
  compare -metric mae $d/{a,b}/$p.$ext $d/diff-$p.$ext 2>&1
done

[-- Attachment #3: pixel diff --]
[-- Type: image/png, Size: 35769 bytes --]

[-- Attachment #4: Type: text/plain, Size: 485 bytes --]

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

  reply	other threads:[~2014-07-03 22:37 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-29 10:13 Sanjoy Mahajan
2014-06-29 10:24 ` Sanjoy Mahajan
2014-07-03 10:49   ` Sanjoy Mahajan
2014-07-03 19:21     ` Wolfgang Schuster
2014-07-03 21:03       ` Sanjoy Mahajan
2014-07-03 22:09         ` Hans Hagen
2014-07-03 22:37           ` Sanjoy Mahajan [this message]
2014-07-03 22:47             ` luigi scarso
2014-07-07 13:59               ` Sanjoy Mahajan
2014-07-03 22:51             ` Hans Hagen
2014-07-04  4:58               ` Wolfgang Schuster
2014-07-04  8:22                 ` Hans Hagen
2014-07-04  9:34                 ` Sanjoy Mahajan
2014-07-05  0:30                   ` Hans Hagen
2014-07-07  2:16                     ` Sanjoy Mahajan
2014-07-07  3:48                       ` Sanjoy Mahajan
2014-07-07 13:56             ` Sanjoy Mahajan
2014-07-07 13:53       ` Sanjoy Mahajan
2014-07-04  7:12 Akira Kakuto
2014-07-04  8:17 ` Hans Hagen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=871tu23w7e.fsf@approx.mit.edu \
    --to=sanjoy@mit.edu \
    --cc=ntg-context@ntg.nl \
    --cc=pragma@wxs.nl \
    --cc=schuster.wolfgang@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).