Tables are a major feature for Nisus Writer Express version 2.0, and we’ve been working hard on them. There are a lot of little details that take time to get things just right. For instance: drawing table cell borders.
When drawing table cells we wanted to make sure that the border edges look sharp and clean. To accomplish this we have to prevent the lines from being antialiased when drawn on screen. This means that a thin line has to be drawn at the exact same coordinate as the pixel it should fill.
On the Macintosh screen pixels are one point (1pt) wide. This means that if you imagine a pixel as a square, the bottom of the square is at y-coordinate of 0.0, and the top of the square is at 1.0. So for a 1pt line to exactly fill that pixel, it must be centered inside the pixel at a y-coordinate of 0.5. Had we tried to draw the line at 0.0 only the top half of the line would have fallen into the pixel. The other half would have wound up in the pixel below, and we would have a 1pt line that was drawn into two pixels, leading to a fuzzy image.
Drawing is slightly different with lines of even width. Imagine a 2pt line. If we try to draw the line at 0.5, then we fill the pixel with coordinates 0.0 through 1.0, but the remaining 1pt of the line would spill into the pixels above and below. So again we have 1pt of line drawn into 2 pixels, yielding a fuzzy line. So when drawing lines of even point widths, we have to align them on integer coordinates.
For tables things are made more complicated by different line styles, weights, joins, user specified row heights, and other kinds of table properties. When considering all these, you cannot just draw a border edge at the nearest 0.5 or 1.0 coordinate, since other cells depend on an edge being drawn at a particular location.
In some cases it is actually impossible to avoid antialiasing. For example, imagine a 1pt line and a 2pt line both centered along the same axis. If you draw them both at 0.5, the 1pt line will be sharp, but the 2pt line will be fuzzy. If you choose 1.0, then the 1pt line will be fuzzy.
Getting all this right took just about a day of work, but table borders are looking good. We hope you guys will enjoy using our slick table editor when 2.0 is released.