+ for (z = b->z; z < page->n[axis] - page->h[axis][1]; z++)
+ {
+ int needed = needed_size (b, z + 1);
+ if (needed > size)
+ {
+ if (cell_is_breakable (b, z))
+ {
+ /* If there is no right header and we render a partial cell on
+ the right side of the body, then we omit the rightmost rule of
+ the body. Otherwise the rendering is deceptive because it
+ looks like the whole cell is present instead of a partial
+ cell.
+
+ This is similar to code for the left side in needed_size(). */
+ int rule_allowance = (page->h[axis][1]
+ ? 0
+ : rule_width (page, axis, z));
+
+ /* The amount that, if we added cell 'z', the rendering would
+ overfill the allocated 'size'. */
+ int overhang = needed - size - rule_allowance;
+
+ /* The width of cell 'z'. */
+ int cell_size = cell_width (page, axis, z);
+
+ /* The amount trimmed off the left side of 'z',
+ and the amount left to render. */
+ int cell_ofs = z == b->z ? b->pixel : 0;
+ int cell_left = cell_size - cell_ofs;
+
+ /* A small but visible width. */
+ int em = page->params->font_size[axis];
+
+ /* If some of the cell remains to render,
+ and there would still be some of the cell left afterward,
+ then partially render that much of the cell. */
+ pixel = (cell_left && cell_left > overhang
+ ? cell_left - overhang + cell_ofs
+ : 0);
+
+ /* If there would be only a tiny amount of the cell left after
+ rendering it partially, reduce the amount rendered slightly
+ to make the output look a little better. */
+ if (pixel + em > cell_size)
+ pixel = MAX (pixel - em, 0);
+
+ /* If we're breaking vertically, then consider whether the cells
+ being broken have a better internal breakpoint than the exact
+ number of pixels available, which might look bad e.g. because
+ it breaks in the middle of a line of text. */
+ if (axis == TABLE_VERT && page->params->adjust_break)
+ {
+ int x;
+
+ for (x = 0; x < page->n[H]; )
+ {
+ struct table_cell cell;
+ int better_pixel;
+ int w;
+
+ table_get_cell (page->table, x, z, &cell);
+ w = joined_width (page, H, cell.d[H][0], cell.d[H][1]);
+ better_pixel = page->params->adjust_break (
+ page->params->aux, &cell, w, pixel);
+ x = cell.d[H][1];
+ table_cell_free (&cell);
+
+ if (better_pixel < pixel)
+ {
+ if (better_pixel > (z == b->z ? b->pixel : 0))
+ {
+ pixel = better_pixel;
+ break;
+ }
+ else if (better_pixel == 0 && z != b->z)
+ {
+ pixel = 0;
+ break;
+ }
+ }
+ }
+ }
+ }
+ break;
+ }
+ }